XACMLExportImportTest.java revision cb7ae3378eb7595a9f486c189a192af8390b1d5d
/*
* 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-2016 ForgeRock AS.
*/
public class XACMLExportImportTest {
private SearchFilterFactory searchFilterFactory;
private PrivilegeValidator validator;
private PrivilegeManager pm;
private XACMLReaderWriter xacmlReaderWriter;
private PrivilegeManagerFactory pmFactory;
private ApplicationService applicationService;
private ResourceTypeService resourceTypeService;
private XACMLExportImport xacmlExportImport;
public void setUp() throws EntitlementException {
// Constructor Dependencies
searchFilterFactory = new SearchFilterFactory();
when(applicationServiceFactory.create(any(Subject.class), anyString())).thenReturn(applicationService);
.setName("TestResourceType")
.setUUID("123")
// Class under test
xacmlExportImport = new XACMLExportImport(pmFactory, xacmlReaderWriter, validator, searchFilterFactory, debug,
// Given (shared test state)
given(applicationServiceFactory.create(any(Subject.class), anyString())).willReturn(applicationService);
given(urlResourceName.compare(anyString(), anyString(), anyBoolean())).willReturn(ResourceMatch.EXACT_MATCH);
given(resourceTypeService.getResourceType(any(Subject.class), anyString(), anyString())).willReturn(resourceType);
}
@Test
public void canImportPrivilegesIntoRealm() throws Exception {
// Given
// shared test state
// When
List<ImportStep> importSteps = xacmlExportImport.importXacml(ROOT_REALM, NULL_INPUT, NULL_SUBJECT, false);
// Then
}
@Test
public void canPerformAnImportDryRun() throws Exception {
// Given
// shared test state
// When
List<ImportStep> importSteps = xacmlExportImport.importXacml(ROOT_REALM, NULL_INPUT, NULL_SUBJECT, true);
// Then
}
public void throwsAnExceptionIfPrivilegeValidationFails() throws EntitlementException {
// Given
// shared test state
// When
// Then
fail("Expected validation exception");
}
}
return privilege;
}
} else {
}
return privilege;
}
}
return privilege;
}
}
return privilege;
}
public static void assertImportStep(ImportStep importStep, DiffStatus diffStatus, IPrivilege privilege) {
assertThat(((PersistableImportStep<Privilege>)importStep).get()).isEqualTo(privilege).as("privilege");
}
}