package test.at.gv.egovernment.moa.id.auth.builder; import at.gv.egovernment.moa.id.auth.builder.CreateXMLSignatureRequestBuilder; import test.at.gv.egovernment.moa.id.UnitTestCase; /** * @author Paul Ivancsics * @version $Id$ */ public class CreateXMLSignatureBuilderTest extends UnitTestCase { private static final String nl = "\n"; public static final String TRANSFORMS_INFO = " " + nl + " " + nl + " " + nl + " " + nl + "" + nl + "" + nl + "" + nl + "" + nl + "" + nl + "" + nl + "" + nl + "" + nl + " " + nl + " " + nl + " " + nl + " text/html" + nl + " " + nl + " " + nl; public static final String REQUEST_SHOULD = "" + nl + "" + nl + " SecureSignatureKeypair" + nl + " " + nl + " " + nl + TRANSFORMS_INFO + " " + nl + " " + nl + " " + nl + " " + AuthenticationBlockAssertionBuilderTest.ASSERTION_SHOULD + "" + nl + " " + nl + " /saml:Assertion" + nl + " " + nl + ""; public static final String TRANSFORMS_INFO_SL12 = " " + nl + " " + nl + " " + nl + " " + nl + "" + nl + "" + nl + "" + nl + "" + nl + "" + nl + "" + nl + "" + nl + "" + nl + " " + nl + " " + nl + " " + nl + " text/html" + nl + " " + nl + " " + nl; public static final String REQUEST_SHOULD_SL12 = "" + nl + "" + nl + " SecureSignatureKeypair" + nl + " " + nl + " " + nl + TRANSFORMS_INFO_SL12 + " " + nl + " " + nl + " " + nl + " " + AuthenticationBlockAssertionBuilderTest.ASSERTION_SHOULD + "" + nl + " " + nl + " /saml:Assertion" + nl + " " + nl + ""; public CreateXMLSignatureBuilderTest(String name) { super(name); } public void testBuild() throws Exception { // test build for Security Layer version 1.1 and 1.0 String request = new CreateXMLSignatureRequestBuilder().build( AuthenticationBlockAssertionBuilderTest.ASSERTION_SHOULD, "SecureSignatureKeypair", new String[] {TRANSFORMS_INFO}, false); assertXmlEquals(REQUEST_SHOULD, request); // test build for Security Layer version 1.2 String requestSL12 = new CreateXMLSignatureRequestBuilder().build( AuthenticationBlockAssertionBuilderTest.ASSERTION_SHOULD, "SecureSignatureKeypair", new String[] {TRANSFORMS_INFO}, true); assertXmlEquals(REQUEST_SHOULD_SL12, requestSL12); } }