| | |
| | | public void testConstructorEmptyAuthzID() |
| | | { |
| | | ProxiedAuthV2Control proxyControl = |
| | | new ProxiedAuthV2Control(ByteString.valueOf("")); |
| | | assertEquals(proxyControl.getAuthorizationID(), ByteString.valueOf("")); |
| | | new ProxiedAuthV2Control(ByteString.valueOfUtf8("")); |
| | | assertEquals(proxyControl.getAuthorizationID(), ByteString.valueOfUtf8("")); |
| | | } |
| | | |
| | | |
| | |
| | | public void testConstructorNonEmptyAuthzIDDN() |
| | | { |
| | | ProxiedAuthV2Control proxyControl = |
| | | new ProxiedAuthV2Control(ByteString.valueOf("dn:uid=test,o=test")); |
| | | new ProxiedAuthV2Control(ByteString.valueOfUtf8("dn:uid=test,o=test")); |
| | | assertEquals(proxyControl.getAuthorizationID(), |
| | | ByteString.valueOf("dn:uid=test,o=test")); |
| | | ByteString.valueOfUtf8("dn:uid=test,o=test")); |
| | | } |
| | | |
| | | |
| | |
| | | public void testConstructorNonEmptyAuthzIDUsername() |
| | | { |
| | | ProxiedAuthV2Control proxyControl = |
| | | new ProxiedAuthV2Control(ByteString.valueOf("u:test")); |
| | | new ProxiedAuthV2Control(ByteString.valueOfUtf8("u:test")); |
| | | assertEquals(proxyControl.getAuthorizationID(), |
| | | ByteString.valueOf("u:test")); |
| | | ByteString.valueOfUtf8("u:test")); |
| | | } |
| | | |
| | | |
| | |
| | | throws Exception |
| | | { |
| | | LDAPControl c = new LDAPControl(OID_PROXIED_AUTH_V2, false, |
| | | ByteString.valueOf("u:test")); |
| | | ByteString.valueOfUtf8("u:test")); |
| | | ProxiedAuthV2Control.DECODER.decode(c.isCritical(), c.getValue()); |
| | | } |
| | | |
| | |
| | | public void testDecodeControlDNValue() |
| | | throws Exception |
| | | { |
| | | ByteString authzID = ByteString.valueOf("dn:uid=test,o=test"); |
| | | ByteString authzID = ByteString.valueOfUtf8("dn:uid=test,o=test"); |
| | | |
| | | LDAPControl c = new LDAPControl(OID_PROXIED_AUTH_V2, true, authzID); |
| | | ProxiedAuthV2Control proxyControl = ProxiedAuthV2Control.DECODER.decode(c.isCritical(), c.getValue()); |
| | |
| | | public void testDecodeControlUsernameValue() |
| | | throws Exception |
| | | { |
| | | ByteString authzID = ByteString.valueOf("u:test"); |
| | | ByteString authzID = ByteString.valueOfUtf8("u:test"); |
| | | |
| | | LDAPControl c = new LDAPControl(OID_PROXIED_AUTH_V2, true, authzID); |
| | | ProxiedAuthV2Control proxyControl = ProxiedAuthV2Control.DECODER.decode(c.isCritical(), c.getValue()); |
| | |
| | | public void testDecodeControlInvalidValue() |
| | | throws Exception |
| | | { |
| | | ByteString authzID = ByteString.valueOf("invalid"); |
| | | ByteString authzID = ByteString.valueOfUtf8("invalid"); |
| | | |
| | | LDAPControl c = new LDAPControl(OID_PROXIED_AUTH_V2, true, authzID); |
| | | ProxiedAuthV2Control proxyControl = ProxiedAuthV2Control.DECODER.decode(c.isCritical(), c.getValue()); |
| | |
| | | public void testDecodeControlLegacyDNValue() |
| | | throws Exception |
| | | { |
| | | ByteString innerValue = ByteString.valueOf("dn:uid=test,o=test"); |
| | | ByteString innerValue = ByteString.valueOfUtf8("dn:uid=test,o=test"); |
| | | ByteStringBuilder bsb = new ByteStringBuilder(); |
| | | ASN1Writer writer = ASN1.getWriter(bsb); |
| | | writer.writeOctetString(innerValue); |
| | |
| | | public void testDecodeControlLegacyUsernameValue() |
| | | throws Exception |
| | | { |
| | | ByteString innerValue = ByteString.valueOf("u:test"); |
| | | ByteString innerValue = ByteString.valueOfUtf8("u:test"); |
| | | ByteStringBuilder bsb = new ByteStringBuilder(); |
| | | ASN1Writer writer = ASN1.getWriter(bsb); |
| | | writer.writeOctetString(innerValue); |
| | |
| | | throws Exception |
| | | { |
| | | ProxiedAuthV2Control proxyControl = |
| | | new ProxiedAuthV2Control(ByteString.valueOf("")); |
| | | new ProxiedAuthV2Control(ByteString.valueOfUtf8("")); |
| | | assertNull(proxyControl.getAuthorizationEntry()); |
| | | } |
| | | |
| | |
| | | throws Exception |
| | | { |
| | | ProxiedAuthV2Control proxyControl = |
| | | new ProxiedAuthV2Control(ByteString.valueOf("dn:")); |
| | | new ProxiedAuthV2Control(ByteString.valueOfUtf8("dn:")); |
| | | assertNull(proxyControl.getAuthorizationEntry()); |
| | | } |
| | | |
| | |
| | | "cn: Test User"); |
| | | |
| | | ProxiedAuthV2Control proxyControl = |
| | | new ProxiedAuthV2Control(ByteString.valueOf("dn:uid=test,o=test")); |
| | | new ProxiedAuthV2Control(ByteString.valueOfUtf8("dn:uid=test,o=test")); |
| | | assertEquals(proxyControl.getAuthorizationEntry().getName(), |
| | | DN.valueOf("uid=test,o=test")); |
| | | } |
| | |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | ProxiedAuthV2Control proxyControl = |
| | | new ProxiedAuthV2Control(ByteString.valueOf("dn:uid=test,o=test")); |
| | | new ProxiedAuthV2Control(ByteString.valueOfUtf8("dn:uid=test,o=test")); |
| | | proxyControl.getAuthorizationEntry(); |
| | | } |
| | | |
| | |
| | | "ds-pwp-account-disabled: true"); |
| | | |
| | | ProxiedAuthV2Control proxyControl = |
| | | new ProxiedAuthV2Control(ByteString.valueOf("dn:uid=test,o=test")); |
| | | new ProxiedAuthV2Control(ByteString.valueOfUtf8("dn:uid=test,o=test")); |
| | | proxyControl.getAuthorizationEntry(); |
| | | } |
| | | |
| | |
| | | throws Exception |
| | | { |
| | | ProxiedAuthV2Control proxyControl = |
| | | new ProxiedAuthV2Control(ByteString.valueOf("u:")); |
| | | new ProxiedAuthV2Control(ByteString.valueOfUtf8("u:")); |
| | | assertNull(proxyControl.getAuthorizationEntry()); |
| | | } |
| | | |
| | |
| | | "cn: Test User"); |
| | | |
| | | ProxiedAuthV2Control proxyControl = |
| | | new ProxiedAuthV2Control(ByteString.valueOf("u:test")); |
| | | new ProxiedAuthV2Control(ByteString.valueOfUtf8("u:test")); |
| | | assertEquals(proxyControl.getAuthorizationEntry().getName(), |
| | | DN.valueOf("uid=test,o=test")); |
| | | } |
| | |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | ProxiedAuthV2Control proxyControl = |
| | | new ProxiedAuthV2Control(ByteString.valueOf("u:test")); |
| | | new ProxiedAuthV2Control(ByteString.valueOfUtf8("u:test")); |
| | | proxyControl.getAuthorizationEntry(); |
| | | } |
| | | |
| | |
| | | "ds-pwp-account-disabled: true"); |
| | | |
| | | ProxiedAuthV2Control proxyControl = |
| | | new ProxiedAuthV2Control(ByteString.valueOf("u:test")); |
| | | new ProxiedAuthV2Control(ByteString.valueOfUtf8("u:test")); |
| | | proxyControl.getAuthorizationEntry(); |
| | | } |
| | | |
| | |
| | | throws Exception |
| | | { |
| | | ProxiedAuthV2Control proxyControl = |
| | | new ProxiedAuthV2Control(ByteString.valueOf("invalid")); |
| | | new ProxiedAuthV2Control(ByteString.valueOfUtf8("invalid")); |
| | | proxyControl.getAuthorizationEntry(); |
| | | } |
| | | |
| | |
| | | // The default toString() calls the version that takes a string builder |
| | | // argument, so we only need to use the default version to cover both cases. |
| | | ProxiedAuthV2Control proxyControl = |
| | | new ProxiedAuthV2Control(ByteString.valueOf("dn:uid=test,o=test")); |
| | | new ProxiedAuthV2Control(ByteString.valueOfUtf8("dn:uid=test,o=test")); |
| | | proxyControl.toString(); |
| | | |
| | | proxyControl = new ProxiedAuthV2Control(ByteString.valueOf("u:test")); |
| | | proxyControl = new ProxiedAuthV2Control(ByteString.valueOfUtf8("u:test")); |
| | | proxyControl.toString(); |
| | | } |
| | | } |