@Test
public void testIsAllowedDeletePendingMembership() {

    final String domainName = "test-domain";
    TopLevelDomain dom1 = createTopLevelDomainObject(domainName,
            "Role Test Domain1", "testOrg", "user.user1");
    zms.postTopLevelDomain(mockDomRsrcCtx, auditRef, dom1);
    Role role1 = createRoleObject(domainName, "testrole1", null, "user.user1", "user.jane");
    zms.putRole(mockDomRsrcCtx, domainName, "testrole1", auditRef, role1);
    Policy policy1 = createPolicyObject(domainName, "Policy1", "testrole1",
            "UPDATE", domainName + ":role.*", AssertionEffect.ALLOW);
    zms.putPolicy(mockDomRsrcCtx, domainName, "Policy1", auditRef, policy1);
    assertTrue(zms.isAllowedDeletePendingMembership(mockDomRsrcCtx.principal(), domainName,
            "testrole1", "user.pending"));
    Authority principalAuthority = new com.yahoo.athenz.common.server.debug.DebugPrincipalAuthority();
    String unsignedCreds = "v=U1;d=user;n=jane";
    Principal rsrcPrince = SimplePrincipal.create("user", "jane", unsignedCreds + ";s=signature",0, principalAuthority);
    assertNotNull(rsrcPrince);
    ((SimplePrincipal) rsrcPrince).setUnsignedCreds(unsignedCreds);
    assertTrue(zms.isAllowedDeletePendingMembership(rsrcPrince, domainName,
            "testrole1", "user.pending"));
    unsignedCreds = "v=U1;d=user;n=john";
    rsrcPrince = SimplePrincipal.create("user", "john", unsignedCreds + ";s=signature",0, principalAuthority);
    assertNotNull(rsrcPrince);
    ((SimplePrincipal) rsrcPrince).setUnsignedCreds(unsignedCreds);
    // this time false since john is not authorized
    assertFalse(zms.isAllowedDeletePendingMembership(rsrcPrince, domainName,
            "testrole1", "user.pending"));
    zms.deleteTopLevelDomain(mockDomRsrcCtx, domainName, auditRef);
}