aboutsummaryrefslogtreecommitdiff
path: root/id/server/stork2-saml-engine/src/test/java/eu/stork/peps/test/simple/StorkAttrQueryRequestTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'id/server/stork2-saml-engine/src/test/java/eu/stork/peps/test/simple/StorkAttrQueryRequestTest.java')
-rw-r--r--id/server/stork2-saml-engine/src/test/java/eu/stork/peps/test/simple/StorkAttrQueryRequestTest.java790
1 files changed, 0 insertions, 790 deletions
diff --git a/id/server/stork2-saml-engine/src/test/java/eu/stork/peps/test/simple/StorkAttrQueryRequestTest.java b/id/server/stork2-saml-engine/src/test/java/eu/stork/peps/test/simple/StorkAttrQueryRequestTest.java
deleted file mode 100644
index 7fa305d3b..000000000
--- a/id/server/stork2-saml-engine/src/test/java/eu/stork/peps/test/simple/StorkAttrQueryRequestTest.java
+++ /dev/null
@@ -1,790 +0,0 @@
-package eu.stork.peps.test.simple;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-
-import org.junit.Test;
-import org.opensaml.xml.parse.BasicParserPool;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import eu.stork.peps.auth.commons.IPersonalAttributeList;
-import eu.stork.peps.auth.commons.PersonalAttribute;
-import eu.stork.peps.auth.commons.PersonalAttributeList;
-import eu.stork.peps.auth.commons.STORKAttrQueryRequest;
-import eu.stork.peps.auth.engine.STORKSAMLEngine;
-import eu.stork.peps.exceptions.STORKSAMLEngineException;
-
-public class StorkAttrQueryRequestTest {
-
- /** The engines. */
- private static STORKSAMLEngine engine = STORKSAMLEngine.getInstance("CONF1");
- private static STORKSAMLEngine engine0 = STORKSAMLEngine.getInstance("CONF0");
- private static STORKSAMLEngine engine2 = STORKSAMLEngine.getInstance("CONF2");
- private static STORKSAMLEngine engine3 = STORKSAMLEngine.getInstance("CONF3");
-
-
- /**
- * Instantiates a new stork authentication request test.
- */
- public StorkAttrQueryRequestTest() {
- pal = new PersonalAttributeList();
-
- final PersonalAttribute isAgeOver = new PersonalAttribute();
- isAgeOver.setName("isAgeOver");
- isAgeOver.setIsRequired(true);
- final ArrayList<String> ages = new ArrayList<String>();
- ages.add("16");
- ages.add("18");
- isAgeOver.setValue(ages);
- pal.add(isAgeOver);
-
- final PersonalAttribute dateOfBirth = new PersonalAttribute();
- dateOfBirth.setName("dateOfBirth");
- dateOfBirth.setIsRequired(false);
- pal.add(dateOfBirth);
-
- final PersonalAttribute eIDNumber = new PersonalAttribute();
- eIDNumber.setName("eIdentifier");
- eIDNumber.setIsRequired(true);
- eIDNumber.setValue(Arrays.asList("ES/IS/1234567890"));
- pal.add(eIDNumber);
-
- final PersonalAttribute givenName = new PersonalAttribute();
- givenName.setName("givenName");
- givenName.setIsRequired(true);
- givenName.setValue(Arrays.asList("Sveinbjorn"));
- pal.add(givenName);
-
- destination = "http://A-PEPS.gov.xx/PEPS/AttributeColleagueRequest";
- //assertConsumerUrl = "http://S-PEPS.gov.xx/PEPS/ColleagueResponse";
-
- }
-
- /** The destination. */
- private String destination;
-
- /** The service provider sector. */
- private String spSector;
-
- /** The service provider institution. */
- private String spInstitution;
-
- /** The service provider application. */
- private String spApplication;
-
- /** The service provider country. */
- private String spCountry;
-
- /** The service provider id. */
- private String spId;
-
- /** The quality authentication assurance level. */
- private static final int QAAL = 3;
-
- /** The List of Personal Attributes. */
- private IPersonalAttributeList pal;
-
- /** The attribute query request. */
- private static byte[] attrRequest;
-
- /** The Constant LOG. */
- private static final Logger LOG = LoggerFactory
- .getLogger(StorkAttrQueryRequestTest.class.getName());
-
- /** Parser manager used to parse XML. */
- private static BasicParserPool parser;
-
- static {
- parser = new BasicParserPool();
- parser.setNamespaceAware(true);
- }
-
- /**
- * Test generate authentication request.
- *
- * @throws STORKSAMLEngineException the STORKSAML engine exception
- */
- @Test
- public final void testGenerateAttrQueryRequest() throws STORKSAMLEngineException {
-
- final STORKAttrQueryRequest request = new STORKAttrQueryRequest();
-
- request.setDestination(destination);
- request.setQaa(QAAL);
- request.setPersonalAttributeList(pal);
-
- // new parameters
- request.setEIDSectorShare(false);
- request.setEIDCrossSectorShare(false);
- request.setEIDCrossBorderShare(false);
-
- STORKAttrQueryRequest req1 = engine0.generateSTORKAttrQueryRequest(request);
- byte[] reqByte = req1.getTokenSaml();
- FileOutputStream output = null;
-
- try {
- output = new FileOutputStream(new File(System.getProperty("user.dir") + "/src/test/resources/data/eu/stork/STORKSAMLEngine/AttrQueryRequest.xml"));
- output.write(reqByte);
- } catch (Exception e) {
- e.printStackTrace();
- throw new STORKSAMLEngineException(e);
- } finally {
- try { output.close(); } catch (Exception e) { throw new STORKSAMLEngineException(e); }
- }
-
-
-
-
- LOG.info("STORKAttrQueryRequest 1: " + SSETestUtils.encodeSAMLToken(engine.generateSTORKAttrQueryRequest(request).getTokenSaml()));
-
- request.setCitizenCountryCode("IS");
- LOG.info("STORKAttrQueryRequest 2: " + SSETestUtils.encodeSAMLToken(engine.generateSTORKAttrQueryRequest(request).getTokenSaml()));
- }
-
- /**
- * Test generate authentication request error personal attribute name error.
- */
- @Test
- public final void testGenerateAttrQueryRequestPALsErr1() {
-
- final IPersonalAttributeList palWrong = new PersonalAttributeList();
-
- final PersonalAttribute worngAttr = new PersonalAttribute();
- worngAttr.setName("attrNotValid");
- worngAttr.setIsRequired(true);
-
- final STORKAttrQueryRequest request = new STORKAttrQueryRequest();
-
- request.setDestination(destination);
- request.setQaa(QAAL);
- request.setPersonalAttributeList(palWrong);
-
- // news parameters
- request.setEIDSectorShare(false);
- request.setEIDCrossSectorShare(false);
- request.setEIDCrossBorderShare(false);
- request.setSpCountry(spCountry);
- request.setSPID(spId);
- request.setCitizenCountryCode("IS");
-
- try {
- engine.generateSTORKAttrQueryRequest(request);
- fail("generateSTORKAuthnRequest(...) should've thrown an STORKSAMLEngineException!");
- } catch (STORKSAMLEngineException e) {
- LOG.error("Error");
- }
- }
-
-
-
- /**
- * Test generate authentication request error personal attribute value error.
- */
- @Test
- public final void testGenerateAttrQueryRequestPALsErr2() {
-
- final IPersonalAttributeList palWrong = new PersonalAttributeList();
-
- final PersonalAttribute attrNotValid = new PersonalAttribute();
- attrNotValid.setName("attrNotValid");
- attrNotValid.setIsRequired(true);
- palWrong.add(attrNotValid);
-
-
-
- final STORKAttrQueryRequest request = new STORKAttrQueryRequest();
-
- request.setDestination(destination);
- request.setQaa(QAAL);
- request.setPersonalAttributeList(palWrong);
-
- // news parameters
- request.setSpSector(spSector);
- request.setSpInstitution(spInstitution);
- request.setSpApplication(spApplication);
- request.setSpCountry(spCountry);
- request.setSPID(spId);
- request.setCitizenCountryCode("IS");
-
- try {
- engine.generateSTORKAttrQueryRequest(request);
- fail("generateSTORKAuthnRequest(...) should've thrown an STORKSAMLEngineException!");
- } catch (STORKSAMLEngineException e) {
- LOG.error("Error");
- }
- }
-
- /**
- * Test generate authentication request authentication assurance level
- * negative value.
- */
- @Test
- public final void testGenerateAttrQueryRequestQaalErr1() {
-
- final STORKAttrQueryRequest request = new STORKAttrQueryRequest();
-
- request.setDestination(destination);
- request.setQaa(-1);
- request.setPersonalAttributeList(pal);
-
- // news parameters
- request.setSpSector(spSector);
- request.setSpInstitution(spInstitution);
- request.setSpApplication(spApplication);
- request.setSpCountry(spCountry);
- request.setSPID(spId);
-
- try {
- engine.generateSTORKAttrQueryRequest(request);
- fail("generateSTORKAuthnRequest(...) should've thrown an STORKSAMLEngineException!");
- } catch (STORKSAMLEngineException e) {
- LOG.error("Error");
- }
- }
-
- /**
- * Test generate authentication request service provider sector null.
- */
- @Test
- public final void testGenerateAttrQueryRequestSectorErr() {
-
- final STORKAttrQueryRequest request = new STORKAttrQueryRequest();
-
- request.setDestination(destination);
- request.setQaa(QAAL);
- request.setPersonalAttributeList(pal);
-
- // news parameters
- request.setSpSector(null);
- request.setSpInstitution(spInstitution);
- request.setSpApplication(spApplication);
- request.setSpCountry(spCountry);
- request.setSPID(spId);
- request.setCitizenCountryCode("IS");
-
- try {
- engine.generateSTORKAttrQueryRequest(request);
- } catch (STORKSAMLEngineException e) {
- LOG.error("Error");
- fail("generateSTORKAuthnRequest(...) should've thrown an STORKSAMLEngineException!");
-
- }
- }
-
- /**
- * Test generate authentication request service provider institution null.
- */
- @Test
- public final void testGenerateAttrQueryRequestInstitutionrErr() {
-
- final STORKAttrQueryRequest request = new STORKAttrQueryRequest();
-
- request.setDestination(destination);
- request.setQaa(QAAL);
- request.setPersonalAttributeList(pal);
-
- // news parameters
- request.setSpSector(spSector);
- request.setSpInstitution(null);
- request.setSpApplication(spApplication);
- request.setSpCountry(spCountry);
- request.setSPID(spId);
- request.setCitizenCountryCode("IS");
-
- try {
- engine.generateSTORKAttrQueryRequest(request);
-
- } catch (STORKSAMLEngineException e) {
- LOG.error("Error");
- fail("generateSTORKAttrQueryRequest(...) should've thrown an STORKSAMLEngineException!");
- }
- }
-
- /**
- * Test generate authentication request service provider application null.
- */
- @Test
- public final void testGenerateAttrQueryRequestApplicationErr() {
-
- final STORKAttrQueryRequest request = new STORKAttrQueryRequest();
-
- request.setDestination(destination);
- request.setQaa(QAAL);
- request.setPersonalAttributeList(pal);
-
- // news parameters
- request.setSpSector(spSector);
- request.setSpInstitution(spInstitution);
- request.setSpApplication(null);
- request.setSpCountry(spCountry);
- request.setSPID(spId);
- request.setCitizenCountryCode("IS");
-
- try {
- engine.generateSTORKAttrQueryRequest(request);
-
- } catch (STORKSAMLEngineException e) {
- LOG.error("Error");
- fail("generateSTORKAuthnRequest(...) should've thrown an STORKSAMLEngineException!");
- }
- }
-
- /**
- * Test generate authentication request service provider country null.
- */
- @Test
- public final void testGenerateAttrQueryRequestCountryErr() {
-
- final STORKAttrQueryRequest request = new STORKAttrQueryRequest();
-
- request.setDestination(destination);
- request.setQaa(QAAL);
- request.setPersonalAttributeList(pal);
-
- // news parameters
- request.setSpSector(spSector);
- request.setSpInstitution(spInstitution);
- request.setSpApplication(spApplication);
- request.setSpCountry(null);
- request.setSPID(spId);
- request.setCitizenCountryCode("IS");
-
- try {
- engine.generateSTORKAttrQueryRequest(request);
-
- } catch (STORKSAMLEngineException e) {
- LOG.error("Error");
- fail("generateSTORKAuthnRequest(...) should've thrown an STORKSAMLEngineException!");
- }
- }
-
- /**
- * Test generate authentication request error with quality authentication
- * assurance level wrong.
- */
- @Test
- public final void testGenerateAttrQueryRequestQaalErr2() {
- final STORKAttrQueryRequest request = new STORKAttrQueryRequest();
-
- request.setDestination(destination);
- request.setQaa(0);
- request.setPersonalAttributeList(pal);
-
- // news parameters
- request.setSpSector(spSector);
- request.setSpInstitution(spInstitution);
- request.setSpApplication(spApplication);
- request.setSpCountry(spCountry);
- request.setSPID(spId);
- request.setCitizenCountryCode("IS");
-
- try {
- engine.generateSTORKAttrQueryRequest(request);
- fail("generateSTORKAuthnRequest(...) should've thrown an STORKSAMLEngineException!");
- } catch (STORKSAMLEngineException e) {
- LOG.error("Error");
- }
- }
-
- /**
- * Test generate authentication request personal attribute list null value.
- */
- @Test
- public final void testGenerateAttrQueryRequestPALErr1() {
- final STORKAttrQueryRequest request = new STORKAttrQueryRequest();
-
- request.setDestination(destination);
- request.setQaa(QAAL);
- request.setPersonalAttributeList(null);
-
- // news parameters
- request.setSpSector(spSector);
- request.setSpInstitution(spInstitution);
- request.setSpApplication(spApplication);
- request.setSpCountry(spCountry);
- request.setSPID(spId);
- request.setCitizenCountryCode("IS");
-
- try {
- engine.generateSTORKAttrQueryRequest(request);
- fail("generateSTORKAuthnRequest(...) should've thrown an STORKSAMLEngineException!");
- } catch (STORKSAMLEngineException e) {
- LOG.error("Error");
- }
- }
-
- /**
- * Test validate authentication request null parameter.
- *
- * @throws STORKSAMLEngineException the STORKSAML engine exception
- */
- @Test
- public final void testValidateAttrQueryRequestNullParam()
- throws STORKSAMLEngineException {
- try {
- engine.validateSTORKAttrQueryRequest(null);
- fail("validateSTORKAuthnRequest(...) should've thrown an STORKSAMLEngineException!");
- } catch (STORKSAMLEngineException e) {
- LOG.error("Error");
- }
- }
-
- /**
- * Test validate authentication request error bytes encode.
- *
- * @throws STORKSAMLEngineException the STORKSAML engine exception
- */
- @Test
- public final void testValidateAttrQueryRequestErrorEncode()
- throws STORKSAMLEngineException {
- try {
- engine.validateSTORKAttrQueryRequest("messageError".getBytes());
- fail("validateSTORKAuthnRequest(...) should've thrown an STORKSAMLEngineException!");
- } catch (STORKSAMLEngineException e) {
- LOG.error("Error");
- }
- }
-
- /**
- * Test validate authentication request.
- *
- * @throws STORKSAMLEngineException the STORKSAML engine exception
- */
- @Test
- public final void testValidateAttrQueryRequest() throws STORKSAMLEngineException {
-
- final STORKAttrQueryRequest request = new STORKAttrQueryRequest();
-
- request.setDestination(destination);
- request.setQaa(QAAL);
- request.setPersonalAttributeList(pal);
-
- // news parameters
- request.setSpSector(spSector);
- request.setSpInstitution(spInstitution);
- request.setSpApplication(spApplication);
- request.setSpCountry(spCountry);
- request.setSPID(spId);
- request.setCitizenCountryCode("IS");
-
- attrRequest = engine.generateSTORKAttrQueryRequest(request).getTokenSaml();
-
- final STORKAttrQueryRequest validatedRequest = engine.validateSTORKAttrQueryRequest(attrRequest);
-
- assertEquals("CrossBorderShare incorrect: ", validatedRequest.isEIDCrossBorderShare(), false);
- assertEquals("CrossSectorShare incorrect: ", validatedRequest.isEIDCrossSectorShare(), false);
- assertEquals("SectorShare incorrect: ", validatedRequest.isEIDSectorShare(), false);
-
- }
-
- /**
- * Test validate data authenticate request. Verified parameters after
- * validation.
- *
- * @throws STORKSAMLEngineException the STORKSAML engine exception
- */
- @Test
- public final void testValidateDataAttrQueryRequest() throws STORKSAMLEngineException {
-
- final STORKAttrQueryRequest request = engine.validateSTORKAttrQueryRequest(attrRequest);
-
- assertEquals("Sestination incorrect: ", request.getDestination(), destination);
-
- assertEquals("CrossBorderShare incorrect: ", request.isEIDCrossBorderShare(), false);
- assertEquals("CrossSectorShare incorrect: ", request.isEIDCrossSectorShare(), false);
- assertEquals("SectorShare incorrect: ", request.isEIDSectorShare(), false);
-
- assertEquals("QAAL incorrect: ", request.getQaa(), QAAL);
- assertEquals("SPSector incorrect: ", request.getSpSector(), spSector);
- assertEquals("SPInstitution incorrect: ", request.getSpInstitution(), null);
- assertEquals("SPApplication incorrect: ", request.getSpApplication(), spApplication);
- assertEquals("CitizenCountryCode incorrect: ", request.getCitizenCountryCode(), null);
-
- }
-
- /**
- * Test validate file attribute query request. Validate from XML file.
- *
- * @throws Exception the exception
- */
- @Test
- public final void testValidateFileAttrQueryRequest() throws Exception {
-
- final byte[] bytes = SSETestUtils.readStorkSamlFromFile("/data/eu/stork/STORKSAMLEngine/AttrQueryRequest.xml");
-
- try {
- engine.validateSTORKAttrQueryRequest(bytes);
- fail("testValidateFileAttrQueryRequest(...) should've thrown an STORKSAMLEngineException!");
- } catch (STORKSAMLEngineException e) {
- LOG.error(e.getMessage());
- }
- }
-
- /**
- * Test validate file authentication request tag delete.
- *
- * @throws Exception the exception
- */
- @Test
- public final void testValidateFileAttrRequestTagDelete() throws Exception {
-
- final byte[] bytes = SSETestUtils.readStorkSamlFromFile("/data/eu/stork/STORKSAMLEngine/AttrQueryRequestTagDelete.xml");
-
- try {
- engine.validateSTORKAttrQueryRequest(bytes);
- fail("validateSTORKAttrQueryRequest(...) should have thrown an STORKSAMLEngineException!");
- } catch (STORKSAMLEngineException e) {
- LOG.error(e.getMessage());
-
- }
- }
-
- /**
- * Test validate authentication request not trusted token.
- *
- * @throws STORKSAMLEngineException the STORKSAML engine exception
- */
- @Test
- public final void testValidateAttrQueryRequestNotTrustedErr1()
- throws STORKSAMLEngineException {
-
- try {
- final STORKSAMLEngine engineNotTrusted = STORKSAMLEngine
- .getInstance("CONF2");
-
- final STORKAttrQueryRequest request = new STORKAttrQueryRequest();
-
- request.setDestination(destination);
- request.setQaa(QAAL);
- request.setPersonalAttributeList(pal);
-
- // news parameters
- request.setSpSector(spSector);
- request.setSpInstitution(spInstitution);
- request.setSpApplication(spApplication);
- request.setSpCountry(spCountry);
-
- final byte[] authReqNotTrust = engineNotTrusted
- .generateSTORKAttrQueryRequest(request).getTokenSaml();
-
- engine.validateSTORKAttrQueryRequest(authReqNotTrust);
- } catch (STORKSAMLEngineException e) {
- LOG.error("Error");
- fail("validateSTORKAttrQueryRequestNotTrusted(...) should not have thrown an STORKSAMLEngineException!");
- }
- }
-
- /**
- * Test validate authentication request trusted.
- *
- * @throws STORKSAMLEngineException the STORKSAML engine exception
- */
- @Test
- public final void testValidateAttrQueryRequestTrusted()
- throws STORKSAMLEngineException {
-
- final STORKSAMLEngine engineTrusted = STORKSAMLEngine
- .getInstance("CONF3");
-
- final STORKAttrQueryRequest request = new STORKAttrQueryRequest();
-
- request.setDestination(destination);
- request.setQaa(QAAL);
- request.setPersonalAttributeList(pal);
-
- // news parameters
- request.setSpSector(spSector);
- request.setSpInstitution(spInstitution);
- request.setSpApplication(spApplication);
- request.setSpCountry(spCountry);
-
- final byte[] authReqNotTrust = engineTrusted.generateSTORKAttrQueryRequest(
- request).getTokenSaml();
-
- // engine ("CONF1") no have trust certificate from "CONF2"
- engine.validateSTORKAttrQueryRequest(authReqNotTrust);
-
- }
-
-
-
-
- /**
- * Test generate authentication request service provider application null.
- */
- @Test
- public final void testGenerateAttrQueryRequestNADA() {
-
- final STORKAttrQueryRequest request = new STORKAttrQueryRequest();
-
- request.setDestination(destination);
- request.setQaa(QAAL);
- request.setPersonalAttributeList(pal);
-
- // news parameters
- request.setSpSector(null);
- request.setSpInstitution(null);
- request.setSpApplication(null);
- request.setSpCountry(null);
-
- try {
-
- engine.validateSTORKAttrQueryRequest(attrRequest);
-
- } catch (STORKSAMLEngineException e) {
- LOG.error("Error");
- fail("generateSTORKAuthnRequest(...) should've thrown an STORKSAMLEngineException!");
- }
- }
-
- /**
- * Test validate authentication request with unknown elements.
- *
- * @throws STORKSAMLEngineException the STORKSAML engine exception
- */
- @Test
- public final void testValidateAttrQueryRequestWithUnknownElements() throws STORKSAMLEngineException {
-
- final STORKAttrQueryRequest request = new STORKAttrQueryRequest();
-
- request.setDestination(destination);
- request.setQaa(QAAL);
- request.setPersonalAttributeList(pal);
-
- IPersonalAttributeList pAttList = new PersonalAttributeList();
-
- final PersonalAttribute unknown = new PersonalAttribute();
- unknown.setName("unknown");
- unknown.setIsRequired(true);
- pAttList.add(unknown);
-
- final PersonalAttribute eIdentifier = new PersonalAttribute();
- eIdentifier.setName("eIdentifier");
- eIdentifier.setIsRequired(true);
- pAttList.add(eIdentifier);
-
- request.setPersonalAttributeList(pAttList);
-
- // new parameters
- request.setSpSector(spSector);
- request.setSpInstitution(spInstitution);
- request.setSpApplication(spApplication);
- request.setSpCountry(spCountry);
- request.setSPID(spId);
- request.setCitizenCountryCode("IS");
-
- STORKAttrQueryRequest req = new STORKAttrQueryRequest();
-
- req = engine3.generateSTORKAttrQueryRequest(request);
-
- req = engine.validateSTORKAttrQueryRequest(req.getTokenSaml());
-
- assertNull("The value shouldn't exist", req.getPersonalAttributeList().get("unknown"));
- assertNotNull("The value should exist", req.getPersonalAttributeList().get("eIdentifier"));
-
- }
-
- /**
- * Test generate Request with required elements by default
- *
- * @throws STORKSAMLEngineException the STORKSAML engine exception
- */
- @Test
- public final void testGenerateAttrQueryRequestWithIsRequiredElementsByDefault() throws STORKSAMLEngineException {
-
- final STORKAttrQueryRequest request = new STORKAttrQueryRequest();
-
- request.setDestination(destination);
- request.setQaa(QAAL);
- request.setPersonalAttributeList(pal);
-
- IPersonalAttributeList pAttList = new PersonalAttributeList();
-
- final PersonalAttribute eIdentifier = new PersonalAttribute();
- eIdentifier.setName("eIdentifier");
- eIdentifier.setIsRequired(true);
- pAttList.add(eIdentifier);
-
- request.setPersonalAttributeList(pAttList);
-
- // new parameters
- request.setSpSector(spSector);
- request.setSpInstitution(spInstitution);
- request.setSpApplication(spApplication);
- request.setSpCountry(spCountry);
- request.setSPID(spId);
- request.setCitizenCountryCode("IS");
-
- STORKAttrQueryRequest req = new STORKAttrQueryRequest();
- STORKAttrQueryRequest reqTrue = new STORKAttrQueryRequest();
- STORKAttrQueryRequest reqFalse = new STORKAttrQueryRequest();
-
- reqTrue = engine.generateSTORKAttrQueryRequest(request);
- reqFalse = engine2.generateSTORKAttrQueryRequest(request);
- req = engine3.generateSTORKAttrQueryRequest(request);
-
-
- String token = new String(req.getTokenSaml());
- String reqTrueToken = new String(reqTrue.getTokenSaml());
- String reqFalseToken = new String(reqFalse.getTokenSaml());
-
- assertTrue("The token must contain the chain 'isRequired'", token.contains("isRequired"));
- assertTrue("The token must contain the chain 'isRequired'", reqTrueToken.contains("isRequired"));
- assertFalse("The token must contain the chain 'isRequired'", reqFalseToken.contains("isRequired"));
-
- }
-
- /**
- * Test validating attribute query and getting alias used to save
- * the saml trusted certificate into trustore
- *
- * @throws STORKSAMLEngineException the STORKSAML engine exception
- */
- @Test
- public final void testValidateAtrrQueryRequestGettingItsAlias() throws STORKSAMLEngineException {
-
- final STORKAttrQueryRequest request = new STORKAttrQueryRequest();
-
- request.setDestination(destination);
- request.setQaa(QAAL);
- request.setPersonalAttributeList(pal);
-
- IPersonalAttributeList pAttList = new PersonalAttributeList();
-
- final PersonalAttribute eIdentifier = new PersonalAttribute();
- eIdentifier.setName("eIdentifier");
- eIdentifier.setIsRequired(true);
- pAttList.add(eIdentifier);
-
- request.setPersonalAttributeList(pAttList);
-
- // new parameters
- request.setSpSector(spSector);
- request.setSpInstitution(spInstitution);
- request.setSpApplication(spApplication);
- request.setSpCountry(spCountry);
- request.setSPID(spId);
- request.setCitizenCountryCode("IS");
-
- STORKAttrQueryRequest req = new STORKAttrQueryRequest();
-
- req = engine3.generateSTORKAttrQueryRequest(request);
- req = engine.validateSTORKAttrQueryRequest(req.getTokenSaml());
- assertTrue("The alias should match this value", req.getAlias().equals("local-demo"));
-
- req = engine2.generateSTORKAttrQueryRequest(request);
- req = engine2.validateSTORKAttrQueryRequest(req.getTokenSaml());
- assertTrue("The alias should match this value", req.getAlias().equals("local-demo"));
- }
-
-}