@Before public void setUp() throws Exception { OAuth2ClientTest.client1 = MockUtils.getClient_Code_Confidential(); OAuth2ClientTest.client2 = MockUtils.getClient_Code_Public(); }
@Before public void setUp() throws Exception { OAuth2ClientTest.client1 = MockUtils.getClient_Code_Confidential(); OAuth2ClientTest.client2 = MockUtils.getClient_Code_Public(); }
@Test public void testStoreClients_1() throws Exception { this.cache.clearClients(); final Collection<OAuth2Client> clients = new HashSet<OAuth2Client>(); clients.add(MockUtils.getClient_Code_Confidential()); clients.add(MockUtils.getClient_Code_Public()); this.cache.storeClients(clients); Assert.assertNotNull(this.cache.getClient(MockUtils.GADGET_URI1, MockUtils.SERVICE_NAME)); Assert.assertNotNull(this.cache.getClient(MockUtils.GADGET_URI2, MockUtils.SERVICE_NAME)); }
@Test public void testStoreClients_1() throws Exception { this.cache.clearClients(); final Collection<OAuth2Client> clients = new HashSet<OAuth2Client>(); clients.add(MockUtils.getClient_Code_Confidential()); clients.add(MockUtils.getClient_Code_Public()); this.cache.storeClients(clients); Assert.assertNotNull(this.cache.getClient(MockUtils.GADGET_URI1, MockUtils.SERVICE_NAME)); Assert.assertNotNull(this.cache.getClient(MockUtils.GADGET_URI2, MockUtils.SERVICE_NAME)); }
@Before public void setUp() throws Exception { this.cache = new InMemoryCache(); Assert.assertNotNull(this.cache); Assert.assertTrue(OAuth2Cache.class.isInstance(this.cache)); this.cache.storeClient(MockUtils.getClient_Code_Confidential()); this.cache.storeClient(MockUtils.getClient_Code_Public()); this.cache.storeToken(MockUtils.getAccessToken()); this.cache.storeToken(MockUtils.getRefreshToken()); this.cache.storeOAuth2Accessor(MockUtils.getOAuth2Accessor_Code()); this.cache.storeOAuth2Accessor(MockUtils.getOAuth2Accessor_Error()); }
@Test public void testSetTokenForSharedClient() throws Exception { final OAuth2Cache cache = new InMemoryCache(); final OAuth2Persister persister = MockUtils.getDummyPersister(); final OAuth2Encrypter encrypter = MockUtils.getDummyEncrypter(); final BlobCrypter stateCrypter = MockUtils.getDummyStateCrypter(); OAuth2Token token = MockUtils.getAccessToken(); OAuth2Client client = MockUtils.getClient_Code_Confidential(); client.setSharedToken( true ); BasicOAuth2Store mockStore = createMockBuilder( BasicOAuth2Store.class ) .withConstructor( OAuth2Cache.class, OAuth2Persister.class, OAuth2Encrypter.class, String.class, Authority.class, String.class, BlobCrypter.class ) .withArgs( cache, persister, encrypter, MockUtils.REDIRECT_URI, (Authority)null, (String)null, stateCrypter ) .addMockedMethod( "getClient" ) .addMockedMethod( "getToken" ) .createMock(); expect( mockStore.getClient( eq(MockUtils.GADGET_URI1), eq(MockUtils.SERVICE_NAME) ) ).andReturn( client ); expect( mockStore.getToken( eq(token.getGadgetUri()), eq(token.getServiceName()), eq(token.getUser()), eq(token.getScope()), eq(token.getType() ) )).andReturn( token ); replay( mockStore ); mockStore.setToken( token ); verify( mockStore ); } }
@Test public void testSetTokenForSharedClient() throws Exception { final OAuth2Cache cache = new InMemoryCache(); final OAuth2Persister persister = MockUtils.getDummyPersister(); final OAuth2Encrypter encrypter = MockUtils.getDummyEncrypter(); final BlobCrypter stateCrypter = MockUtils.getDummyStateCrypter(); OAuth2Token token = MockUtils.getAccessToken(); OAuth2Client client = MockUtils.getClient_Code_Confidential(); client.setSharedToken( true ); BasicOAuth2Store mockStore = createMockBuilder( BasicOAuth2Store.class ) .withConstructor( OAuth2Cache.class, OAuth2Persister.class, OAuth2Encrypter.class, String.class, Authority.class, String.class, BlobCrypter.class ) .withArgs( cache, persister, encrypter, MockUtils.REDIRECT_URI, (Authority)null, (String)null, stateCrypter ) .addMockedMethod( "getClient" ) .addMockedMethod( "getToken" ) .createMock(); expect( mockStore.getClient( eq(MockUtils.GADGET_URI1), eq(MockUtils.SERVICE_NAME) ) ).andReturn( client ); expect( mockStore.getToken( eq(token.getGadgetUri()), eq(token.getServiceName()), eq(token.getUser()), eq(token.getScope()), eq(token.getType() ) )).andReturn( token ); replay( mockStore ); mockStore.setToken( token ); verify( mockStore ); } }
@Before public void setUp() throws Exception { this.cache = new InMemoryCache(); Assert.assertNotNull(this.cache); Assert.assertTrue(OAuth2Cache.class.isInstance(this.cache)); this.cache.storeClient(MockUtils.getClient_Code_Confidential()); this.cache.storeClient(MockUtils.getClient_Code_Public()); this.cache.storeToken(MockUtils.getAccessToken()); this.cache.storeToken(MockUtils.getRefreshToken()); this.cache.storeOAuth2Accessor(MockUtils.getOAuth2Accessor_Code()); this.cache.storeOAuth2Accessor(MockUtils.getOAuth2Accessor_Error()); }