use of com.sun.identity.entitlement.xacml3.core.PolicySet in project OpenAM by OpenRock.
the class XacmlServiceTest method testDispositionOfRootRealmExport.
@Test
public void testDispositionOfRootRealmExport() throws Exception {
//given
query.add(XacmlService.QUERY_PARAM_STRING, "test1");
query.add(XacmlService.QUERY_PARAM_STRING, "test2");
PolicySet policySet = new PolicySet();
doReturn(policySet).when(importExport).exportXACML(eq("/"), any(Subject.class), any(List.class));
//when
Representation result = service.exportXACML("/");
Disposition disposition = result.getDisposition();
assertThat(disposition.getFilename()).isEqualTo("realm-policies.xml");
assertThat(disposition.getType()).isEqualTo(disposition.TYPE_ATTACHMENT);
}
use of com.sun.identity.entitlement.xacml3.core.PolicySet in project OpenAM by OpenRock.
the class XacmlServiceTest method testDispositionOfSubRealmExport.
@Test
public void testDispositionOfSubRealmExport() throws Exception {
//given
query.add(XacmlService.QUERY_PARAM_STRING, "test1");
query.add(XacmlService.QUERY_PARAM_STRING, "test2");
PolicySet policySet = new PolicySet();
doReturn(policySet).when(importExport).exportXACML(eq("/"), any(Subject.class), any(List.class));
//when
Representation result = service.exportXACML("/sub");
Disposition disposition = result.getDisposition();
assertThat(disposition.getFilename()).isEqualTo("sub-realm-policies.xml");
assertThat(disposition.getType()).isEqualTo(disposition.TYPE_ATTACHMENT);
}
use of com.sun.identity.entitlement.xacml3.core.PolicySet in project OpenAM by OpenRock.
the class XacmlServiceTest method testExportXACML.
@Test
public void testExportXACML() throws Exception {
//given
query.add(XacmlService.QUERY_PARAM_STRING, "test1");
query.add(XacmlService.QUERY_PARAM_STRING, "test2");
PolicySet policySet = new PolicySet();
doReturn(policySet).when(importExport).exportXACML(eq("/"), any(Subject.class), any(List.class));
//when
Representation result = service.exportXACML();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
result.write(baos);
String xml = new String(baos.toByteArray(), "UTF-8");
//then
assertThat(xml).contains("<ns2:PolicySet");
assertThat(xml).contains("xmlns:ns2=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\"");
verify(response).setStatus(Status.SUCCESS_OK);
ArgumentCaptor<List> listCaptor = ArgumentCaptor.forClass(List.class);
verify(importExport).exportXACML(eq("/"), any(Subject.class), listCaptor.capture());
assertThat(listCaptor.getValue()).containsExactly("test1", "test2");
}
Aggregations