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

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


  @Test
  public void connectionStatus() throws Exception {
    ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry();
    ConnectionFactory<TestApi1> connectionFactory1 = new StubOAuth1ConnectionFactory("clientId", "clientSecret", THROW_EXCEPTION);
    connectionFactoryLocator.addConnectionFactory(connectionFactory1);       
    ConnectionFactory<TestApi2> connectionFactory2 = new StubOAuth2ConnectionFactory("clientId", "clientSecret", THROW_EXCEPTION);
    connectionFactoryLocator.addConnectionFactory(connectionFactory2);       
    StubConnectionRepository connectionRepository = new StubConnectionRepository();
    connectionRepository.addConnection(connectionFactory1.createConnection(new ConnectionData("oauth1Provider", "provider1User1", null, null, null, null, null, null, null)));
    MockMvc mockMvc = standaloneSetup(new ConnectController(connectionFactoryLocator, connectionRepository)).build();
   
View Full Code Here


  }

  @Test
  public void connectionStatus_withErrorsInFlashScope() throws Exception {
    ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry();
    ConnectionFactory<TestApi2> connectionFactory2 = new StubOAuth2ConnectionFactory("clientId", "clientSecret", THROW_EXCEPTION);
    connectionFactoryLocator.addConnectionFactory(connectionFactory2);       
    StubConnectionRepository connectionRepository = new StubConnectionRepository();
    MockMvc mockMvc = standaloneSetup(new ConnectController(connectionFactoryLocator, connectionRepository)).build();
   
    // Should convert errors in "flash" scope to model attributes and remove them from "flash"
View Full Code Here

}

  @Test
  public void removeConnections() throws Exception {
    ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry();
    ConnectionFactory<TestApi2> connectionFactory = new StubOAuth2ConnectionFactory("clientId", "clientSecret", THROW_EXCEPTION);
    connectionFactoryLocator.addConnectionFactory(connectionFactory);       
    StubConnectionRepository connectionRepository = new StubConnectionRepository();
    connectionRepository.addConnection(connectionFactory.createConnection(new ConnectionData("provider1", "provider1User1", null, null, null, null, null, null, null)));
    connectionRepository.addConnection(connectionFactory.createConnection(new ConnectionData("provider1", "provider1User2", null, null, null, null, null, null, null)));
    connectionRepository.addConnection(connectionFactory.createConnection(new ConnectionData("oauth2Provider", "provider2User1", null, null, null, null, null, null, null)));
    connectionRepository.addConnection(connectionFactory.createConnection(new ConnectionData("oauth2Provider", "provider2User2", null, null, null, null, null, null, null)));
    assertEquals(2, connectionRepository.findConnections("provider1").size());   
    assertEquals(2, connectionRepository.findConnections("oauth2Provider").size());       
    ConnectController connectController = new ConnectController(connectionFactoryLocator, connectionRepository);
    List<DisconnectInterceptor<?>> interceptors = getDisconnectInterceptor();
    connectController.setDisconnectInterceptors(interceptors);
View Full Code Here

  }

  @Test
  public void removeConnection() throws Exception {
    ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry();
    ConnectionFactory<TestApi2> connectionFactory = new StubOAuth2ConnectionFactory("clientId", "clientSecret", THROW_EXCEPTION);
    connectionFactoryLocator.addConnectionFactory(connectionFactory);       
    StubConnectionRepository connectionRepository = new StubConnectionRepository();
    connectionRepository.addConnection(connectionFactory.createConnection(new ConnectionData("oauth2Provider", "provider1User1", null, null, null, null, null, null, null)));
    connectionRepository.addConnection(connectionFactory.createConnection(new ConnectionData("oauth2Provider", "provider1User2", null, null, null, null, null, null, null)));
    assertEquals(2, connectionRepository.findConnections("oauth2Provider").size());   
    ConnectController connectController = new ConnectController(connectionFactoryLocator, connectionRepository);
    List<DisconnectInterceptor<?>> interceptors = getDisconnectInterceptor();
    connectController.setDisconnectInterceptors(interceptors);
    MockMvc mockMvc = standaloneSetup(connectController).build();
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();
View Full Code Here

  }

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

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

  }

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

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

  }

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

TOP

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

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.