Package org.springframework.social.connect.support

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


    assertFalse(((TestConnectInterceptor<?>)(interceptors.get(1))).preConnectInvoked);
  }

  @Test
  public void connect_OAuth1Provider_exceptionWhileFetchingRequestToken() throws Exception {
    ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry();
    ConnectionFactory<TestApi1> connectionFactory = new StubOAuth1ConnectionFactory("clientId", "clientSecret", StubOAuthTemplateBehavior.THROW_EXCEPTION);
    connectionFactoryLocator.addConnectionFactory(connectionFactory);
    MockMvc mockMvc = standaloneSetup(new ConnectController(connectionFactoryLocator, null)).build();
    mockMvc.perform(post("/connect/oauth1Provider"))
      .andExpect(redirectedUrl("/connect/oauth1Provider"))
      .andExpect(request().sessionAttribute("social_provider_error", notNullValue()));
  }
View Full Code Here


      .andExpect(request().sessionAttribute("social_provider_error", notNullValue()));
  }
 
  @Test
  public void oauth1Callback() throws Exception {
    ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry();
    ConnectionFactory<TestApi1> connectionFactory = new StubOAuth1ConnectionFactory("clientId", "clientSecret");
    connectionFactoryLocator.addConnectionFactory(connectionFactory);
    StubConnectionRepository connectionRepository = new StubConnectionRepository();
    ConnectController connectController = new ConnectController(connectionFactoryLocator, connectionRepository);
    List<ConnectInterceptor<?>> interceptors = getConnectInterceptor();
    connectController.setConnectInterceptors(interceptors);
    connectController.afterPropertiesSet();
View Full Code Here

    assertFalse(((TestConnectInterceptor<?>)(interceptors.get(1))).postConnectInvoked);
  }

  @Test
  public void oauth1Callback_exceptionWhileFetchingAccessToken() throws Exception {
    ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry();
    ConnectionFactory<TestApi1> connectionFactory = new StubOAuth1ConnectionFactory("clientId", "clientSecret", THROW_EXCEPTION);
    connectionFactoryLocator.addConnectionFactory(connectionFactory);
    StubConnectionRepository connectionRepository = new StubConnectionRepository();
    MockMvc mockMvc = standaloneSetup(new ConnectController(connectionFactoryLocator, connectionRepository)).build();
    assertEquals(0, connectionRepository.findConnections("oauth2Provider").size());   
    mockMvc.perform(get("/connect/oauth1Provider")
            .sessionAttr("oauthToken", new OAuthToken("requestToken", "requestTokenSecret"))
View Full Code Here

  // OAuth 2
 
  @Test
  public void connect_OAuth2Provider() throws Exception {
    ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry();
    ConnectionFactory<TestApi2> connectionFactory = new StubOAuth2ConnectionFactory("clientId", "clientSecret");
    connectionFactoryLocator.addConnectionFactory(connectionFactory);
    ConnectController connectController = new ConnectController(connectionFactoryLocator, null);
    List<ConnectInterceptor<?>> interceptors = getConnectInterceptor();
    connectController.setConnectInterceptors(interceptors);
    connectController.afterPropertiesSet();
    MockMvc mockMvc = standaloneSetup(connectController).build();
View Full Code Here

    assertEquals("oauth2Provider", testInterceptor2.connectionFactory.getProviderId());
  }

  @Test
  public void connect_OAuth2Provider_withScope() throws Exception {
    ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry();
    ConnectionFactory<TestApi2> connectionFactory = new StubOAuth2ConnectionFactory("clientId", "clientSecret");
    connectionFactoryLocator.addConnectionFactory(connectionFactory);
    ConnectController connectController = new ConnectController(connectionFactoryLocator, null);
    connectController.afterPropertiesSet();
    MockMvc mockMvc = standaloneSetup(connectController).build();
    mockMvc.perform(post("/connect/oauth2Provider").param("scope", "read,write"))
      .andExpect(redirectedUrl(OAUTH2_AUTHORIZE_URL + "&scope=read%2Cwrite&state=STATE"));
View Full Code Here

      .andExpect(redirectedUrl(OAUTH2_AUTHORIZE_URL + "&scope=read%2Cwrite&state=STATE"));
  }
 
  @Test
  public void oauth2Callback() throws Exception {
    ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry();
    ConnectionFactory<TestApi2> connectionFactory = new StubOAuth2ConnectionFactory("clientId", "clientSecret");
    connectionFactoryLocator.addConnectionFactory(connectionFactory);
    StubConnectionRepository connectionRepository = new StubConnectionRepository();
    ConnectController connectController = new ConnectController(connectionFactoryLocator, connectionRepository);
    List<ConnectInterceptor<?>> interceptors = getConnectInterceptor();
    connectController.setConnectInterceptors(interceptors);
    connectController.afterPropertiesSet();
View Full Code Here

    assertTrue(testInterceptor2.postConnectInvoked);
  }

  @Test
  public void oauth2Callback_exceptionWhileFetchingAccessToken() throws Exception {
    ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry();
    ConnectionFactory<TestApi2> connectionFactory = new StubOAuth2ConnectionFactory("clientId", "clientSecret", THROW_EXCEPTION);
    connectionFactoryLocator.addConnectionFactory(connectionFactory);
    StubConnectionRepository connectionRepository = new StubConnectionRepository();
    MockMvc mockMvc = standaloneSetup(new ConnectController(connectionFactoryLocator, connectionRepository)).build();
    assertEquals(0, connectionRepository.findConnections("oauth2Provider").size());   
    mockMvc.perform(get("/connect/oauth2Provider").param("code", "oauth2Code"))
      .andExpect(redirectedUrl("/connect/oauth2Provider"))
View Full Code Here

    assertEquals(0, connectionRepository.findConnections("oauth2Provider").size());   
  }
 
  @Test
  public void oauth2ErrorCallback() throws Exception {
    ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry();
    ConnectionFactory<TestApi2> connectionFactory = new StubOAuth2ConnectionFactory("clientId", "clientSecret", THROW_EXCEPTION);
    connectionFactoryLocator.addConnectionFactory(connectionFactory);
    StubConnectionRepository connectionRepository = new StubConnectionRepository();
    MockMvc mockMvc = standaloneSetup(new ConnectController(connectionFactoryLocator, connectionRepository)).build();
    assertEquals(0, connectionRepository.findConnections("oauth2Provider").size());   
    HashMap<String, String> expectedError = new HashMap<String, String>();
    expectedError.put("error", "access_denied");
View Full Code Here

      .andExpect(request().sessionAttribute("social_authorization_error", expectedError));
  }

  @Test
  public void oauth2ErrorCallback_noDescriptionOrUri() throws Exception {
    ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry();
    ConnectionFactory<TestApi2> connectionFactory = new StubOAuth2ConnectionFactory("clientId", "clientSecret", THROW_EXCEPTION);
    connectionFactoryLocator.addConnectionFactory(connectionFactory);
    StubConnectionRepository connectionRepository = new StubConnectionRepository();
    MockMvc mockMvc = standaloneSetup(new ConnectController(connectionFactoryLocator, connectionRepository)).build();
    assertEquals(0, connectionRepository.findConnections("oauth2Provider").size());   
    HashMap<String, String> expectedError = new HashMap<String, String>();
    expectedError.put("error", "access_denied");
View Full Code Here

  private InMemoryUsersConnectionRepository usersConnectionRepository;

  @Before
  public void setUp() {
    connectionFactoryRegistry = new ConnectionFactoryRegistry();
    usersConnectionRepository = new InMemoryUsersConnectionRepository(connectionFactoryRegistry);
    connectionRepository = usersConnectionRepository.createConnectionRepository("1");
    facebookConnectionFactory = registerFacebookConnectionFactory();
    twitterConnectionFactory = registerTwitterConnectionFactory();
  }
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.