PrivilegeAuthzModuleTest.java revision 16682c615640da7d54591f86528a5eb562e0ab97
/*
* 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 2014-2015 ForgeRock AS.
*/
/**
* Unit test for {@link org.forgerock.openam.rest.authz.PrivilegeAuthzModule}.
*
* @since 12.0.0
*/
public class PrivilegeAuthzModuleTest {
return "ou=abc";
}
};
@Mock
private DelegationPermissionFactory factory;
@Mock
private DelegationEvaluator evaluator;
@Mock
private SubjectContext subjectContext;
@Mock
@Mock
private CollectionResourceProvider provider;
private CrestAuthorizationModule module;
public void setUp() {
MockitoAnnotations.initMocks(this);
definitions.put("evaluate", PrivilegeDefinition.getInstance("evaluate", PrivilegeDefinition.Action.READ));
definitions.put("blowup", PrivilegeDefinition.getInstance("destroy", PrivilegeDefinition.Action.MODIFY));
}
@Test
// Given...
given(provider.readInstance(isA(Context.class), eq("123"), isA(ReadRequest.class))).willReturn(promise);
// When...
// Then...
}
@Test
// Given...
Promise<QueryResponse, ResourceException> promise = Promises.newResultPromise(Responses.newQueryResponse("abc-def"));
given(provider.queryCollection(isA(Context.class), isA(QueryRequest.class), isA(QueryResourceHandler.class)))
// When...
// Then...
}
@Test
// Given...
// When...
// Then...
}
@Test
// Given...
given(provider.updateInstance(isA(Context.class), eq("123"), isA(UpdateRequest.class))).willReturn(promise);
// When...
final UpdateRequest request = Requests.newUpdateRequest("/policies/123", JsonValue.json(new Object()));
// Then...
}
@Test
// Given...
given(provider.deleteInstance(isA(Context.class), eq("123"), isA(DeleteRequest.class))).willReturn(promise);
// When...
// Then...
}
@Test
// Given...
given(provider.patchInstance(isA(Context.class), eq("123"), isA(PatchRequest.class))).willReturn(promise);
// When...
final PatchRequest request = Requests.newPatchRequest("/policies/123", PatchOperation.add("abc", "123"));
// Then...
}
@Test
// Given...
// When...
// Then...
}
@Test
// Given...
// When...
// Then...
}
@Test
// When...
// Then...
}
@Test
// Given...
// When...
// Then...
}
}