mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Webapp authenticator framework test cases
This commit is contained in:
parent
8f7c2447ad
commit
b47c3eb5dd
@ -16,7 +16,7 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.wso2.carbon.webapp.authenticator.framework.test;
|
package org.wso2.carbon.webapp.authenticator.framework;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
@ -16,7 +16,7 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.wso2.carbon.webapp.authenticator.framework.test;
|
package org.wso2.carbon.webapp.authenticator.framework;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
@ -16,14 +16,13 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.wso2.carbon.webapp.authenticator.framework.test;
|
package org.wso2.carbon.webapp.authenticator.framework;
|
||||||
|
|
||||||
import org.testng.Assert;
|
import org.testng.Assert;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
import org.wso2.carbon.webapp.authenticator.framework.WebappAuthenticatorRepository;
|
|
||||||
import org.wso2.carbon.webapp.authenticator.framework.authenticator.WebappAuthenticator;
|
import org.wso2.carbon.webapp.authenticator.framework.authenticator.WebappAuthenticator;
|
||||||
import org.wso2.carbon.webapp.authenticator.framework.test.util.MalformedAuthenticator;
|
import org.wso2.carbon.webapp.authenticator.framework.util.MalformedAuthenticator;
|
||||||
import org.wso2.carbon.webapp.authenticator.framework.test.util.TestWebappAuthenticator;
|
import org.wso2.carbon.webapp.authenticator.framework.util.TestWebappAuthenticator;
|
||||||
|
|
||||||
public class WebappAuthenticatorRepositoryTest {
|
public class WebappAuthenticatorRepositoryTest {
|
||||||
|
|
||||||
@ -0,0 +1,41 @@
|
|||||||
|
package org.wso2.carbon.webapp.authenticator.framework.authenticator;
|
||||||
|
|
||||||
|
import org.apache.catalina.Context;
|
||||||
|
import org.apache.catalina.connector.Request;
|
||||||
|
import org.apache.catalina.core.StandardContext;
|
||||||
|
import org.apache.tomcat.util.buf.MessageBytes;
|
||||||
|
import org.apache.tomcat.util.http.MimeHeaders;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
|
public class BasicAuthAuthenticatorTest {
|
||||||
|
@Test
|
||||||
|
public void testCanHandle()
|
||||||
|
throws NoSuchFieldException, IllegalAccessException, ClassNotFoundException, NoSuchMethodException,
|
||||||
|
InvocationTargetException, InstantiationException {
|
||||||
|
Request request = new Request();
|
||||||
|
Context context = new StandardContext();
|
||||||
|
context.addParameter("basicAuth", "true");
|
||||||
|
request.setContext(context);
|
||||||
|
org.apache.coyote.Request coyoteRequest = new org.apache.coyote.Request();
|
||||||
|
Field headers = org.apache.coyote.Request.class.getDeclaredField("headers");
|
||||||
|
headers.setAccessible(true);
|
||||||
|
|
||||||
|
Field mimeHeaderField = MimeHeaders.class.getDeclaredField("headers");
|
||||||
|
mimeHeaderField.setAccessible(true);
|
||||||
|
|
||||||
|
|
||||||
|
MimeHeaders mimeHeaders = new MimeHeaders();
|
||||||
|
MessageBytes bytes = mimeHeaders.addValue("Authorization");
|
||||||
|
bytes.setString("test");
|
||||||
|
// mimeHeaders.setValue()
|
||||||
|
headers.set(coyoteRequest, mimeHeaders);
|
||||||
|
|
||||||
|
request.setCoyoteRequest(coyoteRequest);
|
||||||
|
BasicAuthAuthenticator basicAuthAuthenticator = new BasicAuthAuthenticator();
|
||||||
|
basicAuthAuthenticator.canHandle(request);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -16,7 +16,7 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.wso2.carbon.webapp.authenticator.framework.test.util;
|
package org.wso2.carbon.webapp.authenticator.framework.util;
|
||||||
|
|
||||||
import org.apache.catalina.connector.Request;
|
import org.apache.catalina.connector.Request;
|
||||||
import org.apache.catalina.connector.Response;
|
import org.apache.catalina.connector.Response;
|
||||||
@ -16,7 +16,7 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.wso2.carbon.webapp.authenticator.framework.test.util;
|
package org.wso2.carbon.webapp.authenticator.framework.util;
|
||||||
|
|
||||||
import org.apache.catalina.connector.Request;
|
import org.apache.catalina.connector.Request;
|
||||||
import org.apache.catalina.connector.Response;
|
import org.apache.catalina.connector.Response;
|
||||||
@ -22,21 +22,12 @@
|
|||||||
<suite name="WebappAuthenticatorFramework">
|
<suite name="WebappAuthenticatorFramework">
|
||||||
<parameter name="useDefaultListeners" value="false"/>
|
<parameter name="useDefaultListeners" value="false"/>
|
||||||
|
|
||||||
<test name="WebappAuthenticatorConfigTests" preserve-order="true">
|
<test name="WebappAuthenticatorTests" preserve-order="true">
|
||||||
<classes>
|
<classes>
|
||||||
<class name="org.wso2.carbon.webapp.authenticator.framework.test.WebappAuthenticatorConfigTest"/>
|
<class name="org.wso2.carbon.webapp.authenticator.framework.WebappAuthenticatorConfigTest"/>
|
||||||
</classes>
|
<class name="org.wso2.carbon.webapp.authenticator.framework.WebappAuthenticatorFrameworkUtilTest"/>
|
||||||
</test>
|
<class name="org.wso2.carbon.webapp.authenticator.framework.WebappAuthenticatorRepositoryTest"/>
|
||||||
|
<class name="org.wso2.carbon.webapp.authenticator.framework.authenticator.BasicAuthAuthenticatorTest" />
|
||||||
<test name="WebappAuthenticatorUtilTests" preserve-order="true">
|
|
||||||
<classes>
|
|
||||||
<class name="org.wso2.carbon.webapp.authenticator.framework.test.WebappAuthenticatorFrameworkUtilTest"/>
|
|
||||||
</classes>
|
|
||||||
</test>
|
|
||||||
|
|
||||||
<test name="WebappAuthenticatorGeneralTests" preserve-order="true">
|
|
||||||
<classes>
|
|
||||||
<class name="org.wso2.carbon.webapp.authenticator.framework.test.WebappAuthenticatorRepositoryTest"/>
|
|
||||||
</classes>
|
</classes>
|
||||||
</test>
|
</test>
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user