RejectUnauthReqTests.java revision 480256311ff1597d92043303772f072d8d67fb3c
/*
* 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
* 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
* trunk/opends/resource/legal-notices/OpenDS.LICENSE. 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
*
*
* Portions Copyright 2007 Sun Microsystems, Inc.
*/
/**
* 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)
{
"-h", "127.0.0.1",
"-D","cn=directory manager",
"-w","password",
"-a",
"-f", filePath,
};
else
{
"-h", "127.0.0.1",
"-a",
"-f", filePath,
};
}
/**
* 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.
*/
{
"dn: o=rejectTestCase,o=test",
"changetype: modify",
"replace: description",
"description: New Description");
if(authentication)
{
"-h", "127.0.0.1",
"-D","cn=directory manager",
"-w","password",
"-f", path
};
else
{
"-h", "127.0.0.1",
"-f", path
};
}
/**
* 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)
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"o:test",
"o=test"
};
else
{
"-h", "127.0.0.1",
"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.
*/
{
"changetype: modrdn",
"newrdn: o=mod_rejectTestCase",
"deleteoldrdn: 0");
if(authentication)
{
"-h", "127.0.0.1",
"-D","cn=directory manager",
"-w","password",
"-f", path
};
else
{
"-h", "127.0.0.1",
"-f", path
};
}
/**
* 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)
{
"-h", "127.0.0.1",
"-V", "3",
"-D", "cn=Directory Manager",
"-w", "password",
"o=mod_rejectTestCase,o=test"
};
else
{
"-h", "127.0.0.1",
"o=mod_rejectTestCase,o=test"
};
}
/**
* Ensures that the Directory Server is running before executing the
* testcases.
*
* @throws Exception If an unexpected problem occurs.
*/
@BeforeClass()
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()
{
"-h", "127.0.0.1",
"-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()
{
"-h", "127.0.0.1",
"-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 InternalClientConnection(new AuthenticationInfo());
new ASN1OctetString("cn=Directory Manager");
new ASN1OctetString("password");
}
/**
* 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 InternalClientConnection(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
{
new ASN1OctetString("password"),
new ArrayList<LDAPControl>(),
new ArrayList<LDAPControl>());
new UnbindRequestProtocolOp());
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
{
new UnbindRequestProtocolOp());
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
{
{
"-h", "127.0.0.1",
"-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 change in the configuration attribute takes effect
* on-the-fly.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(dependsOnMethods = {
"org.opends.server.core.RejectUnauthReqTests.testAuthSearchDefCfg",
"org.opends.server.core.RejectUnauthReqTests.testUnauthSearchDefCfg",
"org.opends.server.core.RejectUnauthReqTests.testAuthBindDefCfg",
"org.opends.server.core.RejectUnauthReqTests.testUnauthBindDefCfg",
"org.opends.server.core.RejectUnauthReqTests.testUnauthWAIDefCfg",
"org.opends.server.core.RejectUnauthReqTests.testAuthWAIDefCfg",
"org.opends.server.core.RejectUnauthReqTests.testStartTLSUnauthDefCfg",
// "org.opends.server.core.RejectUnauthReqTests.testOtherOpsUnauthDefCfg",
"org.opends.server.core.RejectUnauthReqTests.testOtherOpsAuthDefCfg"
})
public void testChangeAndVerifyRejUnauthReqCfgAttr() throws Exception
{
//Verify the default setting of the configuration attribute.
"dn: cn=config",
"changetype: modify",
"replace: ds-cfg-reject-unauthenticated-requests",
"ds-cfg-reject-unauthenticated-requests: true");
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-f", path
};
}
/**
* Tests whether both authenticated and unauthenticated SEARCH requests
* will be allowed with the new configuration settings for
* "ds-cfg-reject-unauthenticated-requests" .
*/
@Test(dependsOnMethods = {
"org.opends.server.core.RejectUnauthReqTests." +
"testChangeAndVerifyRejUnauthReqCfgAttr"
})
public void testSearchNewCfg()
{
"-h", "127.0.0.1",
"-b", "",
"-s", "base",
"(objectClass=*)"
};
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-b", "",
"-s", "base",
"(objectClass=*)"
} ;
}
/**
* Tests whether authenticated and unauthenticated BIND requests will be
* allowed with the new configuration settings for
* "ds-cfg-reject-unauthenticated-requests" .
*/
@Test(dependsOnMethods = {
"org.opends.server.core.RejectUnauthReqTests." +
"testChangeAndVerifyRejUnauthReqCfgAttr"})
public void testBindNewCfg()
{
new InternalClientConnection(new AuthenticationInfo());
new ASN1OctetString("cn=Directory Manager");
new ASN1OctetString("password");
//Unauthenticated BIND request.
//Authenticated BIND request.
}
/**
* 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(dependsOnMethods = {
"org.opends.server.core.RejectUnauthReqTests." +
"testChangeAndVerifyRejUnauthReqCfgAttr"})
public void testStartTLSNoAuthTrustAll() throws Exception
{
{
"-h", "127.0.0.1",
"-D", "cn=directory manager",
"-w", "password",
"-q",
"-X",
"-b", "",
"-s", "base",
"(objectClass=*)"
};
}
/**
* 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(dependsOnMethods = {
"org.opends.server.core.RejectUnauthReqTests." +
"testChangeAndVerifyRejUnauthReqCfgAttr"})
public void testAuthWAINewCfg() throws Exception
{
}
/**
* 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(dependsOnMethods = {
"org.opends.server.core.RejectUnauthReqTests." +
"testChangeAndVerifyRejUnauthReqCfgAttr"})
public void testUnauthWAINewCfg() throws UnsupportedEncodingException,
{
try
{
}
catch(LDAPException e)
{
}
finally
{
new UnbindRequestProtocolOp());
s.close();
}
}
/**
* 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(dependsOnMethods = {
"org.opends.server.core.RejectUnauthReqTests." +
"testChangeAndVerifyRejUnauthReqCfgAttr"})
public void testOtherOpsAuthNewCfg() throws Exception {
}
/**
* 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(dependsOnMethods = {
"org.opends.server.core.RejectUnauthReqTests." +
"testChangeAndVerifyRejUnauthReqCfgAttr"})
public void testOtherOpsUnauthNewCfg() throws Exception
{
}
/**
* Resets the configuration attribute to the default settings.
*
* @throws Exception If an unexpected problem occurs.
*/
@AfterClass()
public void testResetRejUnauthReqCfgAttr() throws Exception
{
"dn: cn=config",
"changetype: modify",
"replace: ds-cfg-reject-unauthenticated-requests",
"ds-cfg-reject-unauthenticated-requests: false");
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-f", path
};
}
}