diff options
Diffstat (limited to 'id/server/idserverlib/src/test/java/test/abnahme/AbnahmeTestCase.java')
-rw-r--r-- | id/server/idserverlib/src/test/java/test/abnahme/AbnahmeTestCase.java | 380 |
1 files changed, 190 insertions, 190 deletions
diff --git a/id/server/idserverlib/src/test/java/test/abnahme/AbnahmeTestCase.java b/id/server/idserverlib/src/test/java/test/abnahme/AbnahmeTestCase.java index 8e38c7673..7caa6dd8c 100644 --- a/id/server/idserverlib/src/test/java/test/abnahme/AbnahmeTestCase.java +++ b/id/server/idserverlib/src/test/java/test/abnahme/AbnahmeTestCase.java @@ -1,190 +1,190 @@ -/* - * Copyright 2003 Federal Chancellery Austria - * MOA-ID has been developed in a cooperation between BRZ, the Federal - * Chancellery Austria - ICT staff unit, and Graz University of Technology. - * - * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * http://www.osor.eu/eupl/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - * - * This product combines work with different licenses. See the "NOTICE" text - * file for details on the various modules and licenses. - * The "NOTICE" text file is part of the distribution. Any derivative works - * that you distribute must include a readable copy of the "NOTICE" text file. - */ - - -package test.abnahme; - -import java.io.File; -import java.io.IOException; -import java.io.RandomAccessFile; - -import test.MOAIDTestCase; - -import at.gv.egovernment.moa.id.MOAIDException; -import at.gv.egovernment.moa.id.auth.AuthenticationServer; -import at.gv.egovernment.moa.id.config.ConfigurationProvider; -import at.gv.egovernment.moa.id.config.auth.AuthConfigurationProvider; -import at.gv.egovernment.moa.id.data.AuthenticationData; - -/** - * Base class for MOA ID test cases. - * - * Provides some utility functions. - * - * @author Stefan Knirsch - * @version $Id$ - */ -public class AbnahmeTestCase extends MOAIDTestCase { - - protected static final String TESTDATA_ROOT = "data/abnahme-test/"; - protected static final String TESTDATA_XMLDATA = "data/abnahme-test/xmldata/"; - protected static final String AUTH_ENDPOINT = "http://localhost:8080/moa-id-auth/"; - protected AuthenticationServer server; - - /** - * Constructor for MOATestCase. - * @param arg0 - */ - public AbnahmeTestCase(String name) { - super(name); - } - /** - * Set up a transaction context with a test configuration. - */ - protected void setUp() throws Exception { - - System.out.print("--------S-T-A-R-T----V-O-N----"); - System.out.print(getName().toUpperCase().substring(4,getName().length())); - System.out.print("-----------------------------\n"); - - // Set moa.spss.server.configuration property - System.setProperty("moa.spss.server.configuration",TESTDATA_ROOT + "conf/moa/ConfigurationTest.xml"); - - // Set moa.id.configuration property - String pathname = findXmldata("Configuration.xml"); - System.setProperty(ConfigurationProvider.CONFIG_PROPERTY_NAME, pathname); - System.out.println("Konfiguration " + pathname); - AuthConfigurationProvider.reload(); - - server = AuthenticationServer.getInstance(); - } - /** Test case z.B. "A153" */ - protected String getID() { - return getName().toUpperCase().substring(4,getName().length()); - } - /** Test group z.B. "A100" */ - protected String getTestGroup() { - return getID().substring(0, 2) + "00"; - } - /** Test case data directory */ - protected String getTestCaseDirectory() { - return getTestGroupDirectory() + getID() + "/"; - } - /** Test group data directory */ - protected String getTestGroupDirectory() { - return TESTDATA_XMLDATA + getTestGroup() + "/"; - } - /** Finds a file in the xmldata directory */ - protected String findXmldata(String filename) { - String pathname = getTestCaseDirectory() + filename; - if (! new File(pathname).exists()) { - pathname = getTestGroupDirectory() + filename; - if (! new File(pathname).exists()) { - pathname = TESTDATA_XMLDATA + filename; - } - } - return pathname; - } - /** Finds and reads a file in the xmldata directory */ - protected String readXmldata(String filename) throws IOException { - String pathname = findXmldata(filename); - System.out.println("Read file " + pathname); - return readFile(pathname); - } - protected void writeXmldata(String filename, byte[] content) throws Exception { - String pathname = getTestCaseDirectory() + filename; - System.out.println("Write file " + pathname); - RandomAccessFile raf = new RandomAccessFile(pathname, "rw"); - byte[] data = content; - raf.write(data); - raf.setLength(data.length); - raf.close(); - } - - /** - * Creates a session using standard parameters, - * and returns the session ID. - */ - protected String startAuthentication() throws MOAIDException { - return startAuthentication("https://localhost:9443/"); - } - /** - * Creates a session using standard parameters, - * and returns the session ID. - */ - protected String startAuthentication(String oaURL) throws MOAIDException { - String htmlForm = AuthenticationServer.getInstance().startAuthentication( - "https://localhost:8443/auth", - "gb", - null, - oaURL, - null, - null, - null, - null, - null, null); - String sessionID = parseSessionIDFromForm(htmlForm); - return sessionID; - } - 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 = i1; - while(i2 < htmlForm.length() && - (htmlForm.charAt(i2) == '-' || (htmlForm.charAt(i2) >= '0' && htmlForm.charAt(i2) <= '9'))) - i2++; - assertTrue("HTML Form enthält keine gültige SessionID", i2 > i1); - return htmlForm.substring(i1, i2); - } - protected String clearSessionID(String htmlForm) { - String sessionID = parseSessionIDFromForm(htmlForm); - int i1 = htmlForm.indexOf(sessionID); - int i2 = i1 + sessionID.length(); - return htmlForm.substring(0, i1) + htmlForm.substring(i2); - } - protected void assertEqualsIgnoreSessionID(String s1, String s2) { - String ss1 = clearSessionID(s1); - String ss2 = clearSessionID(s2); - assertEquals(ss1, ss2); - } - protected void authDataWriter(AuthenticationData authData, String filename) throws Exception - { - writeXmldata("AuthenticationDataNEW.xml", clearSamlAssertion(authData.getSamlAssertion()).getBytes("UTF-8")); - } - - /** - * clearSamlAssertion löscht aus einer beliebiegen String-Repräsentation einer XML-Struktur - * AUSSLIESSLICH die Attribute 'IssueInstant' und 'AssertionID' heraus. - * @param samlAssertion - * @return String - */ - protected String clearSamlAssertion(String samlAssertion) - { - String result = killInclusive(samlAssertion,"IssueInstant='", "'",""); - result = killInclusive(result,"AssertionID='", "'",""); - return result; - } -}
\ No newline at end of file +///* +// * Copyright 2003 Federal Chancellery Austria +// * MOA-ID has been developed in a cooperation between BRZ, the Federal +// * Chancellery Austria - ICT staff unit, and Graz University of Technology. +// * +// * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by +// * the European Commission - subsequent versions of the EUPL (the "Licence"); +// * You may not use this work except in compliance with the Licence. +// * You may obtain a copy of the Licence at: +// * http://www.osor.eu/eupl/ +// * +// * Unless required by applicable law or agreed to in writing, software +// * distributed under the Licence is distributed on an "AS IS" basis, +// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// * See the Licence for the specific language governing permissions and +// * limitations under the Licence. +// * +// * This product combines work with different licenses. See the "NOTICE" text +// * file for details on the various modules and licenses. +// * The "NOTICE" text file is part of the distribution. Any derivative works +// * that you distribute must include a readable copy of the "NOTICE" text file. +// */ +// +// +//package test.abnahme; +// +//import java.io.File; +//import java.io.IOException; +//import java.io.RandomAccessFile; +// +//import test.MOAIDTestCase; +// +//import at.gv.egovernment.moa.id.MOAIDException; +//import at.gv.egovernment.moa.id.auth.AuthenticationServer; +//import at.gv.egovernment.moa.id.config.ConfigurationProvider; +//import at.gv.egovernment.moa.id.config.auth.AuthConfigurationProvider; +//import at.gv.egovernment.moa.id.data.AuthenticationData; +// +///** +// * Base class for MOA ID test cases. +// * +// * Provides some utility functions. +// * +// * @author Stefan Knirsch +// * @version $Id$ +// */ +//public class AbnahmeTestCase extends MOAIDTestCase { +// +// protected static final String TESTDATA_ROOT = "data/abnahme-test/"; +// protected static final String TESTDATA_XMLDATA = "data/abnahme-test/xmldata/"; +// protected static final String AUTH_ENDPOINT = "http://localhost:8080/moa-id-auth/"; +// protected AuthenticationServer server; +// +// /** +// * Constructor for MOATestCase. +// * @param arg0 +// */ +// public AbnahmeTestCase(String name) { +// super(name); +// } +// /** +// * Set up a transaction context with a test configuration. +// */ +// protected void setUp() throws Exception { +// +// System.out.print("--------S-T-A-R-T----V-O-N----"); +// System.out.print(getName().toUpperCase().substring(4,getName().length())); +// System.out.print("-----------------------------\n"); +// +// // Set moa.spss.server.configuration property +// System.setProperty("moa.spss.server.configuration",TESTDATA_ROOT + "conf/moa/ConfigurationTest.xml"); +// +// // Set moa.id.configuration property +// String pathname = findXmldata("Configuration.xml"); +// System.setProperty(ConfigurationProvider.CONFIG_PROPERTY_NAME, pathname); +// System.out.println("Konfiguration " + pathname); +// AuthConfigurationProvider.reload(); +// +// server = AuthenticationServer.getInstance(); +// } +// /** Test case z.B. "A153" */ +// protected String getID() { +// return getName().toUpperCase().substring(4,getName().length()); +// } +// /** Test group z.B. "A100" */ +// protected String getTestGroup() { +// return getID().substring(0, 2) + "00"; +// } +// /** Test case data directory */ +// protected String getTestCaseDirectory() { +// return getTestGroupDirectory() + getID() + "/"; +// } +// /** Test group data directory */ +// protected String getTestGroupDirectory() { +// return TESTDATA_XMLDATA + getTestGroup() + "/"; +// } +// /** Finds a file in the xmldata directory */ +// protected String findXmldata(String filename) { +// String pathname = getTestCaseDirectory() + filename; +// if (! new File(pathname).exists()) { +// pathname = getTestGroupDirectory() + filename; +// if (! new File(pathname).exists()) { +// pathname = TESTDATA_XMLDATA + filename; +// } +// } +// return pathname; +// } +// /** Finds and reads a file in the xmldata directory */ +// protected String readXmldata(String filename) throws IOException { +// String pathname = findXmldata(filename); +// System.out.println("Read file " + pathname); +// return readFile(pathname); +// } +// protected void writeXmldata(String filename, byte[] content) throws Exception { +// String pathname = getTestCaseDirectory() + filename; +// System.out.println("Write file " + pathname); +// RandomAccessFile raf = new RandomAccessFile(pathname, "rw"); +// byte[] data = content; +// raf.write(data); +// raf.setLength(data.length); +// raf.close(); +// } +// +// /** +// * Creates a session using standard parameters, +// * and returns the session ID. +// */ +// protected String startAuthentication() throws MOAIDException { +// return startAuthentication("https://localhost:9443/"); +// } +// /** +// * Creates a session using standard parameters, +// * and returns the session ID. +// */ +// protected String startAuthentication(String oaURL) throws MOAIDException { +// String htmlForm = AuthenticationServer.getInstance().startAuthentication( +// "https://localhost:8443/auth", +// "gb", +// null, +// oaURL, +// null, +// null, +// null, +// null, +// null, null); +// String sessionID = parseSessionIDFromForm(htmlForm); +// return sessionID; +// } +// 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 = i1; +// while(i2 < htmlForm.length() && +// (htmlForm.charAt(i2) == '-' || (htmlForm.charAt(i2) >= '0' && htmlForm.charAt(i2) <= '9'))) +// i2++; +// assertTrue("HTML Form enth�lt keine g�ltige SessionID", i2 > i1); +// return htmlForm.substring(i1, i2); +// } +// protected String clearSessionID(String htmlForm) { +// String sessionID = parseSessionIDFromForm(htmlForm); +// int i1 = htmlForm.indexOf(sessionID); +// int i2 = i1 + sessionID.length(); +// return htmlForm.substring(0, i1) + htmlForm.substring(i2); +// } +// protected void assertEqualsIgnoreSessionID(String s1, String s2) { +// String ss1 = clearSessionID(s1); +// String ss2 = clearSessionID(s2); +// assertEquals(ss1, ss2); +// } +// protected void authDataWriter(AuthenticationData authData, String filename) throws Exception +// { +// writeXmldata("AuthenticationDataNEW.xml", clearSamlAssertion(authData.getSamlAssertion()).getBytes("UTF-8")); +// } +// +// /** +// * clearSamlAssertion l�scht aus einer beliebiegen String-Repr�sentation einer XML-Struktur +// * AUSSLIESSLICH die Attribute 'IssueInstant' und 'AssertionID' heraus. +// * @param samlAssertion +// * @return String +// */ +// protected String clearSamlAssertion(String samlAssertion) +// { +// String result = killInclusive(samlAssertion,"IssueInstant='", "'",""); +// result = killInclusive(result,"AssertionID='", "'",""); +// return result; +// } +//}
\ No newline at end of file |