use of org.forgerock.openam.sm.datalayer.impl.uma.UmaPendingRequest in project OpenAM by OpenRock.
the class AuthorizationRequestEndpointTest method createPendingRequest.
private UmaPendingRequest createPendingRequest(String... scopes) {
UmaPendingRequest pendingRequest = mock(UmaPendingRequest.class);
given(pendingRequest.getScopes()).willReturn(new HashSet<>(Arrays.asList(scopes)));
return pendingRequest;
}
use of org.forgerock.openam.sm.datalayer.impl.uma.UmaPendingRequest in project OpenAM by OpenRock.
the class PendingRequestsServiceTest method shouldCreatePendingRequest.
@Test
public void shouldCreatePendingRequest() throws Exception {
//Given
HttpServletRequest httpRequest = mock(HttpServletRequest.class);
//When
service.createPendingRequest(httpRequest, RESOURCE_SET_ID, RESOURCE_SET_NAME, RESOURCE_OWNER_ID, REQUESTING_PARTY_ID, REALM, Collections.singleton(SCOPE));
//Then
ArgumentCaptor<UmaPendingRequest> pendingRequestCaptor = ArgumentCaptor.forClass(UmaPendingRequest.class);
verify(store).create(pendingRequestCaptor.capture());
UmaPendingRequest pendingRequest = pendingRequestCaptor.getValue();
assertThat(pendingRequest.getResourceSetId()).isEqualTo(RESOURCE_SET_ID);
assertThat(pendingRequest.getResourceSetName()).isEqualTo(RESOURCE_SET_NAME);
assertThat(pendingRequest.getResourceOwnerId()).isEqualTo(RESOURCE_OWNER_ID);
assertThat(pendingRequest.getRequestingPartyId()).isEqualTo(REQUESTING_PARTY_ID);
assertThat(pendingRequest.getRealm()).isEqualTo(REALM);
assertThat(pendingRequest.getScopes()).containsExactly(SCOPE);
assertThat(pendingRequest.getRequestedAt()).isNotNull();
}
use of org.forgerock.openam.sm.datalayer.impl.uma.UmaPendingRequest in project OpenAM by OpenRock.
the class PendingRequestsServiceTest method createPendingRequest.
private void createPendingRequest(String id, String resourceSetId, String resourceSetName, String resourceOwnerId, String realm, String requestingPartyId, Set<String> scopes) throws NotFoundException, ServerException {
UmaPendingRequest pendingRequest = new UmaPendingRequest(resourceSetId, resourceSetName, resourceOwnerId, realm, requestingPartyId, scopes);
pendingRequest.setId(id);
given(store.read(id)).willReturn(pendingRequest);
}
use of org.forgerock.openam.sm.datalayer.impl.uma.UmaPendingRequest in project OpenAM by OpenRock.
the class PendingRequestsServiceTest method shouldSendEmailOnPendingRequestCreation.
@Test
public void shouldSendEmailOnPendingRequestCreation() throws Exception {
//Given
HttpServletRequest httpRequest = mock(HttpServletRequest.class);
given(settings.isEmailResourceOwnerOnPendingRequestCreationEnabled()).willReturn(true);
mockPendingRequestCreationEmailTemplate(RESOURCE_OWNER_ID, REALM);
//When
service.createPendingRequest(httpRequest, RESOURCE_SET_ID, RESOURCE_SET_NAME, RESOURCE_OWNER_ID, REQUESTING_PARTY_ID, REALM, Collections.singleton(SCOPE));
//Then
verify(emailService).email(REALM, RESOURCE_OWNER_ID, "CREATION_SUBJECT", "CREATION_BODY " + REQUESTING_PARTY_ID + " " + RESOURCE_SET_NAME + " " + SCOPE);
ArgumentCaptor<UmaPendingRequest> pendingRequestCaptor = ArgumentCaptor.forClass(UmaPendingRequest.class);
verify(store).create(pendingRequestCaptor.capture());
}
use of org.forgerock.openam.sm.datalayer.impl.uma.UmaPendingRequest in project OpenAM by OpenRock.
the class PendingRequestResourceTest method mockPendingRequestsForUser.
private void mockPendingRequestsForUser(String username, String realm, int numberOfPendingRequests) throws ResourceException {
given(contextHelper.getUserId(any(Context.class))).willReturn(username);
Set<UmaPendingRequest> pendingRequests = new HashSet<>();
for (int i = 0; i < numberOfPendingRequests; i++) {
UmaPendingRequest pendingRequest = new UmaPendingRequest();
pendingRequest.setId("ID" + i);
pendingRequests.add(pendingRequest);
}
given(service.queryPendingRequests(username, realm)).willReturn(pendingRequests);
}
Aggregations