| | |
| | | |
| | | import org.opends.server.protocols.asn1.ASN1Boolean; |
| | | import org.opends.server.protocols.asn1.ASN1OctetString; |
| | | import org.opends.server.protocols.ldap.LDAPException; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | |
| | | assertEquals(val.toString(), expected); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * Test If we have only the required values |
| | | */ |
| | |
| | | assertTrue(exceptedValues.containsKey(val.intValue())); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Test invalid int values |
| | | */ |
| | |
| | | { |
| | | PasswordPolicyWarningType val = PasswordPolicyWarningType.valueOf(i); |
| | | String expected = expectedValues.get(i); |
| | | |
| | | |
| | | assertEquals(val.toString(), expected); |
| | | assertEquals(i, val.getType()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * Test If we have only the required values |
| | | */ |
| | |
| | | assertTrue(exceptedValues.containsValue(val.toString())); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Test invalid int values |
| | | */ |
| | |
| | | PasswordPolicyWarningType val = PasswordPolicyWarningType.valueOf(b); |
| | | assertNull(val); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Create values for PasswordControl |
| | | */ |
| | |
| | | { OID_NS_PASSWORD_EXPIRING, false, 2}, |
| | | }; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Test OID |
| | | */ |
| | |
| | | { |
| | | assertEquals(OID_NS_PASSWORD_EXPIRED, "2.16.840.1.113730.3.4.4"); |
| | | assertEquals(OID_NS_PASSWORD_EXPIRING, "2.16.840.1.113730.3.4.5"); |
| | | //assertEquals(OID_PASSWORD_POLICY_CONTROL, ""); |
| | | //assertEquals(OID_PASSWORD_POLICY_CONTROL, ""); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Test "Netscape password expired control" implementation |
| | | */ |
| | |
| | | assertNotNull(pec); |
| | | assertEquals(pec.isCritical(),isCritical); |
| | | assertEquals(pec.getOID(),oid); |
| | | |
| | | |
| | | control.setValue(new ASN1Boolean(true).decodeAsOctetString()); |
| | | try |
| | | { |
| | |
| | | } |
| | | |
| | | // Check toString |
| | | assertEquals("PasswordExpiredControl()", pec.toString()); |
| | | assertEquals("PasswordExpiredControl()", pec.toString()); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Test "Netscape password expired control" implementation |
| | | */ |
| | |
| | | assertTrue(true, |
| | | "shouldn't be allow to create PasswordExpiringControl without value"); |
| | | } |
| | | |
| | | |
| | | control.setValue(new ASN1OctetString("invalid value")); |
| | | try |
| | | { |
| | |
| | | assertEquals(newPec.getOID(), oid); |
| | | assertEquals(newPec.getSecondsUntilExpiration(), sec); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Test PasswordPolicyRequestControl |
| | | */ |
| | |
| | | assertNotNull(pec); |
| | | assertEquals(pec.isCritical(),isCritical); |
| | | assertEquals(pec.getOID(),oid); |
| | | |
| | | |
| | | control.setValue(new ASN1Boolean(true).decodeAsOctetString()); |
| | | try |
| | | { |
| | |
| | | } |
| | | |
| | | // Check toString |
| | | assertEquals("PasswordPolicyRequestControl()", pec.toString()); |
| | | assertEquals("PasswordPolicyRequestControl()", pec.toString()); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * Create values for PasswordControl |
| | | */ |
| | |
| | | { OID_NS_PASSWORD_EXPIRING, false, 2} |
| | | }; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Test PasswordPolicyResponseControl |
| | | */ |
| | |
| | | assertEquals(pprc.getOID(), OID_PASSWORD_POLICY_CONTROL); |
| | | assertNull(pprc.getWarningType()); |
| | | assertNull(pprc.getErrorType()); |
| | | |
| | | |
| | | |
| | | |
| | | // check constructor PasswordPolicyResponseControl |
| | | // (PasswordPolicyWarningType warningType, |
| | | // int warningValue, |
| | |
| | | assertEquals(pprc.getWarningValue(),warningValue); |
| | | } |
| | | } |
| | | |
| | | |
| | | // check constructor PasswordPolicyResponseControl |
| | | // (PString oid, boolean isCritical, |
| | | // PasswordPolicyWarningType warningType, |
| | |
| | | assertEquals(pprc.getWarningValue(), warningValue); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | // check decode |
| | | Control control ; |
| | | for (PasswordPolicyErrorType errorType : PasswordPolicyErrorType.values()) |
| | |
| | | assertEquals(warningType, pprc.getWarningType()); |
| | | assertEquals(errorType, pprc.getErrorType()); |
| | | assertEquals(pprc.getWarningValue(), warningValue); |
| | | |
| | | |
| | | // check to String |
| | | String toString = |
| | | String toString = |
| | | "PasswordPolicyResponseControl(" + |
| | | warningType.toString() + |
| | | "=" + |
| | |
| | | errorType.toString() + |
| | | ")" ; |
| | | assertEquals(toString, pprc.toString()) ; |
| | | |
| | | |
| | | |
| | | |
| | | // check null value for the control |
| | | try |
| | | { |
| | |
| | | // normal case |
| | | assertTrue(true,"the control should have a value"); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | // check null warning type |
| | | control = new PasswordPolicyResponseControl(oid, isCritical, |
| | | null, warningValue, errorType); |
| | |
| | | { |
| | | assertTrue(false,"We should be able to decode the control"); |
| | | } |
| | | |
| | | |
| | | // check null error type |
| | | control = new PasswordPolicyResponseControl(oid, isCritical, |
| | | warningType, warningValue, null); |