PendingRequestsServiceTest.java revision 2dd75eff92ef66e22cca286b6f4fe5a9c929af9d
/*
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2015 ForgeRock AS.
*/
public class PendingRequestsServiceTest {
private PendingRequestsService service;
@Mock
@Mock
private UmaAuditLogger auditLogger;
@Mock
private UmaProviderSettings settings;
@Mock
private UmaEmailService emailService;
@Mock
@Mock
private UmaPolicyService policyService;
@Mock
private BaseURLProvider baseUrlProvider;
@SuppressWarnings("unchecked")
public void setup() {
initMocks(this);
}
@Test
public void shouldCreatePendingRequest() throws Exception {
//Given
//When
//Then
ArgumentCaptor<UmaPendingRequest> pendingRequestCaptor = ArgumentCaptor.forClass(UmaPendingRequest.class);
}
@Test
public void shouldSendEmailOnPendingRequestCreation() throws Exception {
//Given
//When
//Then
ArgumentCaptor<UmaPendingRequest> pendingRequestCaptor = ArgumentCaptor.forClass(UmaPendingRequest.class);
}
@Test
public void shouldReadPendingRequest() throws Exception {
//When
//Then
}
@SuppressWarnings("unchecked")
@Test
public void shouldQueryPendingRequestByResourceOwner() throws Exception {
//When
//Then
assertThat(queryFilter.toString()).contains(RESOURCE_OWNER_ID_FIELD + " eq \"" + RESOURCE_OWNER_ID + "\" and "
}
@SuppressWarnings("unchecked")
@Test
public void shouldQueryPendingRequestByResourceOwnerAndRequestingParty() throws Exception {
//When
//Then
+ RESOURCE_OWNER_ID_FIELD + " eq \"" + RESOURCE_OWNER_ID + "\" and " + REALM_FIELD + " eq \"REALM\" and "
}
@Test
public void shouldApprovePendingRequest() throws Exception {
//Given
//When
//Then
}
@Test
public void shouldApprovePendingRequestUsingScopesFromRequestContent() throws Exception {
//Given
//When
//Then
}
@Test
public void shouldApprovePendingRequestUpdatingExistingPolicy() throws Exception {
//Given
//When
//Then
}
@Test
public void shouldSendEmailOnPendingRequestApproval() throws Exception {
//Given
//When
//Then
}
@Test
public void shouldDenyPendingRequest() throws Exception {
//Given
//When
//Then
}
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,
}
given(pendingRequestEmailTemplate.buildScopeString(anySetOf(String.class), eq(resourceOwnerId), eq(realm)))
.willReturn(SCOPE);
}
given(pendingRequestEmailTemplate.buildScopeString(anySetOf(String.class), eq(resourceOwnerId), eq(realm)))
.willReturn(SCOPE);
}
private void mockSuccessfulPolicyCreationForPendingRequest() {
given(policyService.createPolicy(any(ServerContext.class), any(JsonValue.class))).willReturn(createPromise);
}
return policy;
}
}
}