From b9e7df0cbe67b486ce3a1a2177bd08c0ced9e005 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@d688527b-c9ab-4aba-bd8d-4036d912da1d> Date: Mon, 22 Dec 2003 17:51:40 +0000 Subject: This commit was manufactured by cvs2svn to create tag 'Build_002'. git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/tags/Build_002@88 d688527b-c9ab-4aba-bd8d-4036d912da1d --- .../moa/id/auth/AuthenticationServerTest.java | 50 ------- .../moa/id/auth/MOAIDAuthInitialiserTest.java | 47 ------ .../egovernment/moa/id/auth/builder/AllTests.java | 33 ---- .../AuthenticationBlockAssertionBuilderTest.java | 46 ------ .../builder/CreateXMLSignatureBuilderTest.java | 58 ------- .../builder/GetIdentityLinkFormBuilderTest.java | 73 --------- .../builder/InfoboxReadRequestBuilderTest.java | 29 ---- .../moa/id/auth/builder/PersonDataBuilderTest.java | 51 ------- .../id/auth/builder/SAMLArtifactBuilderTest.java | 52 ------- .../VerifyXMLSignatureRequestBuilderTest.java | 93 ------------ .../moa/id/auth/invoke/MOASPSSTestCase.java | 38 ----- .../id/auth/invoke/SignatureVerificationTest.java | 166 --------------------- .../egovernment/moa/id/auth/parser/AllTests.java | 29 ---- .../parser/IdentityLinkAssertionParserTest.java | 137 ----------------- .../auth/parser/InfoboxReadResponseParserTest.java | 67 --------- .../moa/id/auth/parser/SAMLArtifactParserTest.java | 55 ------- .../servlet/GetAuthenticationDataServiceTest.java | 91 ----------- 17 files changed, 1115 deletions(-) delete mode 100644 id.server/src/test/at/gv/egovernment/moa/id/auth/AuthenticationServerTest.java delete mode 100644 id.server/src/test/at/gv/egovernment/moa/id/auth/MOAIDAuthInitialiserTest.java delete mode 100644 id.server/src/test/at/gv/egovernment/moa/id/auth/builder/AllTests.java delete mode 100644 id.server/src/test/at/gv/egovernment/moa/id/auth/builder/AuthenticationBlockAssertionBuilderTest.java delete mode 100644 id.server/src/test/at/gv/egovernment/moa/id/auth/builder/CreateXMLSignatureBuilderTest.java delete mode 100644 id.server/src/test/at/gv/egovernment/moa/id/auth/builder/GetIdentityLinkFormBuilderTest.java delete mode 100644 id.server/src/test/at/gv/egovernment/moa/id/auth/builder/InfoboxReadRequestBuilderTest.java delete mode 100644 id.server/src/test/at/gv/egovernment/moa/id/auth/builder/PersonDataBuilderTest.java delete mode 100644 id.server/src/test/at/gv/egovernment/moa/id/auth/builder/SAMLArtifactBuilderTest.java delete mode 100644 id.server/src/test/at/gv/egovernment/moa/id/auth/builder/VerifyXMLSignatureRequestBuilderTest.java delete mode 100644 id.server/src/test/at/gv/egovernment/moa/id/auth/invoke/MOASPSSTestCase.java delete mode 100644 id.server/src/test/at/gv/egovernment/moa/id/auth/invoke/SignatureVerificationTest.java delete mode 100644 id.server/src/test/at/gv/egovernment/moa/id/auth/parser/AllTests.java delete mode 100644 id.server/src/test/at/gv/egovernment/moa/id/auth/parser/IdentityLinkAssertionParserTest.java delete mode 100644 id.server/src/test/at/gv/egovernment/moa/id/auth/parser/InfoboxReadResponseParserTest.java delete mode 100644 id.server/src/test/at/gv/egovernment/moa/id/auth/parser/SAMLArtifactParserTest.java delete mode 100644 id.server/src/test/at/gv/egovernment/moa/id/auth/servlet/GetAuthenticationDataServiceTest.java (limited to 'id.server/src/test/at/gv/egovernment/moa/id/auth') diff --git a/id.server/src/test/at/gv/egovernment/moa/id/auth/AuthenticationServerTest.java b/id.server/src/test/at/gv/egovernment/moa/id/auth/AuthenticationServerTest.java deleted file mode 100644 index 753b2ef12..000000000 --- a/id.server/src/test/at/gv/egovernment/moa/id/auth/AuthenticationServerTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package test.at.gv.egovernment.moa.id.auth; - -import at.gv.egovernment.moa.id.auth.AuthenticationServer; -import at.gv.egovernment.moa.id.data.AuthenticationData; - -import test.at.gv.egovernment.moa.id.UnitTestCase; - -/** - * @author Paul Ivancsics - * @version $Id$ - */ -public class AuthenticationServerTest extends UnitTestCase { - - public AuthenticationServerTest(String name) { - super(name); - } - - public void testStandard() throws Exception { - doTest( - "standard", - "https://localhost:8443/auth", - "gb", - "https://localhost:9443/", - null, - null); - } - public void doTest(String testdataDirectory, String authURL, String target, String oaURL, String bkuURL, String templateURL) throws Exception { - String testdataRoot = TESTDATA_ROOT + "xmldata/" + testdataDirectory + "/"; - AuthenticationServer server = AuthenticationServer.getInstance(); - String htmlForm = server.startAuthentication(authURL, target, oaURL, templateURL, bkuURL, null); - String sessionID = parseSessionIDFromForm(htmlForm); - String infoboxReadResponse = readFile(TESTDATA_ROOT + "xmldata/testperson1/" + "InfoboxReadResponse.xml"); - String createXMLSignatureRequest = server.verifyIdentityLink(sessionID, infoboxReadResponse); - String createXMLSignatureRequestShould = readFile(testdataRoot + "CreateXMLSignatureRequest.xml"); - assertXmlEquals(createXMLSignatureRequestShould, createXMLSignatureRequest); - String createXMLSignatureResponse = readFile(testdataRoot + "CreateXMLSignatureResponse.xml"); - String samlArtifact = server.verifyAuthenticationBlock(sessionID, createXMLSignatureResponse); - AuthenticationData authData = server.getAuthenticationData(samlArtifact); - String authDataShould = readFile(testdataRoot + "AuthenticationDataAssertion.xml"); - assertXmlEquals(authDataShould, authData.getSamlAssertion()); - } - private String parseSessionIDFromForm(String htmlForm) { - String parName = "MOASessionID="; - assertTrue("HTML Form enthält keine SessionID", htmlForm.indexOf(parName) >= 0); - int i1 = htmlForm.indexOf(parName) + parName.length(); - int i2 = htmlForm.indexOf("\"", i1); - assertTrue("HTML Form enthält keine gültige SessionID", i2 > i1); - return htmlForm.substring(i1, i2); - } -} diff --git a/id.server/src/test/at/gv/egovernment/moa/id/auth/MOAIDAuthInitialiserTest.java b/id.server/src/test/at/gv/egovernment/moa/id/auth/MOAIDAuthInitialiserTest.java deleted file mode 100644 index 4bc7d52d6..000000000 --- a/id.server/src/test/at/gv/egovernment/moa/id/auth/MOAIDAuthInitialiserTest.java +++ /dev/null @@ -1,47 +0,0 @@ -package test.at.gv.egovernment.moa.id.auth; - -import java.security.KeyStore; -import java.util.Enumeration; - -import test.at.gv.egovernment.moa.id.UnitTestCase; -import at.gv.egovernment.moa.id.util.SSLUtils; -import at.gv.egovernment.moa.util.KeyStoreUtils; - -/** - * @author Paul Ivancsics - * @version $Id$ - */ -public class MOAIDAuthInitialiserTest extends UnitTestCase { - - public MOAIDAuthInitialiserTest(String name) { - super(name); - } - - public void testInit() throws Exception - { -// System.setProperty( -// ConfigurationProvider.CONFIG_PROPERTY_NAME,"C://Programme/ApacheGroup/abnahme/conf/moa-id/SampleMOAIDConfiguration.xml"); -// System.setProperty( -// ConfigurationProvider.CONFIG_PROPERTY_NAME,"D://Daten/_Projects/moa_id_maengel/SampleMOAIDConfiguration.xml"); - SSLUtils.initialize(); - - try { - KeyStore s = KeyStoreUtils.loadKeyStore("pkcs12","file:C:/Programme/ApacheGroup/abnahme/cert/keystore.p12","changeit"); - System.out.println(s.getProvider().getClass().getName()); - Enumeration enum = s.aliases(); - while (enum.hasMoreElements()) { - String element = (String) enum.nextElement(); - System.out.print(element+":"); - System.out.println(s.getCertificate(element).getPublicKey().getAlgorithm()); - System.out.println(s.getCertificate(element).getType()); - } - - - System.out.println(s.getCertificate("pc41408").getPublicKey().getFormat()); - - } - catch (Exception e) {e.printStackTrace();}; - - } - - } diff --git a/id.server/src/test/at/gv/egovernment/moa/id/auth/builder/AllTests.java b/id.server/src/test/at/gv/egovernment/moa/id/auth/builder/AllTests.java deleted file mode 100644 index 77dff29aa..000000000 --- a/id.server/src/test/at/gv/egovernment/moa/id/auth/builder/AllTests.java +++ /dev/null @@ -1,33 +0,0 @@ -package test.at.gv.egovernment.moa.id.auth.builder; - -import junit.awtui.TestRunner; -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * @author patrick - * @version $Id$ - */ -public class AllTests { - - public static Test suite() { - TestSuite suite = new TestSuite(); - - suite.addTestSuite(AuthenticationBlockAssertionBuilderTest.class); - suite.addTestSuite(CreateXMLSignatureBuilderTest.class); - suite.addTestSuite(GetIdentityLinkFormBuilderTest.class); - suite.addTestSuite(InfoboxReadRequestBuilderTest.class); - suite.addTestSuite(PersonDataBuilderTest.class); - suite.addTestSuite(SAMLArtifactBuilderTest.class); - - return suite; - } - - public static void main(String[] args) { - try { - TestRunner.run(AllTests.class); - } catch (Exception e) { - e.printStackTrace(); - } - } -} diff --git a/id.server/src/test/at/gv/egovernment/moa/id/auth/builder/AuthenticationBlockAssertionBuilderTest.java b/id.server/src/test/at/gv/egovernment/moa/id/auth/builder/AuthenticationBlockAssertionBuilderTest.java deleted file mode 100644 index 2717ee8c0..000000000 --- a/id.server/src/test/at/gv/egovernment/moa/id/auth/builder/AuthenticationBlockAssertionBuilderTest.java +++ /dev/null @@ -1,46 +0,0 @@ -package test.at.gv.egovernment.moa.id.auth.builder; - -import test.at.gv.egovernment.moa.id.UnitTestCase; - -import at.gv.egovernment.moa.id.auth.builder.AuthenticationBlockAssertionBuilder; - -/** - * @author Paul Ivancsics - * @version $Id$ - */ -public class AuthenticationBlockAssertionBuilderTest extends UnitTestCase { - private static final String nl = "\n"; - private static final String ISSUER = "Hugo Mustermann"; - private static final String ISSUE_INSTANT = "2003-03-15T22:50:21+01:00"; - private static final String AUTH_URL = "https://auth.moa.gv.at/"; - private static final String TARGET = "Grundbuch"; - private static final String OA_URL = "https://grundbuch.gv.at/"; - - // wird auch von CreateXMLSignatureBuilderTest verwendet ! - public static final String ASSERTION_SHOULD = -"" + nl + -" " + nl + -" " + nl + -" " + AUTH_URL + "" + nl + -" " + nl + -" " + nl + -" " + TARGET + "" + nl + -" " + nl + -" " + nl + -" " + OA_URL + "" + nl + -" " + nl + -" " + nl + -""; - - public AuthenticationBlockAssertionBuilderTest(String name) { - super(name); - } - - public void testBuild() throws Exception { - AuthenticationBlockAssertionBuilder builder = new AuthenticationBlockAssertionBuilder(); - String assertionBuilt = builder.build(ISSUER, ISSUE_INSTANT, AUTH_URL, TARGET, OA_URL); - assertionBuilt = XML_DECL + assertionBuilt; - String assertionShould = XML_DECL + ASSERTION_SHOULD; - assertXmlEquals(assertionShould, assertionBuilt); - } -} diff --git a/id.server/src/test/at/gv/egovernment/moa/id/auth/builder/CreateXMLSignatureBuilderTest.java b/id.server/src/test/at/gv/egovernment/moa/id/auth/builder/CreateXMLSignatureBuilderTest.java deleted file mode 100644 index 13f86efee..000000000 --- a/id.server/src/test/at/gv/egovernment/moa/id/auth/builder/CreateXMLSignatureBuilderTest.java +++ /dev/null @@ -1,58 +0,0 @@ -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 CreateXMLSignatureBuilderTest(String name) { - super(name); - } - - public void testBuild() throws Exception { - String request = new CreateXMLSignatureRequestBuilder().build( - AuthenticationBlockAssertionBuilderTest.ASSERTION_SHOULD, - new String[] {TRANSFORMS_INFO}); - assertXmlEquals(REQUEST_SHOULD, request); - } -} diff --git a/id.server/src/test/at/gv/egovernment/moa/id/auth/builder/GetIdentityLinkFormBuilderTest.java b/id.server/src/test/at/gv/egovernment/moa/id/auth/builder/GetIdentityLinkFormBuilderTest.java deleted file mode 100644 index 9142a8e42..000000000 --- a/id.server/src/test/at/gv/egovernment/moa/id/auth/builder/GetIdentityLinkFormBuilderTest.java +++ /dev/null @@ -1,73 +0,0 @@ -package test.at.gv.egovernment.moa.id.auth.builder; - -import java.text.MessageFormat; - -import junit.framework.TestCase; - -import at.gv.egovernment.moa.id.auth.builder.CertInfoVerifyXMLSignatureRequestBuilder; -import at.gv.egovernment.moa.id.auth.builder.GetIdentityLinkFormBuilder; -import at.gv.egovernment.moa.id.auth.builder.InfoboxReadRequestBuilder; - -/** - * @author Paul Ivancsics - * @version $Id$ - */ -public class GetIdentityLinkFormBuilderTest extends TestCase { - private static String nl = "\n"; - public static String FORM = - "" + nl + - "" + nl + - "" + nl + - "Auslesen der Personenbindung" + nl + - "" + nl + - "" + nl + - "
" + nl + - " " + nl + - " " + nl + - " " + nl + - "
" + nl + - "
" + nl + - " " + nl + - " " + nl + - " " + nl + - "
" + nl + - "" + nl + - ""; - public static String BKU = - "http://localhost:3495/http-security-layer-request"; - - public void testBuild() throws Exception { - String xmlRequest = new InfoboxReadRequestBuilder().build(); - String dataURL = "https://1.2.3.4/auth/VerifyIdentityLink?MOASessionID=1234567"; - String infoRequest = new CertInfoVerifyXMLSignatureRequestBuilder().build(); - String infoDataURL = "https://1.2.3.4/auth/StartAuthentication?Target=gb&OA=https://oa.gv.at/"; - String form = new GetIdentityLinkFormBuilder().build(null, null, xmlRequest, dataURL, infoRequest, infoDataURL); - String formShould = MessageFormat.format( - FORM, new Object[] { BKU, xmlRequest, dataURL, infoRequest, infoDataURL }); - assertEquals(formShould, form); - } - public void testBuildCustomBKU() throws Exception { - String xmlRequest = new InfoboxReadRequestBuilder().build(); - String dataURL = "https://1.2.3.4/auth/AuthServlet/StartAuthentication?MOASessionID=1234567"; - String infoRequest = new CertInfoVerifyXMLSignatureRequestBuilder().build(); - String infoDataURL = "https://1.2.3.4/auth/StartAuthentication?Target=gb&OA=https://oa.gv.at/"; - String bkuURL = "http://bku.at/"; - String form = new GetIdentityLinkFormBuilder().build(null, bkuURL, xmlRequest, dataURL, infoRequest, infoDataURL); - String formShould = MessageFormat.format( - FORM, new Object[] { bkuURL, xmlRequest, dataURL, infoRequest, infoDataURL }); - assertEquals(formShould, form); - } - -} diff --git a/id.server/src/test/at/gv/egovernment/moa/id/auth/builder/InfoboxReadRequestBuilderTest.java b/id.server/src/test/at/gv/egovernment/moa/id/auth/builder/InfoboxReadRequestBuilderTest.java deleted file mode 100644 index b65fc9ecf..000000000 --- a/id.server/src/test/at/gv/egovernment/moa/id/auth/builder/InfoboxReadRequestBuilderTest.java +++ /dev/null @@ -1,29 +0,0 @@ -package test.at.gv.egovernment.moa.id.auth.builder; - -import org.w3c.dom.Document; -import test.at.gv.egovernment.moa.id.UnitTestCase; - -import at.gv.egovernment.moa.id.auth.builder.InfoboxReadRequestBuilder; -import at.gv.egovernment.moa.util.Constants; -import at.gv.egovernment.moa.util.DOMUtils; - -/** - * @author Paul Ivancsics - * @version $Id$ - */ -public class InfoboxReadRequestBuilderTest extends UnitTestCase implements Constants { - - public InfoboxReadRequestBuilderTest(String name) { - super(name); - } - - public void testBuild() throws Exception { - InfoboxReadRequestBuilder builder = new InfoboxReadRequestBuilder(); - String xmlBuilt = builder.build(); - Document docBuilt = DOMUtils.parseDocument(xmlBuilt, false, ALL_SCHEMA_LOCATIONS, null); - String xmlBuiltSerialized = DOMUtils.serializeNode(docBuilt); - // xmlShould was generated by Hot:Sign Tester - String xmlShould = "IdentityLink"; - assertXmlEquals(xmlShould, xmlBuiltSerialized); - } -} diff --git a/id.server/src/test/at/gv/egovernment/moa/id/auth/builder/PersonDataBuilderTest.java b/id.server/src/test/at/gv/egovernment/moa/id/auth/builder/PersonDataBuilderTest.java deleted file mode 100644 index 504679fd5..000000000 --- a/id.server/src/test/at/gv/egovernment/moa/id/auth/builder/PersonDataBuilderTest.java +++ /dev/null @@ -1,51 +0,0 @@ -package test.at.gv.egovernment.moa.id.auth.builder; - -import at.gv.egovernment.moa.id.auth.builder.PersonDataBuilder; -import at.gv.egovernment.moa.id.auth.data.IdentityLink; -import at.gv.egovernment.moa.id.auth.parser.InfoboxReadResponseParser; -import at.gv.egovernment.moa.util.Constants; - -import test.at.gv.egovernment.moa.id.UnitTestCase; - -/** - * @author Paul Ivancsics - * @version $Id$ - */ -public class PersonDataBuilderTest extends UnitTestCase implements Constants { - - /** - * Constructor for PersonDataBuilderTest. - */ - public PersonDataBuilderTest(String arg) { - super(arg); - } - public void testBuild() throws Exception { - String xmlInfoboxReadResponse = readFile("data/test/xmldata/testperson1/InfoboxReadResponse.xml"); - IdentityLink il = new InfoboxReadResponseParser(xmlInfoboxReadResponse).parseIdentityLink(); - String xmlPersonData = new PersonDataBuilder().build(il, true); - String xmlPersonDataShould = "123456789012http://reference.e-government.gv.at/names/persondata/20020228#zmr-zahlHermannMuster1968-10-22"; - assertPersonDataEquals(xmlPersonDataShould, xmlPersonData); - } - public void testBuildNoZMRZahl() throws Exception { - String xmlInfoboxReadResponse = readFile("data/test/xmldata/testperson1/InfoboxReadResponse.xml"); - IdentityLink il = new InfoboxReadResponseParser(xmlInfoboxReadResponse).parseIdentityLink(); - String xmlPersonData = new PersonDataBuilder().build(il, false); - String xmlPersonDataShould = XML_DECL + "HermannMuster1968-10-22"; - assertPersonDataEquals(xmlPersonDataShould, xmlPersonData); - } - private void assertPersonDataEquals(String s1, String s2) throws Exception { - String ss1 = insertPrNS(s1); - String ss2 = insertPrNS(s2); - assertXmlEquals(ss1, ss2); - } - private String insertPrNS(String xmlPersonData) { - int startNS = xmlPersonData.indexOf("Person") + "Person".length() + 1; - String s = - xmlPersonData.substring(0, startNS) + - "xmlns:pr=\"" + PD_NS_URI + "\" " + - "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " + - xmlPersonData.substring(startNS); - return s; - } - -} diff --git a/id.server/src/test/at/gv/egovernment/moa/id/auth/builder/SAMLArtifactBuilderTest.java b/id.server/src/test/at/gv/egovernment/moa/id/auth/builder/SAMLArtifactBuilderTest.java deleted file mode 100644 index 3ec73ee4c..000000000 --- a/id.server/src/test/at/gv/egovernment/moa/id/auth/builder/SAMLArtifactBuilderTest.java +++ /dev/null @@ -1,52 +0,0 @@ -package test.at.gv.egovernment.moa.id.auth.builder; - -import at.gv.egovernment.moa.id.BuildException; -import at.gv.egovernment.moa.id.auth.builder.SAMLArtifactBuilder; -import at.gv.egovernment.moa.util.Base64Utils; - -import test.at.gv.egovernment.moa.id.UnitTestCase; - -/** - * @author Paul Ivancsics - * @version $Id$ - */ -public class SAMLArtifactBuilderTest extends UnitTestCase { - - private static final String AUTH_URL = "https://moa.gv.at/auth/"; - private static final String SESSION_ID_1 = "123456"; - private static final String SESSION_ID_2 = "123457"; - private static final String SESSION_ID_3 = "1234567"; - - private SAMLArtifactBuilder builder; - private byte[] artifact1; - private byte[] artifact2; - private byte[] artifact3; - - public SAMLArtifactBuilderTest(String name) { - super(name); - } - protected void setUp() throws Exception { - builder = new SAMLArtifactBuilder(); - artifact1 = Base64Utils.decode(builder.build(AUTH_URL, SESSION_ID_1), false); - artifact2 = Base64Utils.decode(builder.build(AUTH_URL, SESSION_ID_2), false); - artifact3 = Base64Utils.decode(builder.build(AUTH_URL, SESSION_ID_3), false); - } - - public void testBuildArtifactLength() throws BuildException { - assertEquals(42, artifact1.length); - assertEquals(42, artifact2.length); - assertEquals(42, artifact3.length); - } - public void testBuildSameArtifact() throws Exception { - byte[] artifact1Clone = Base64Utils.decode(builder.build(AUTH_URL, SESSION_ID_1), false); - assertEquals(new String(artifact1), new String(artifact1Clone)); - } - public void testBuildDifferentArtifacts() throws BuildException { - String msg = "SAML Artifacts should be different"; - assertFalse(msg, new String(artifact1).equals(new String(artifact2))); - assertFalse(msg, new String(artifact1).equals(new String(artifact3))); - assertFalse(msg, new String(artifact3).equals(new String(artifact2))); - } - - -} diff --git a/id.server/src/test/at/gv/egovernment/moa/id/auth/builder/VerifyXMLSignatureRequestBuilderTest.java b/id.server/src/test/at/gv/egovernment/moa/id/auth/builder/VerifyXMLSignatureRequestBuilderTest.java deleted file mode 100644 index 5b3bb5906..000000000 --- a/id.server/src/test/at/gv/egovernment/moa/id/auth/builder/VerifyXMLSignatureRequestBuilderTest.java +++ /dev/null @@ -1,93 +0,0 @@ -package test.at.gv.egovernment.moa.id.auth.builder; - -import java.io.FileInputStream; -import java.io.RandomAccessFile; - -import org.w3c.dom.Element; -import test.at.gv.egovernment.moa.id.auth.invoke.MOASPSSTestCase; - -import at.gv.egovernment.moa.id.auth.builder.VerifyXMLSignatureRequestBuilder; -import at.gv.egovernment.moa.id.auth.data.CreateXMLSignatureResponse; -import at.gv.egovernment.moa.id.auth.data.IdentityLink; -import at.gv.egovernment.moa.id.auth.parser.CreateXMLSignatureResponseParser; -import at.gv.egovernment.moa.id.auth.parser.InfoboxReadResponseParser; -import at.gv.egovernment.moa.id.auth.invoke.SignatureVerificationInvoker; -import at.gv.egovernment.moa.id.config.ConfigurationProvider; -import at.gv.egovernment.moa.id.config.auth.AuthConfigurationProvider; - - - -/** - * Test case for the signature verification web service. - * - * This test requires a running SignatureVerification web service. - * - * @author Stefan Knirsch - * @version $Id$ - */ -public class VerifyXMLSignatureRequestBuilderTest extends MOASPSSTestCase { - - - private SignatureVerificationInvoker caller; - - public VerifyXMLSignatureRequestBuilderTest(String name) { - super(name); - } - - public void setUp() { - System.setProperty( - ConfigurationProvider.CONFIG_PROPERTY_NAME, - "data/test/conf/ConfigurationTest.xml"); - caller = new SignatureVerificationInvoker(); - } - - public void testVerifyXMLSignatureRequestBuilderIdentityLink() throws Exception { - - RandomAccessFile infoBox = new RandomAccessFile( - "data/test/xmldata/testperson1/InfoboxReadResponse.xml","r"); - byte[] b = new byte[(int) infoBox.length()]; - infoBox.read(b); - infoBox.close(); - String xmlInfoboxReadResponse = new String(b, "UTF-8"); - - - RandomAccessFile vr = new RandomAccessFile( - "data/test/xmldata/standard/VerifyXMLSignatureRequestIdentityLink.xml","r"); - b = new byte[(int) vr.length()]; - vr.read(b); - vr.close(); - String xmlResponse = new String(b, "UTF-8"); - - InfoboxReadResponseParser irrp = new InfoboxReadResponseParser(xmlInfoboxReadResponse); - IdentityLink idl = irrp.parseIdentityLink(); - VerifyXMLSignatureRequestBuilder vsrb = new VerifyXMLSignatureRequestBuilder(); - AuthConfigurationProvider authConf = AuthConfigurationProvider.getInstance(); - - Element requestBuild = vsrb.build(idl, authConf.getMoaSpIdentityLinkTrustProfileID()); - - assertXmlEquals(requestBuild, xmlResponse); - - } - - public void testVerifyXMLSignature2() throws Exception { - - RandomAccessFile s = new RandomAccessFile("data/test/xmldata/standard/CreateXMLSignatureResponse.xml","r"); - byte[] b = new byte[(int) s.length()]; - s.read(b); - s.close(); - String xmlCreateXMLSignatureResponse = new String(b, "UTF-8"); - - CreateXMLSignatureResponseParser cXMLsrp = new CreateXMLSignatureResponseParser(xmlCreateXMLSignatureResponse); - CreateXMLSignatureResponse csr = cXMLsrp.parseResponse(); - - VerifyXMLSignatureRequestBuilder vsrb = new VerifyXMLSignatureRequestBuilder(); - - AuthConfigurationProvider authConf = AuthConfigurationProvider.getInstance(); - - Element request = vsrb.build(csr, authConf.getMoaSpAuthBlockVerifyTransformsInfoIDs(), authConf.getMoaSpIdentityLinkTrustProfileID()); - - // check the result - assertXmlEquals(request, new FileInputStream("data/test/xmldata/standard/VerifyXMLSignatureRequestCreateXML.xml")); - - } - } diff --git a/id.server/src/test/at/gv/egovernment/moa/id/auth/invoke/MOASPSSTestCase.java b/id.server/src/test/at/gv/egovernment/moa/id/auth/invoke/MOASPSSTestCase.java deleted file mode 100644 index 7ae6f70ef..000000000 --- a/id.server/src/test/at/gv/egovernment/moa/id/auth/invoke/MOASPSSTestCase.java +++ /dev/null @@ -1,38 +0,0 @@ -package test.at.gv.egovernment.moa.id.auth.invoke; - -import java.security.Security; - -import test.at.gv.egovernment.moa.id.UnitTestCase; - -/** - * Base class for end-to-end tests of MOA web-services. - * - * Initializes the test system and provides some properties. - * - * @author Patrick Peck - * @version $Id$ - */ -public class MOASPSSTestCase extends UnitTestCase { - - public MOASPSSTestCase(String name) { - super(name); - } - - - protected void setupSSL() { - System.setProperty("javax.net.debug", "all"); - Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); - System.setProperty( - "java.protocol.handler.pkgs", - "com.sun.net.ssl.internal.www.protocol"); - System.setProperty( - "javax.net.ssl.keyStore", - "data/test/security/client.keystore"); - System.setProperty("javax.net.ssl.keyStorePassword", "changeit"); - System.setProperty( - "javax.net.ssl.trustStore", - "data/test/security/client.keystore"); - System.setProperty("javax.net.ssl.trustStorePassword", "changeit"); - } - -} diff --git a/id.server/src/test/at/gv/egovernment/moa/id/auth/invoke/SignatureVerificationTest.java b/id.server/src/test/at/gv/egovernment/moa/id/auth/invoke/SignatureVerificationTest.java deleted file mode 100644 index e56dcde91..000000000 --- a/id.server/src/test/at/gv/egovernment/moa/id/auth/invoke/SignatureVerificationTest.java +++ /dev/null @@ -1,166 +0,0 @@ -package test.at.gv.egovernment.moa.id.auth.invoke; - -import java.io.RandomAccessFile; - -import org.w3c.dom.Element; - -import at.gv.egovernment.moa.id.auth.builder.VerifyXMLSignatureRequestBuilder; -import at.gv.egovernment.moa.id.auth.data.CreateXMLSignatureResponse; -import at.gv.egovernment.moa.id.auth.data.IdentityLink; -import at.gv.egovernment.moa.id.auth.data.VerifyXMLSignatureResponse; -import at.gv.egovernment.moa.id.auth.parser.CreateXMLSignatureResponseParser; -import at.gv.egovernment.moa.id.auth.parser.InfoboxReadResponseParser; -import at.gv.egovernment.moa.id.auth.parser.VerifyXMLSignatureResponseParser; -import at.gv.egovernment.moa.id.auth.invoke.SignatureVerificationInvoker; -import at.gv.egovernment.moa.id.auth.validator.VerifyXMLSignatureResponseValidator; -import at.gv.egovernment.moa.id.config.ConfigurationProvider; -import at.gv.egovernment.moa.id.config.auth.AuthConfigurationProvider; -import at.gv.egovernment.moa.util.DOMUtils; - - - -/** - * Test case for the signature verification web service. - * - * This test requires a running SignatureVerification web service. - * - * @author Patrick Peck - * @author Fatemeh Philippi - * @version $Id$ - */ -public class SignatureVerificationTest extends MOASPSSTestCase { - - - private SignatureVerificationInvoker caller; - - public SignatureVerificationTest(String name) { - super(name); - } - - public void setUp() { -System.setProperty( - ConfigurationProvider.CONFIG_PROPERTY_NAME, - "data/test/conf/ConfigurationTest.xml"); - caller = new SignatureVerificationInvoker(); - } - -/* public void testVerifyCMSSignature() throws Exception { - Element request = - parseXml("data/test/xml/VCSQ000.xml").getDocumentElement(); - Element result; - - // call the service - result = caller.verifyXMLSignature(request); - - // check the result - assertEquals("VerifyCMSSignatureResponse", result.getTagName()); - }*/ - - public void testVerifyXMLSignature1() throws Exception { - - //Momentan zeigt die Konfiguration als Endpunkt aus localhost:8081 zum - //Protokollieren per TCPMon... der ECHT Endpunkt ist 10.16.46.108:8080 - RandomAccessFile s = - new RandomAccessFile( - "data/test/xmldata/testperson1/InfoboxReadResponse.xml","r"); - byte[] b = new byte[(int) s.length()]; - s.read(b); - String xmlInfoboxReadResponse =new String(b,"UTF8"); - - InfoboxReadResponseParser irrp = new InfoboxReadResponseParser(xmlInfoboxReadResponse); - IdentityLink idl = irrp.parseIdentityLink(); - VerifyXMLSignatureRequestBuilder vsrb = new VerifyXMLSignatureRequestBuilder(); - - AuthConfigurationProvider authConf = AuthConfigurationProvider.getInstance(); - - Element request = vsrb.build(idl, authConf.getMoaSpIdentityLinkTrustProfileID()); - s =new RandomAccessFile("D://PatricksVerifyXMLSignatureRequestWithInfoboxReadResponse.xml","rw"); - s.write(DOMUtils.serializeNode(request).getBytes("UTF-8")); - s.close(); -// Element request = DOMUtils.parseDocument(vsrb.build(xmlInfoboxReadResponse,"TrustProfile1"),false,null,null).getDocumentElement(); -// Element request = DOMUtils.parseDocument(xmlInfoboxReadResponse,false,null,null).getDocumentElement(); -// call the service - Element response = caller.verifyXMLSignature(request); - VerifyXMLSignatureResponseParser vParser = new VerifyXMLSignatureResponseParser(response); - VerifyXMLSignatureResponse vData = vParser.parseData(); - VerifyXMLSignatureResponseValidator vValidate = VerifyXMLSignatureResponseValidator.getInstance(); - vValidate.validate(vData, authConf.getIdentityLinkX509SubjectNames(), VerifyXMLSignatureResponseValidator.CHECK_IDENTITY_LINK); - vValidate.validateCertificate(vData,idl); - - // check the result - assertXmlEquals(response, request); - - } - - public void testVerifyXMLSignature2() throws Exception { - // Prüft den 2. Aufruf mit dem CreateXMLSIgnatureResponse als Parameter - //Momentan zeigt die Konfiguration als Endpunkt aus localhost:8081 zum - //Protokollieren per TCPMon... der ECHT Endpunkt ist 10.16.46.108:8080 - RandomAccessFile s = - new RandomAccessFile( - "data/test/xmldata/standard/CreateXMLSignatureResponse.xml","r"); - byte[] b = new byte[(int) s.length()]; - s.read(b); - String xmlCreateXMLSignatureResponse = new String(b, "UTF8"); - - CreateXMLSignatureResponseParser cXMLsrp = new CreateXMLSignatureResponseParser(xmlCreateXMLSignatureResponse); -// CreateXMLSignatureResponseParser cXMLsrp = new CreateXMLSignatureResponseParser(xmlCreateXMLSignatureResponse); - CreateXMLSignatureResponse csr = cXMLsrp.parseResponse(); - - VerifyXMLSignatureRequestBuilder vsrb = new VerifyXMLSignatureRequestBuilder(); - - AuthConfigurationProvider authConf = AuthConfigurationProvider.getInstance(); - - Element request = vsrb.build(csr, authConf.getMoaSpAuthBlockVerifyTransformsInfoIDs(), authConf.getMoaSpIdentityLinkTrustProfileID()); - // Element request = DOMUtils.parseDocument(vsrb.build(xmlInfoboxReadResponse,"TrustProfile1"),false,null,null).getDocumentElement(); -// Element request = DOMUtils.parseDocument(xmlInfoboxReadResponse,false,null,null).getDocumentElement(); - Element result; -/*s =new RandomAccessFile("D://PatricksVerifyXMLSignatureRequestWithAuthBlock.xml","rw"); - s.write(DOMUtils.serializeNode(request).getBytes("UTF-8")); - s.close();*/ - // call the service - result = caller.verifyXMLSignature(request); - // check the result - assertEquals("VerifyXMLSignatureResponse", result.getTagName()); - - } - - - public void testParseCreateXMLSignatureResponse() throws Exception { - - //Später soll die Datei direkt vom Server geholt werden... - - RandomAccessFile s = - new RandomAccessFile( - "data/test/xmldata/standard/CreateXMLSignatureResponse.xml", - - "r"); - byte[] b = new byte[(int) s.length()]; - s.read(b); - String xmlCreateXMLSignatureResponse = new String(b, "UTF-8"); - - CreateXMLSignatureResponseParser cXMLsrp = new CreateXMLSignatureResponseParser(xmlCreateXMLSignatureResponse); - CreateXMLSignatureResponse csr = cXMLsrp.parseResponse(); - - } - - public void testParseVerifyXMLSignatureResponse() throws Exception { - - //Später soll die Datei direkt vom Server geholt werden... - - RandomAccessFile s = - new RandomAccessFile( - "data/test/xmldata/standard/VerifyXMLSignaterResponse.xml", - - "r"); - byte[] b = new byte[(int) s.length()]; - s.read(b); - String xmlVerifyXMLSignatureResponse = new String(b, "UTF-8"); - - VerifyXMLSignatureResponseParser vXMLsrp = new VerifyXMLSignatureResponseParser(xmlVerifyXMLSignatureResponse); - VerifyXMLSignatureResponse vsr = vXMLsrp.parseData(); - - } - - - } diff --git a/id.server/src/test/at/gv/egovernment/moa/id/auth/parser/AllTests.java b/id.server/src/test/at/gv/egovernment/moa/id/auth/parser/AllTests.java deleted file mode 100644 index 84f5110b0..000000000 --- a/id.server/src/test/at/gv/egovernment/moa/id/auth/parser/AllTests.java +++ /dev/null @@ -1,29 +0,0 @@ -package test.at.gv.egovernment.moa.id.auth.parser; - -import junit.awtui.TestRunner; -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * @author Paul Ivancsics - * @version $Id$ - */ -public class AllTests { - - public static Test suite() { - TestSuite suite = new TestSuite(); - - suite.addTestSuite(IdentityLinkAssertionParserTest.class); - suite.addTestSuite(SAMLArtifactParserTest.class); - - return suite; - } - - public static void main(String[] args) { - try { - TestRunner.run(AllTests.class); - } catch (Exception e) { - e.printStackTrace(); - } - } -} diff --git a/id.server/src/test/at/gv/egovernment/moa/id/auth/parser/IdentityLinkAssertionParserTest.java b/id.server/src/test/at/gv/egovernment/moa/id/auth/parser/IdentityLinkAssertionParserTest.java deleted file mode 100644 index 77eb360bc..000000000 --- a/id.server/src/test/at/gv/egovernment/moa/id/auth/parser/IdentityLinkAssertionParserTest.java +++ /dev/null @@ -1,137 +0,0 @@ -package test.at.gv.egovernment.moa.id.auth.parser; - -import iaik.security.rsa.RSAPublicKey; - -import java.io.FileOutputStream; -import java.io.RandomAccessFile; -import java.security.PublicKey; - -import org.w3c.dom.Document; - -import test.at.gv.egovernment.moa.id.UnitTestCase; - -import at.gv.egovernment.moa.id.auth.builder.VerifyXMLSignatureRequestBuilder; -import at.gv.egovernment.moa.id.auth.data.IdentityLink; -import at.gv.egovernment.moa.id.auth.parser.ECDSAKeyValueConverter; -import at.gv.egovernment.moa.id.auth.parser.IdentityLinkAssertionParser; -import at.gv.egovernment.moa.id.auth.parser.InfoboxReadResponseParser; -import at.gv.egovernment.moa.id.auth.validator.IdentityLinkValidator; -import at.gv.egovernment.moa.util.Constants; -import at.gv.egovernment.moa.util.DOMUtils; - -/** - * @author Paul Ivancsics - * @version $Id$ - */ -public class IdentityLinkAssertionParserTest extends UnitTestCase { - - IdentityLinkAssertionParser ilap; - - public IdentityLinkAssertionParserTest(String name) { - super(name); - } - - public void setUp() { - try { - RandomAccessFile s = - new RandomAccessFile( - "data/test/xmldata/testperson1/InfoboxReadResponse.xml", - "r"); - byte[] b = new byte[(int) s.length()]; - s.read(b); - String xmlInfoboxReadResponse = new String(b, "UTF-8"); - - InfoboxReadResponseParser irrp = new InfoboxReadResponseParser(xmlInfoboxReadResponse); - ilap = new IdentityLinkAssertionParser(irrp.parseSAMLAssertion()); - } - catch (Exception e) { - e.printStackTrace(); - } - } - - public void testParseIdentityLink() throws Exception { - IdentityLink idl = ilap.parseIdentityLink(); - System.out.println(idl.getGivenName()); - System.out.println(idl.getFamilyName()); - System.out.println(idl.getDateOfBirth()); - System.out.println(idl.getIdentificationValue()); - - VerifyXMLSignatureRequestBuilder vx = new VerifyXMLSignatureRequestBuilder(); - - // Element zurück bekommen: vx.build(idl.getSamlAssertion()); - - IdentityLinkValidator idVali = IdentityLinkValidator.getInstance(); - idVali.validate(idl); - - } - - public void testParseIdentityLinkECC() throws Exception { - RandomAccessFile s = - new RandomAccessFile( - "data/test/xmldata/IL.ResponseToRequest.01.ECDSA.xml", - "r"); - byte[] b = new byte[(int) s.length()]; - s.read(b); - String xmlInfoboxReadResponse = new String(b); - InfoboxReadResponseParser irrp = new InfoboxReadResponseParser(xmlInfoboxReadResponse); - String SAML = irrp.parseSAMLAssertion(); - ilap = new IdentityLinkAssertionParser(SAML); - IdentityLink idl = ilap.parseIdentityLink(); - System.out.println(idl.getGivenName()); - System.out.println(idl.getFamilyName()); - System.out.println(idl.getDateOfBirth()); - System.out.println(idl.getIdentificationValue()); - - VerifyXMLSignatureRequestBuilder vx = new VerifyXMLSignatureRequestBuilder(); - - // Element zurück bekommen: vx.build(idl.getSamlAssertion()); - - IdentityLinkValidator idVali = IdentityLinkValidator.getInstance(); - idVali.validate(idl); - - } - - public void testRSAPublicKeys() throws Exception { - if (ilap.getPublicKeys()[0].getClass().getName().equals("iaik.security.rsa.RSAPublicKey")) - { - - for (int i = 0; i < ilap.getPublicKeys().length; i++) { - RSAPublicKey result = (RSAPublicKey)ilap.getPublicKeys()[i]; - System.out.println("RSA Public Key No" + i); - System.out.println("Modulus: " + result.getModulus()); - System.out.println("Exponent: " + result.getPublicExponent()); - } - - } - } - - public void testECDSAPublicKeys() throws Exception { - - RandomAccessFile s = - new RandomAccessFile( - "data/test/xmldata/ECDSAKeyExample.xml", - "r"); - byte[] b = new byte[(int) s.length()]; - s.read(b); - String ecdsaKey = new String(b, "UTF-8"); - Document e = DOMUtils.parseDocument(ecdsaKey,true,Constants.ALL_SCHEMA_LOCATIONS, null); - PublicKey p = ECDSAKeyValueConverter.element2ECDSAPublicKey(e.getDocumentElement()); - - } - - - public void testDsigCertificates() throws Exception { - - String[] result = ilap.getCertificates(); - for (int i = 0; i < result.length; i++) { - - System.out.println("DSIG Certificate Length: " + result[i].length() + " No" + i + "\n" + result[i]); - FileOutputStream raf = new FileOutputStream("data/test/certs/cert" + i + ".cer"); - raf.write(result[i].getBytes()); - raf.flush(); - raf.close(); - } - - } - -} diff --git a/id.server/src/test/at/gv/egovernment/moa/id/auth/parser/InfoboxReadResponseParserTest.java b/id.server/src/test/at/gv/egovernment/moa/id/auth/parser/InfoboxReadResponseParserTest.java deleted file mode 100644 index 9a878be2c..000000000 --- a/id.server/src/test/at/gv/egovernment/moa/id/auth/parser/InfoboxReadResponseParserTest.java +++ /dev/null @@ -1,67 +0,0 @@ -package test.at.gv.egovernment.moa.id.auth.parser; - -import java.io.RandomAccessFile; - -import test.at.gv.egovernment.moa.id.UnitTestCase; - -import at.gv.egovernment.moa.id.auth.data.IdentityLink; -import at.gv.egovernment.moa.id.auth.parser.IdentityLinkAssertionParser; -import at.gv.egovernment.moa.id.auth.parser.InfoboxReadResponseParser; - -/** - * @author Paul Ivancsics - * @version $Id$ - */ -public class InfoboxReadResponseParserTest extends UnitTestCase { - - IdentityLinkAssertionParser ilap; - - public InfoboxReadResponseParserTest(String name) { - super(name); - } - - public void setUp() { - } - - public void testParseInfoboxReadResponse() throws Exception { - RandomAccessFile s = - new RandomAccessFile( - "data/test/xmldata/testperson1/InfoboxReadResponse.xml", - "r"); - byte[] b = new byte[(int) s.length()]; - s.read(b); - String xmlInfoboxReadResponse = new String(b, "UTF-8"); - - InfoboxReadResponseParser irrp = new InfoboxReadResponseParser(xmlInfoboxReadResponse); - ilap = new IdentityLinkAssertionParser(irrp.parseSAMLAssertion()); - - IdentityLink idl = ilap.parseIdentityLink(); - System.out.println(idl.getGivenName()); - System.out.println(idl.getFamilyName()); - System.out.println(idl.getDateOfBirth()); - System.out.println(idl.getIdentificationValue()); - - } - - public void testParseInfoboxReadResponseError() throws Exception { - RandomAccessFile s = - new RandomAccessFile( - "data/test/xmldata/ErrorResponse.xml", - "r"); - byte[] b = new byte[(int) s.length()]; - s.read(b); - String xmlInfoboxReadResponse = new String(b, "UTF-8"); - - InfoboxReadResponseParser irrp = new InfoboxReadResponseParser(xmlInfoboxReadResponse); - ilap = new IdentityLinkAssertionParser(irrp.parseSAMLAssertion()); - - IdentityLink idl = ilap.parseIdentityLink(); - System.out.println(idl.getGivenName()); - System.out.println(idl.getFamilyName()); - System.out.println(idl.getDateOfBirth()); - System.out.println(idl.getIdentificationValue()); - - } - - -} diff --git a/id.server/src/test/at/gv/egovernment/moa/id/auth/parser/SAMLArtifactParserTest.java b/id.server/src/test/at/gv/egovernment/moa/id/auth/parser/SAMLArtifactParserTest.java deleted file mode 100644 index 992e799bd..000000000 --- a/id.server/src/test/at/gv/egovernment/moa/id/auth/parser/SAMLArtifactParserTest.java +++ /dev/null @@ -1,55 +0,0 @@ -package test.at.gv.egovernment.moa.id.auth.parser; - -import at.gv.egovernment.moa.id.auth.builder.SAMLArtifactBuilder; -import at.gv.egovernment.moa.id.auth.parser.SAMLArtifactParser; -import at.gv.egovernment.moa.id.util.Random; -import test.at.gv.egovernment.moa.id.UnitTestCase; - -/* - * @author Paul Ivancsics - * @version $Id$ - */ -public class SAMLArtifactParserTest extends UnitTestCase { - - private static String URL1 = "http://moa.gv.at/auth"; - private static String URL2 = "https://moa.gv.at/auth"; - - public SAMLArtifactParserTest(String name) { - super(name); - } - - public void testParseTypeCode() throws Exception { - String sessionID = Random.nextRandom(); - String samlArtifact = new SAMLArtifactBuilder().build(URL1, sessionID); - byte[] typeCode = new SAMLArtifactParser(samlArtifact).parseTypeCode(); - assertEquals(typeCode[0], 0); - assertEquals(typeCode[1], 1); - } - public void testParseAssertionHandleSameSessionID() throws Exception { - // SAML artifacts for different authURL's but same sessionID MUST give same assertion handle - String sessionID = Random.nextRandom(); - String samlArtifact1 = new SAMLArtifactBuilder().build(URL1, sessionID); - String samlArtifact2 = new SAMLArtifactBuilder().build(URL2, sessionID); - String assertionHandle1 = new SAMLArtifactParser(samlArtifact1).parseAssertionHandle(); - String assertionHandle2 = new SAMLArtifactParser(samlArtifact2).parseAssertionHandle(); - assertEquals(assertionHandle1, assertionHandle2); - } - public void testParseAssertionHandleSameURL() throws Exception { - // SAML artifacts for same authURL but different sessionID's MUST give different assertion handles - String sessionID1 = Random.nextRandom(); - String sessionID2 = Random.nextRandom(); - String samlArtifact1 = new SAMLArtifactBuilder().build(URL1, sessionID1); - String samlArtifact2 = new SAMLArtifactBuilder().build(URL1, sessionID2); - String assertionHandle1 = new SAMLArtifactParser(samlArtifact1).parseAssertionHandle(); - String assertionHandle2 = new SAMLArtifactParser(samlArtifact2).parseAssertionHandle(); - assertFalse(assertionHandle1.equals(assertionHandle2)); - } - public void testParseAssertionHandleSameSAMLArtifact() throws Exception { - // SAML artifact parsed twice MUST give same assertion handle each time - String sessionID = Random.nextRandom(); - String samlArtifact = new SAMLArtifactBuilder().build(URL1, sessionID); - String assertionHandle1 = new SAMLArtifactParser(samlArtifact).parseAssertionHandle(); - String assertionHandle2 = new SAMLArtifactParser(samlArtifact).parseAssertionHandle(); - assertEquals(assertionHandle1, assertionHandle2); - } -} diff --git a/id.server/src/test/at/gv/egovernment/moa/id/auth/servlet/GetAuthenticationDataServiceTest.java b/id.server/src/test/at/gv/egovernment/moa/id/auth/servlet/GetAuthenticationDataServiceTest.java deleted file mode 100644 index c78651fdb..000000000 --- a/id.server/src/test/at/gv/egovernment/moa/id/auth/servlet/GetAuthenticationDataServiceTest.java +++ /dev/null @@ -1,91 +0,0 @@ -package test.at.gv.egovernment.moa.id.auth.servlet; - -import org.w3c.dom.Element; - -import test.at.gv.egovernment.moa.id.UnitTestCase; - -import at.gv.egovernment.moa.id.auth.servlet.GetAuthenticationDataService; -import at.gv.egovernment.moa.util.Constants; -import at.gv.egovernment.moa.util.DOMUtils; -import at.gv.egovernment.moa.util.XPathUtils; - -/** - * Test case instantiates GetAuthenticationDataService and calls the Request() method. - * It DOES NOT call the web service via Axis. - * - * @author Paul Ivancsics - * @version $Id$ - */ -public class GetAuthenticationDataServiceTest extends UnitTestCase implements Constants { - - private GetAuthenticationDataService service; - - public GetAuthenticationDataServiceTest(String arg0) { - super(arg0); - } - protected void setUp() throws Exception { - service = new GetAuthenticationDataService(); - } - - public void testService2Requests() throws Exception { - String requestString = - "" + - "" + - "123" + - ""; - Element request = DOMUtils.parseDocument(requestString, false, ALL_SCHEMA_LOCATIONS, null).getDocumentElement(); - Element response = service.Request(new Element[] {request, request})[0]; - assertStatus(response, "samlp:Requester", "samlp:TooManyResponses"); - } - public void testServiceNoSAMLArtifact() throws Exception { - String requestString = - "" + - "" + - "123" + - ""; - Element request = DOMUtils.parseDocument(requestString, false, ALL_SCHEMA_LOCATIONS, null).getDocumentElement(); - Element response = service.Request(new Element[] {request})[0]; - assertStatus(response, "samlp:Requester", null); - } - public void testService2SAMLArtifacts() throws Exception { - String requestString = - "" + - "" + - "123" + - "456" + - ""; - Element request = DOMUtils.parseDocument(requestString, false, ALL_SCHEMA_LOCATIONS, null).getDocumentElement(); - Element response = service.Request(new Element[] {request})[0]; - assertStatus(response, "samlp:Requester", "samlp:TooManyResponses"); - } - public void testServiceWrongFormat() throws Exception { - String requestString = - "" + - "" + - ""; - Element request = DOMUtils.parseDocument(requestString, false, ALL_SCHEMA_LOCATIONS, null).getDocumentElement(); - Element response = service.Request(new Element[] {request})[0]; - assertStatus(response, "samlp:Requester", null); - } - public void testServiceWrongSAMLArtifact() throws Exception { - String requestString = - "" + - "" + - "WRONGARTIFACT" + - ""; - Element request = DOMUtils.parseDocument(requestString, false, ALL_SCHEMA_LOCATIONS, null).getDocumentElement(); - Element response = service.Request(new Element[] {request})[0]; - assertStatus(response, "samlp:Requester", "samlp:ResourceNotRecognized"); - } - private void assertStatus(Element response, String statusCodeShould, String subStatusCodeShould) throws Exception { - Element statusCodeNode = (Element)XPathUtils.selectSingleNode(response, "//samlp:StatusCode"); - String statusCode = statusCodeNode.getAttribute("Value"); - Element subStatusCodeNode = (Element)XPathUtils.selectSingleNode(statusCodeNode, "//samlp:StatusCode/samlp:StatusCode"); - String subStatusCode = subStatusCodeNode == null ? null : subStatusCodeNode.getAttribute("Value"); - System.out.println(statusCode + subStatusCode); - assertEquals(statusCodeShould, statusCode); - assertEquals(subStatusCodeShould, subStatusCode); - } - - -} -- cgit v1.2.3