RejectUnauthReqTests.java revision ea1068c292e9b341af6d6b563cd8988a96be20a9
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2008 Sun Microsystems, Inc.
* Portions Copyright 2014-2015 ForgeRock AS
*/
/**
* A set of testcases for configuration attribute
* "ds-cfg-reject-unauthenticated-requests".
*/
public class RejectUnauthReqTests extends CoreTestCase
{
/**
* Utility method which is called by the testcase sending an ADD
* request.
*
* @param authentication
* The flag to set the authentication on and off.
* @return The error code of operation performed.
* @throws Exception
* If an unexpected problem occurs.
*/
{
"dn: o=rejectTestCase,o=test", "objectclass: top",
"objectclass: organization", "o: rejectTestCase",
"description: Reject Test Case");
if (authentication)
{
"--noPropertiesFile",
"-h",
"127.0.0.1",
"-p",
"-D",
"cn=directory manager",
"-w",
"password",
"-a",
"-f",
};
else
{
"--noPropertiesFile",
"-h",
"127.0.0.1",
"-p",
"-a",
"-f",
};
}
/**
* Utility method which is called by the testcase sending a MODIFY
* request.
*
* @param authentication
* The flag to set the authentication on and off.
* @return The error code of operation performed.
* @throws Exception
* If an unexpected problem occurs.
*/
{
"changetype: modify", "replace: description",
"description: New Description");
if (authentication)
{
"--noPropertiesFile",
"-h",
"127.0.0.1",
"-p",
"-D",
"cn=directory manager",
"-w",
"password",
"-f",
};
else
{
"--noPropertiesFile",
"-h",
"127.0.0.1",
"-p",
"-f",
};
}
/**
* Utility method which is called by the testcase sending a COMPARE
* request.
*
* @param authentication
* The flag to set the authentication on and off.
* @return The error code of operation performed.
* @throws Exception
* If an unexpected problem occurs.
*/
{
if (authentication)
{
"--noPropertiesFile",
"-h",
"127.0.0.1",
"-p",
"-D",
"cn=Directory Manager",
"-w",
"password",
"o:test",
"o=test"
};
else
{
"--noPropertiesFile",
"-h",
"127.0.0.1",
"-p",
"o:test",
"o=test"
};
}
/**
* Utility method which is called by the testcase sending a MODRDN
* request.
*
* @param authentication
* The flag to set the authentication on and off.
* @return The error code of operation performed.
* @throws Exception
* If an unexpected problem occurs.
*/
{
"newrdn: o=mod_rejectTestCase", "deleteoldrdn: 0");
if (authentication)
{
"--noPropertiesFile",
"-h",
"127.0.0.1",
"-p",
"-D",
"cn=directory manager",
"-w",
"password",
"-f",
};
else
{
"--noPropertiesFile",
"-h",
"127.0.0.1",
"-p",
"-f",
};
}
/**
* Utility method which is called by the testcase sending a DELETE
* request.
*
* @param authentication
* The flag to set the authentication on and off.
* @return The error code of operation performed.
* @throws Exception
* If an unexpected problem occurs.
*/
{
if (authentication)
{
"--noPropertiesFile",
"-h",
"127.0.0.1",
"-p",
"-V",
"3",
"-D",
"cn=Directory Manager",
"-w",
"password",
"o=mod_rejectTestCase,o=test"
};
else
{
"--noPropertiesFile",
"-h",
"127.0.0.1",
"-p",
"o=mod_rejectTestCase,o=test"
};
}
/**
* Ensures that the Directory Server is running before executing the
* testcases.
*
* @throws Exception
* If an unexpected problem occurs.
*/
public void startServer() throws Exception
{
}
/**
* Tests whether an authenticated SEARCH request will be allowed
* with the default configuration settings for
* "ds-cfg-reject-unauthenticated-requests".
*/
@Test
public void testAuthSearchDefCfg()
{
{
"--noPropertiesFile",
"-h",
"127.0.0.1",
"-p",
"-D",
"cn=Directory Manager",
"-w",
"password",
"-b",
"",
"-s",
"base",
"(objectClass=*)"
};
}
/**
* Tests whether an unauthenticated SEARCH request will be allowed
* with the default configuration settings for
* "ds-cfg-reject-unauthenticated-requests".
*/
@Test
public void testUnauthSearchDefCfg()
{
{
"--noPropertiesFile",
"-h",
"127.0.0.1",
"-p",
"-b",
"",
"-s",
"base",
"(objectClass=*)"
};
}
/**
* Tests whether an authenticated BIND request will be allowed with
* the default configuration settings for
* "ds-cfg-reject-unauthenticated-requests" .
*/
@Test
public void testAuthBindDefCfg()
{
new AuthenticationInfo());
}
/**
* Tests whether an Unauthenticated BIND request will be allowed
* with the default configuration settings for
* "ds-cfg-reject-unauthenticated-requests".
*/
@Test
public void testUnauthBindDefCfg()
{
new AuthenticationInfo());
}
/**
* Tests whether the Who Am I? extended operation with an internal
* authenticated connection succeeds with default setting of
* "ds-cfg-reject-unauthenticated-requests".
*
* @throws Exception
* If an unexpected problem occurs.
*/
@Test
public void testAuthWAIDefCfg() throws Exception
{
s.close();
}
/**
* Tests whether the who am I? extended operation with an internal
* unauthenticated connection succeeds with default setting of
* "ds-cfg-reject-unauthenticated-requests".
*
* @throws Exception
* If an unexpected problem occurs.
*/
@Test
public void testUnauthWAIDefCfg() throws Exception
{
s.close();
}
/**
* Tests the use of the StartTLS extended operation to communicate
* with the server in conjunction with no authentication and using
* blind trust with the default configuration settings.
*
* @throws Exception
* If an unexpected problem occurs.
*/
@Test
public void testStartTLSUnauthDefCfg() throws Exception
{
{
"--noPropertiesFile",
"-h",
"127.0.0.1",
"-p",
"-D",
"cn=directory manager",
"-w",
"password",
"-q",
"-X",
"-b",
"",
"-s",
"base",
"(objectClass=*)"
};
}
/**
* Tests the whether the authenticated ADD,MODIFY,COMPARE,MODRDN and
* DELETE requests succeed with the default configuration settings.
*
* @throws Exception
* If an unexpected problem occurs.
*/
@Test
public void testOtherOpsAuthDefCfg() throws Exception
{
}
/**
* Tests the whether the unauthenticated ADD,MODIFY,COMPARE,MODRDN
* and DELETE requests succeed with the default configuration
* settings. FIXME: This test is disabled because it is unreasonable
* to expect unauthenticated writes to succeed when access control
* is enabled.
*
* @throws Exception
* If an unexpected problem occurs.
*/
public void testOtherOpsUnauthDefCfg() throws Exception
{
}
/**
* Tests whether both authenticated and unauthenticated SEARCH
* requests will be allowed with the new configuration settings for
* "ds-cfg-reject-unauthenticated-requests" .
*/
@Test
public void testSearchNewCfg()
{
try
{
{
"--noPropertiesFile",
"-h",
"127.0.0.1",
"-p",
"-b",
"",
"-s",
"base",
"(objectClass=*)"
};
{
"--noPropertiesFile",
"-h",
"127.0.0.1",
"-p",
"-D",
"cn=Directory Manager",
"-w",
"password",
"-b",
"",
"-s",
"base",
"(objectClass=*)"
};
}
finally
{
}
}
/**
* Tests whether authenticated and unauthenticated BIND requests
* will be allowed with the new configuration settings for
* "ds-cfg-reject-unauthenticated-requests" .
*/
@Test
public void testBindNewCfg()
{
try
{
new AuthenticationInfo());
// Unauthenticated BIND request.
// Authenticated BIND request.
}
finally
{
}
}
/**
* Tests the use of the StartTLS extended operation to communicate
* with the server in conjunction with no authentication and using
* blind trust.
*
* @throws Exception
* If an unexpected problem occurs.
*/
@Test
public void testStartTLSNoAuthTrustAll() throws Exception
{
try
{
{
"--noPropertiesFile",
"-h",
"127.0.0.1",
"-p",
"-D",
"cn=directory manager",
"-w",
"password",
"-q",
"-X",
"-b",
"",
"-s",
"base",
"(objectClass=*)"
};
}
finally
{
}
}
/**
* Tests whether the Who Am I? extended operation with an internal
* authenticated connection succeeds with new setting of
* "ds-cfg-reject-unauthenticated-requests".
*
* @throws Exception
* If an unexpected problem occurs.
*/
@Test
public void testAuthWAINewCfg() throws Exception
{
try
{
}
finally
{
}
}
/**
* Tests whether the who am I? extended operation with an
* unauthenticated connection fails with new setting of
* "ds-cfg-reject-unauthenticated-requests".
*
* @throws UnsupportedEncodingException
* If an unexpected problem occurs.
* @throws IOException
* If an unexpected problem occurs.
* @throws ClientException
* If an unexpected problem occurs.
*/
@Test
public void testUnauthWAINewCfg() throws UnsupportedEncodingException,
{
try
{
try
{
}
catch (LDAPException e)
{
}
finally
{
.getAndIncrement(), new UnbindRequestProtocolOp());
s.close();
}
}
finally
{
}
}
/**
* Tests the whether the authenticated ADD,MODIFY,COMPARE,MODRDN and
* DELETE requests succeed with the new configuration settings.
*
* @throws Exception
* If an unexpected problem occurs.
*/
@Test
public void testOtherOpsAuthNewCfg() throws Exception
{
try
{
}
finally
{
}
}
/**
* Tests the whether the unauthenticated ADD,MODIFY,COMPARE,MODRDN
* and DELETE requests fail with the new configuration settings.
*
* @throws Exception
* If an unexpected problem occurs.
*/
@Test
public void testOtherOpsUnauthNewCfg() throws Exception
{
try
{
}
finally
{
}
}
}