-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
32 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,8 @@ | |
import java.text.ParseException; | ||
import java.time.Clock; | ||
import java.util.Date; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import javax.validation.ConstraintViolationException; | ||
|
||
|
@@ -105,7 +107,7 @@ public void testPagedClientLookup() { | |
|
||
Sort sort = Sort.by(Direction.ASC, "clientId"); | ||
Pageable pageable = PagingUtils.buildPageRequest(10, 1, 100, sort); | ||
|
||
ListResponseDTO<RegisteredClientDTO> clients = managementService.retrieveAllClients(pageable); | ||
|
||
assertThat(clients.getTotalResults(), is(19L)); | ||
|
@@ -249,8 +251,7 @@ public void testBasicClientValidation() { | |
} | ||
|
||
@Test | ||
public void testDynamicallyRegisteredClientCanBeUpdated() | ||
throws ParseException { | ||
public void testDynamicallyRegisteredClientCanBeUpdated() throws ParseException { | ||
|
||
userAuth = Mockito.mock(UsernamePasswordAuthenticationToken.class); | ||
when(userAuth.getName()).thenReturn("test"); | ||
|
@@ -261,7 +262,7 @@ public void testDynamicallyRegisteredClientCanBeUpdated() | |
request.setGrantTypes(Sets.newHashSet(AuthorizationGrantType.CLIENT_CREDENTIALS)); | ||
RegisteredClientDTO response = registrationService.registerClient(request, userAuth); | ||
|
||
|
||
String clientId = response.getClientId(); | ||
ClientDetailsEntity entity = clientService.findClientByClientId(clientId).orElseThrow(); | ||
assertThat(entity.isDynamicallyRegistered(), is(true)); | ||
|
@@ -296,8 +297,7 @@ public void testSecretRotation() throws ParseException { | |
RegisteredClientDTO updatedClient = | ||
managementService.retrieveClientByClientId(client.getClientId()).orElseThrow(); | ||
|
||
assertThat(updatedClient.getClientSecret(), | ||
not(equalTo(savedClient.getClientSecret()))); | ||
assertThat(updatedClient.getClientSecret(), not(equalTo(savedClient.getClientSecret()))); | ||
} | ||
|
||
@Test | ||
|
@@ -333,9 +333,8 @@ public void testClientOwnerAssignRemove() throws ParseException { | |
RegisteredClientDTO savedClient = managementService.saveNewClient(client); | ||
assertThat(savedClient.getClientId(), is(client.getClientId())); | ||
assertThat(savedClient.getClientSecret(), notNullValue()); | ||
|
||
ListResponseDTO<ScimUser> owners = | ||
managementService.getClientOwners(savedClient.getClientId(), | ||
|
||
ListResponseDTO<ScimUser> owners = managementService.getClientOwners(savedClient.getClientId(), | ||
PagingUtils.buildUnpagedPageRequest()); | ||
|
||
assertThat(owners.getTotalResults(), is(0L)); | ||
|
@@ -417,4 +416,28 @@ public void testClientStatusChange() { | |
assertTrue(client.getStatusChangedOn().equals(Date.from(clock.instant()))); | ||
assertEquals("userUUID", client.getStatusChangedBy()); | ||
} | ||
|
||
@Test | ||
public void testClientStatusChangeWithContacts() throws ParseException { | ||
managementService.updateClientStatus("client", false, "userUUID"); | ||
RegisteredClientDTO client = managementService.retrieveClientByClientId("client").get(); | ||
Set<String> contacts = new HashSet<String>(); | ||
contacts.add("[email protected]"); | ||
client.setContacts(contacts); | ||
managementService.updateClient(client.getClientId(), client); | ||
|
||
assertFalse(client.isActive()); | ||
assertTrue(client.getStatusChangedOn().equals(Date.from(clock.instant()))); | ||
assertEquals("userUUID", client.getStatusChangedBy()); | ||
} | ||
|
||
@Test | ||
public void testClientStatusChangeWithoutOwners() { | ||
managementService.updateClientStatus("client-cred", false, "userUUID"); | ||
RegisteredClientDTO client = managementService.retrieveClientByClientId("client-cred").get(); | ||
|
||
assertFalse(client.isActive()); | ||
assertTrue(client.getStatusChangedOn().equals(Date.from(clock.instant()))); | ||
assertEquals("userUUID", client.getStatusChangedBy()); | ||
} | ||
} |