Package org.springframework.social.connect.support

Examples of org.springframework.social.connect.support.ConnectionFactoryRegistry


    // TODO: Assert attempt contents
  }

  @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"))
View Full Code Here


      .andExpect(redirectedUrl("/signin?error=multiple_users"));
  }

  @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();
View Full Code Here

      .andExpect(redirectedUrl("/customsignin?param=1234&error=multiple_users"));
  }

  @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

  public void oauth1Callback_matchingUser_withOriginalUrl() throws Exception {
    performOAuth1Callback("/original", null);
  }

  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

  }

  // OAuth 2
  @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();
View Full Code Here

      .andExpect(redirectedUrl("https://someprovider.com/oauth/authorize?client_id=clientId&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%2Fsignin%2Foauth2Provider&state=STATE"));
  }

  @Test
  public void oauth2Callback_noMatchingUser() throws Exception {
    ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry();
    ConnectionFactory<TestApi2> connectionFactory2 = new StubOAuth2ConnectionFactory("clientId", "clientSecret");
    connectionFactoryLocator.addConnectionFactory(connectionFactory2);
    StubUsersConnectionRepository usersConnectionRepository = new StubUsersConnectionRepository();
    ProviderSignInController providerSignInController = new ProviderSignInController(connectionFactoryLocator, usersConnectionRepository, null);
    providerSignInController.afterPropertiesSet();
    MockMvc mockMvc = standaloneSetup(providerSignInController).build();
    mockMvc.perform(get("/signin/oauth2Provider").param("code", "authcode"))
View Full Code Here

    // TODO: Assert attempt contents
  }

  @Test
  public void oauth2Callback_noMatchingUser_customSignUpUrl() throws Exception {
    ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry();
    ConnectionFactory<TestApi2> connectionFactory2 = new StubOAuth2ConnectionFactory("clientId", "clientSecret");
    connectionFactoryLocator.addConnectionFactory(connectionFactory2);
    StubUsersConnectionRepository usersConnectionRepository = new StubUsersConnectionRepository();
    ProviderSignInController controller = new ProviderSignInController(connectionFactoryLocator, usersConnectionRepository, null);
    controller.setSignUpUrl("/register");
    controller.afterPropertiesSet();
    MockMvc mockMvc = standaloneSetup(controller).build();
View Full Code Here

    // TODO: Assert attempt contents
  }

  @Test
  public void oauth2ErrorCallback() throws Exception {
    ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry();
    ConnectionFactory<TestApi2> connectionFactory2 = new StubOAuth2ConnectionFactory("clientId", "clientSecret");
    connectionFactoryLocator.addConnectionFactory(connectionFactory2);
    StubUsersConnectionRepository usersConnectionRepository = new StubUsersConnectionRepository();
    ProviderSignInController controller = new ProviderSignInController(connectionFactoryLocator, usersConnectionRepository, null);
    MockMvc mockMvc = standaloneSetup(controller).build();
    mockMvc.perform(get("/signin/oauth2Provider").param("error", "access_denied"))
      .andExpect(redirectedUrl("/signin?error=access_denied"));
View Full Code Here

  }

  @Test
  public void oauth2ErrorCallback_withDescriptionAndUri() throws Exception {
    ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry();
    ConnectionFactory<TestApi2> connectionFactory2 = new StubOAuth2ConnectionFactory("clientId", "clientSecret");
    connectionFactoryLocator.addConnectionFactory(connectionFactory2);
    StubUsersConnectionRepository usersConnectionRepository = new StubUsersConnectionRepository();
    ProviderSignInController controller = new ProviderSignInController(connectionFactoryLocator, usersConnectionRepository, null);
    MockMvc mockMvc = standaloneSetup(controller).build();
    mockMvc.perform(get("/signin/oauth2Provider")
      .param("error", "access_denied")
View Full Code Here

      .andExpect(redirectedUrl("/signin?error=access_denied&error_description=The+user+said+no.&error_uri=http%3A%2F%2Fprovider.com%2Fuser%2Fsaid%2Fno"));
  }

  @Test
  public void oauth2Callback_multipleMatchingUsers() throws Exception {
    ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry();
    ConnectionFactory<TestApi2> connectionFactory2 = new StubOAuth2ConnectionFactory("clientId", "clientSecret");
    connectionFactoryLocator.addConnectionFactory(connectionFactory2);
    StubUsersConnectionRepository usersConnectionRepository = new StubUsersConnectionRepository(asList("testuser1", "testuser2"));
    ProviderSignInController providerSignInController = new ProviderSignInController(connectionFactoryLocator, usersConnectionRepository, null);
    providerSignInController.afterPropertiesSet();
    MockMvc mockMvc = standaloneSetup(providerSignInController).build();
    mockMvc.perform(get("/signin/oauth2Provider").param("code", "authcode"))
View Full Code Here

TOP

Related Classes of org.springframework.social.connect.support.ConnectionFactoryRegistry

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.