XACMLPrivilegeUtilsTest.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 Nomura Research Institute, Ltd.
*
* Portions Copyrighted 2014-2016 ForgeRock AS.
*/
/**
* Unit tests for {@link XACMLPrivilegeUtils}. These are limited scope to only cover the functionality used
* within com.sun.identity.cli.entitlement.ListXACML#handleRequest(com.sun.identity.cli.RequestContext) and
* com.sun.identity.cli.entitlement.CreateXACML#handleRequest(com.sun.identity.cli.RequestContext). They will
* indicate when changes to the code directly used by these methods has broken the existing functionality.
*
* Note that the custom JSON-in-XACML is not catered for here.
*
* @since 12.0.0
*/
public class XACMLPrivilegeUtilsTest {
@Test
public void shouldReturnEmptyListWhenNull() {
// When...
// Then...
}
@Test
public void shouldResultInEquivalentPrivilegesWhenValidPrivilegeSetSerializedToXACMLThenDeserialized()
throws EntitlementException {
//Given
//When
}
//Then
}
@Test
public void shouldResultInEquivalentReferralPrivilegeWhenValidReferralPrivilegeSerializedToXACMLThenDeserialized()
throws JSONException, EntitlementException {
//Given
//When
//Then
}
@Test
public void shouldReturnXACMLPolicySetWhenGivenValidPrivilegeSet() throws EntitlementException {
//Given
//When
//Then
}
@Test
public void shouldReturnNullWhenGivenNullAsPrivilegeSet() {
//Given
//When
//Then
}
@Test
public void shouldReturnXACMLPolicyWhenGivenValidReferralPrivilegeSet() throws JSONException, EntitlementException {
//Given
//When
//Then
}
@Test
public void shouldReturnNullWhenGivenNullAsReferralPrivilege() throws JSONException {
//Given
//When
//Then
}
@Test
public void shouldAddPolicyToPolicySet() throws JAXBException {
//Given
//When
//Then
}
@Test
public void shouldNotAddNullToPolicySetAndSoShouldLeavePolicySetUnchanged() throws JAXBException {
//Given
//When
//Then
assertEquals(policySet.getPolicySetOrPolicyOrPolicySetIdReference().size(), 0, "Expected PolicySet to remain " +
"empty as a result of not adding null to the empty PolicySet.");
}
@Test
public void shouldIndicateReferralPolicyWhenGivenReferralPrivilege() throws EntitlementException, JSONException {
//Given
//When
//Then
}
@Test
public void shouldIndicateNotAReferralPolicyWhenGivenPolicy() throws EntitlementException {
//Given
//When
//Then
}
private void assertPolicySetContentsMatchPrivilegesContent(PolicySet policySet, Set<Privilege> privileges) {
}
assertEquals(policies.size(), privileges.size(), "Mismatch between number of Policy elements in PolicySet, " +
"and number of original Privileges.");
}
}
assertTrue(policyIdList.containsAll(privilegeIdList), "Not all Privilege names were included in the " +
"PolicySet.");
assertTrue(privilegeIdList.containsAll(policyIdList), "Extra names were added to the PolicySet which were " +
"not in the list of Privilege names.");
}
assertTrue(descriptionList.contains(description), "Privilege with description '" + description + "' not " +
"found in PolicySet.");
}
assertEquals(policy.getVersion().getValue(), privilegesVersion, "Policy found with version not matching " +
"Privilege creation date.");
}
}
if (referralPrivilege != null) {
}
"ReferralPrivilege name.");
assertEquals(policy.getDescription(), referralPrivilege.getDescription(), "Expected Policy description to " +
"match ReferralPrivilege description.");
String referralPrivilegeCreationDate = formatMillisecondsAsTimestamp(referralPrivilege.getCreationDate());
assertEquals(policy.getVersion().getValue(), referralPrivilegeCreationDate, "Expected Policy creation date " +
"to match ReferralPrivilege creation date.");
}
assertSame(policies.get(0), policy, "Policy that was added to PolicySet does not match the original Policy " +
"to be added.");
}
@Test
public void testUndesirablePrivilegeNames() {
}
}