Package org.mitre.oauth2.model

Examples of org.mitre.oauth2.model.AuthorizationCodeEntity


   * Failure case of blacklisted client uri.
   */
  @Test(expected = IllegalArgumentException.class)
  public void saveNewClient_blacklisted() {

    ClientDetailsEntity client = Mockito.mock(ClientDetailsEntity.class);
    Mockito.when(client.getId()).thenReturn(null);

    String badUri = "badplace.xxx";

    Mockito.when(blacklistedSiteService.isBlacklisted(badUri)).thenReturn(true);
    Mockito.when(client.getRegisteredRedirectUri()).thenReturn(Sets.newHashSet(badUri));

    service.saveNewClient(client);
  }
View Full Code Here


  @Test
  public void saveNewClient_idWasAssigned() {

    // Set up a mock client.
    ClientDetailsEntity client = Mockito.mock(ClientDetailsEntity.class);
    Mockito.when(client.getId()).thenReturn(null);

    service.saveNewClient(client);

    Mockito.verify(client).setClientId(Matchers.anyString());
  }
View Full Code Here

   * Makes sure client has offline access granted scope if allowed refresh tokens.
   */
  @Test
  public void saveNewClient_yesOfflineAccess() {

    ClientDetailsEntity client = Mockito.mock(ClientDetailsEntity.class);
    Mockito.when(client.getId()).thenReturn(null);

    Mockito.when(client.isAllowRefresh()).thenReturn(true);

    // scopes returned by client entities are Strings
    @SuppressWarnings("unchecked")
    Set<String> scopes = Mockito.mock(Set.class);

    Mockito.when(client.getScope()).thenReturn(scopes);

    service.saveNewClient(client);

    Mockito.verify(scopes).add(SystemScopeService.OFFLINE_ACCESS);
  }
View Full Code Here

   * Makes sure client does not have offline access if not allowed to have refresh tokens.
   */
  @Test
  public void saveNewClient_noOfflineAccess() {

    ClientDetailsEntity client = Mockito.mock(ClientDetailsEntity.class);
    Mockito.when(client.getId()).thenReturn(null);

    Mockito.when(client.isAllowRefresh()).thenReturn(false);

    // scopes returned by client entities are Strings
    @SuppressWarnings("unchecked")
    Set<String> scopes = Mockito.mock(Set.class);

    Mockito.when(client.getScope()).thenReturn(scopes);

    service.saveNewClient(client);

    Mockito.verify(scopes).remove(SystemScopeService.OFFLINE_ACCESS);
  }
View Full Code Here

  @Test(expected = InvalidClientException.class)
  public void deleteClient_badId() {

    Long id = 12345L;
    ClientDetailsEntity client = Mockito.mock(ClientDetailsEntity.class);
    Mockito.when(client.getId()).thenReturn(id);
    Mockito.when(clientRepository.getById(id)).thenReturn(null);

    service.deleteClient(client);
  }
View Full Code Here

  public void deleteClient() {

    Long id = 12345L;
    String clientId = "b00g3r";

    ClientDetailsEntity client = Mockito.mock(ClientDetailsEntity.class);
    Mockito.when(client.getId()).thenReturn(id);
    Mockito.when(client.getClientId()).thenReturn(clientId);

    Mockito.when(clientRepository.getById(id)).thenReturn(client);

    WhitelistedSite site = Mockito.mock(WhitelistedSite.class);
    Mockito.when(whitelistedSiteService.getByClientId(clientId)).thenReturn(site);
View Full Code Here

  }

  @Test
  public void updateClient_nullClients() {

    ClientDetailsEntity oldClient = Mockito.mock(ClientDetailsEntity.class);
    ClientDetailsEntity newClient = Mockito.mock(ClientDetailsEntity.class);

    try {
      service.updateClient(oldClient, null);
      fail("New client is null. Expected an IllegalArgumentException.");
    } catch (IllegalArgumentException e) {
View Full Code Here

  }

  @Test(expected = IllegalArgumentException.class)
  public void updateClient_blacklistedUri() {

    ClientDetailsEntity oldClient = Mockito.mock(ClientDetailsEntity.class);
    ClientDetailsEntity newClient = Mockito.mock(ClientDetailsEntity.class);

    String badSite = "badsite.xxx";

    Mockito.when(newClient.getRegisteredRedirectUri()).thenReturn(Sets.newHashSet(badSite));
    Mockito.when(blacklistedSiteService.isBlacklisted(badSite)).thenReturn(true);

    service.updateClient(oldClient, newClient);
  }
View Full Code Here

  }

  @Test
  public void updateClient_yesOfflineAccess() {

    ClientDetailsEntity oldClient = Mockito.mock(ClientDetailsEntity.class);
    ClientDetailsEntity newClient = Mockito.mock(ClientDetailsEntity.class);

    Mockito.when(newClient.isAllowRefresh()).thenReturn(true);

    // scopes returned by client entities are Strings
    @SuppressWarnings("unchecked")
    Set<String> scopes = Mockito.mock(Set.class);

    Mockito.when(newClient.getScope()).thenReturn(scopes);

    service.updateClient(oldClient, newClient);

    Mockito.verify(scopes).add(SystemScopeService.OFFLINE_ACCESS);
  }
View Full Code Here

  }

  @Test
  public void updateClient_noOfflineAccess() {

    ClientDetailsEntity oldClient = Mockito.mock(ClientDetailsEntity.class);
    ClientDetailsEntity newClient = Mockito.mock(ClientDetailsEntity.class);

    Mockito.when(newClient.isAllowRefresh()).thenReturn(false);

    // scopes returned by client entities are Strings
    @SuppressWarnings("unchecked")
    Set<String> scopes = Mockito.mock(Set.class);

    Mockito.when(newClient.getScope()).thenReturn(scopes);

    service.updateClient(oldClient, newClient);

    Mockito.verify(scopes).remove(SystemScopeService.OFFLINE_ACCESS);
  }
View Full Code Here

TOP

Related Classes of org.mitre.oauth2.model.AuthorizationCodeEntity

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.