Package org.springframework.social.connect.web.test

Examples of org.springframework.social.connect.web.test.StubUsersConnectionRepository


  @Test
  public void constructor() {
    ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry();
    ConnectionFactory<TestApi1> connectionFactory1 = new StubOAuth1ConnectionFactory("clientId", "clientSecret");
    connectionFactoryLocator.addConnectionFactory(connectionFactory1);
    StubUsersConnectionRepository usersConnectionRepository = new StubUsersConnectionRepository();
    usersConnectionRepository.createConnectionRepository("habuma").addConnection(connectionFactory1.createConnection(
      new ConnectionData("oauth1Provider", "provider1User1", null, null, null, null, null, null, null)));
    ProviderSignInController providerSignInController = new ProviderSignInController(connectionFactoryLocator, usersConnectionRepository, null);
    providerSignInController.setApplicationUrl("my.url");
  }
View Full Code Here


  @Test
  public void signIn_OAuth1Provider() throws Exception {
    ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry();
    ConnectionFactory<TestApi1> connectionFactory1 = new StubOAuth1ConnectionFactory("clientId", "clientSecret");
    connectionFactoryLocator.addConnectionFactory(connectionFactory1);
    StubUsersConnectionRepository usersConnectionRepository = new StubUsersConnectionRepository();
    usersConnectionRepository.createConnectionRepository("habuma").addConnection(connectionFactory1.createConnection(
      new ConnectionData("oauth1Provider", "provider1User1", null, null, null, null, null, null, null)));
    ProviderSignInController providerSignInController = new ProviderSignInController(connectionFactoryLocator, usersConnectionRepository, null);
    providerSignInController.afterPropertiesSet();
    MockMvc mockMvc = standaloneSetup(providerSignInController).build();
    mockMvc.perform(post("/signin/oauth1Provider"))
View Full Code Here

  @Test
  public void signIn_OAuth1Provider_exceptionWhileFetchingRequestToken() throws Exception {
    ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry();
    ConnectionFactory<TestApi1> connectionFactory1 = new StubOAuth1ConnectionFactory("clientId", "clientSecret", StubOAuthTemplateBehavior.THROW_EXCEPTION);
    connectionFactoryLocator.addConnectionFactory(connectionFactory1);
    StubUsersConnectionRepository usersConnectionRepository = new StubUsersConnectionRepository();
    usersConnectionRepository.createConnectionRepository("habuma").addConnection(connectionFactory1.createConnection(
      new ConnectionData("oauth1Provider", "provider1User1", null, null, null, null, null, null, null)));
    ProviderSignInController providerSignInController = new ProviderSignInController(connectionFactoryLocator, usersConnectionRepository, null);
    providerSignInController.afterPropertiesSet();
    MockMvc mockMvc = standaloneSetup(providerSignInController).build();
    mockMvc.perform(post("/signin/oauth1Provider"))
View Full Code Here

  @Test
  public void oauth1Callback_noMatchingUser() throws Exception {
    ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry();
    ConnectionFactory<TestApi1> connectionFactory1 = new StubOAuth1ConnectionFactory("clientId", "clientSecret");
    connectionFactoryLocator.addConnectionFactory(connectionFactory1);
    StubUsersConnectionRepository usersConnectionRepository = new StubUsersConnectionRepository();
    ProviderSignInController providerSignInController = new ProviderSignInController(connectionFactoryLocator, usersConnectionRepository, null);
    providerSignInController.afterPropertiesSet();
    MockMvc mockMvc = standaloneSetup(providerSignInController).build();
    mockMvc.perform(get("/signin/oauth1Provider").param("verifier", "verifier").param("oauth_token", "requestToken"))
      .andExpect(redirectedUrl("/signup"))
View Full Code Here

  @Test
  public void oauth1Callback_noMatchingUser_customSignUpUrl() throws Exception {
    ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry();
    ConnectionFactory<TestApi1> connectionFactory1 = new StubOAuth1ConnectionFactory("clientId", "clientSecret");
    connectionFactoryLocator.addConnectionFactory(connectionFactory1);
    StubUsersConnectionRepository usersConnectionRepository = new StubUsersConnectionRepository();
    ProviderSignInController providerSignInController = new ProviderSignInController(connectionFactoryLocator, usersConnectionRepository, null);
    providerSignInController.setSignUpUrl("/register");
    providerSignInController.afterPropertiesSet();
    MockMvc mockMvc = standaloneSetup(providerSignInController).build();
    mockMvc.perform(get("/signin/oauth1Provider").param("verifier", "verifier").param("oauth_token", "requestToken"))
View Full Code Here

  @Test
  public void oauth1Callback_multipleMatchingUsers() throws Exception {
    ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry();
    ConnectionFactory<TestApi1> connectionFactory1 = new StubOAuth1ConnectionFactory("clientId", "clientSecret");
    connectionFactoryLocator.addConnectionFactory(connectionFactory1);
    StubUsersConnectionRepository usersConnectionRepository = new StubUsersConnectionRepository(Arrays.asList("testuser1", "testuser2"));
    ProviderSignInController providerSignInController = new ProviderSignInController(connectionFactoryLocator, usersConnectionRepository, null);
    providerSignInController.afterPropertiesSet();
    MockMvc mockMvc = standaloneSetup(providerSignInController).build();
    mockMvc.perform(get("/signin/oauth1Provider").param("verifier", "verifier").param("oauth_token", "requestToken"))
      .andExpect(redirectedUrl("/signin?error=multiple_users"));
View Full Code Here

  @Test
  public void oauth1Callback_multipleMatchingUsers_customSignInUrl() throws Exception {
    ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry();
    ConnectionFactory<TestApi1> connectionFactory1 = new StubOAuth1ConnectionFactory("clientId", "clientSecret");
    connectionFactoryLocator.addConnectionFactory(connectionFactory1);
    StubUsersConnectionRepository usersConnectionRepository = new StubUsersConnectionRepository(Arrays.asList("testuser1", "testuser2"));
    ProviderSignInController providerSignInController = new ProviderSignInController(connectionFactoryLocator, usersConnectionRepository, null);
    providerSignInController.setSignInUrl("/customsignin?param=1234");
    providerSignInController.afterPropertiesSet();
    MockMvc mockMvc = standaloneSetup(providerSignInController).build();
    mockMvc.perform(get("/signin/oauth1Provider").param("verifier", "verifier").param("oauth_token", "requestToken"))
View Full Code Here

  @Test
  public void oauth1Callback_errorWhileExchangingForAccessToken() throws Exception {
    ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry();
    ConnectionFactory<TestApi1> connectionFactory1 = new StubOAuth1ConnectionFactory("clientId", "clientSecret", StubOAuthTemplateBehavior.THROW_EXCEPTION);
    connectionFactoryLocator.addConnectionFactory(connectionFactory1);
    StubUsersConnectionRepository usersConnectionRepository = new StubUsersConnectionRepository(Arrays.asList("testuser1"));
    MockMvc mockMvc = standaloneSetup(new ProviderSignInController(connectionFactoryLocator, usersConnectionRepository, null)).build();
    mockMvc.perform(get("/signin/oauth1Provider").param("verifier", "verifier").param("oauth_token", "requestToken"))
      .andExpect(redirectedUrl("/signin?error=provider"));
  }
View Full Code Here

  private void performOAuth1Callback(String originalUrl, String postSignInUrl) throws Exception {
    ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry();
    ConnectionFactory<TestApi1> connectionFactory1 = new StubOAuth1ConnectionFactory("clientId", "clientSecret");
    connectionFactoryLocator.addConnectionFactory(connectionFactory1);
    StubUsersConnectionRepository usersConnectionRepository = new StubUsersConnectionRepository(asList("habuma"));
    SignInAdapter signInAdapter = new TestSignInAdapter(originalUrl);
    ProviderSignInController controller = new ProviderSignInController(connectionFactoryLocator, usersConnectionRepository, signInAdapter);
    if (postSignInUrl != null) {
      controller.setPostSignInUrl(postSignInUrl);
    }
View Full Code Here

  @Test
  public void signIn_OAuth2Provider() throws Exception {
    ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry();
    ConnectionFactory<TestApi2> connectionFactory2 = new StubOAuth2ConnectionFactory("clientId", "clientSecret");
    connectionFactoryLocator.addConnectionFactory(connectionFactory2);
    StubUsersConnectionRepository usersConnectionRepository = new StubUsersConnectionRepository();
    usersConnectionRepository.createConnectionRepository("habuma").addConnection(connectionFactory2.createConnection(
      new ConnectionData("oauth2Provider", "provider2User1", null, null, null, null, null, null, null)));
    ProviderSignInController providerSignInController = new ProviderSignInController(connectionFactoryLocator, usersConnectionRepository, null);
    providerSignInController.afterPropertiesSet();
    MockMvc mockMvc = standaloneSetup(providerSignInController).build();
    mockMvc.perform(post("/signin/oauth2Provider"))
View Full Code Here

TOP

Related Classes of org.springframework.social.connect.web.test.StubUsersConnectionRepository

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.