package at.gv.egiz.eaaf.modules.pvp2.test; import java.util.Arrays; import java.util.List; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.BlockJUnit4ClassRunner; import at.gv.egiz.eaaf.core.api.data.EaafConstants; import at.gv.egiz.eaaf.modules.pvp2.exception.QaaNotAllowedException; import at.gv.egiz.eaaf.modules.pvp2.impl.utils.QaaLevelVerifier; @RunWith(BlockJUnit4ClassRunner.class) public class QaaLevelVerifierTest { QaaLevelVerifier verifyer = new QaaLevelVerifier(); @Test public void matchingModeUnknown() { String matchingMode = "notExist"; List requiredLoAs = Arrays.asList(EaafConstants.EIDAS_LOA_SUBSTANTIAL); try { QaaLevelVerifier.verifyQaaLevel(EaafConstants.EIDAS_LOA_LOW, requiredLoAs, matchingMode); Assert.fail("LoA should not be allowed"); } catch (QaaNotAllowedException e) { Assert.assertNotNull("No errorMsg", e.getMessage()); } try { QaaLevelVerifier.verifyQaaLevel("not_exist", requiredLoAs, matchingMode); Assert.fail("LoA should not be allowed"); } catch (QaaNotAllowedException e) { Assert.assertNotNull("No errorMsg", e.getMessage()); } } @Test public void matchingMinimumRequiredLow() throws QaaNotAllowedException { String matchingMode = EaafConstants.EIDAS_LOA_MATCHING_MINIMUM; List requiredLoAs = Arrays.asList(EaafConstants.EIDAS_LOA_LOW); QaaLevelVerifier.verifyQaaLevel(EaafConstants.EIDAS_LOA_LOW, requiredLoAs, matchingMode); QaaLevelVerifier.verifyQaaLevel(EaafConstants.EIDAS_LOA_SUBSTANTIAL, requiredLoAs, matchingMode); QaaLevelVerifier.verifyQaaLevel(EaafConstants.EIDAS_LOA_HIGH, requiredLoAs, matchingMode); try { QaaLevelVerifier.verifyQaaLevel("not_exist", requiredLoAs, matchingMode); Assert.fail("LoA should not be allowed"); } catch (QaaNotAllowedException e) { Assert.assertNotNull("No errorMsg", e.getMessage()); } } @Test public void matchingMinimumRequiredSubstantial() throws QaaNotAllowedException { String matchingMode = EaafConstants.EIDAS_LOA_MATCHING_MINIMUM; List requiredLoAs = Arrays.asList(EaafConstants.EIDAS_LOA_SUBSTANTIAL); try { QaaLevelVerifier.verifyQaaLevel(EaafConstants.EIDAS_LOA_LOW, requiredLoAs, matchingMode); Assert.fail("LoA should not be allowed"); } catch (QaaNotAllowedException e) { Assert.assertNotNull("No errorMsg", e.getMessage()); } QaaLevelVerifier.verifyQaaLevel(EaafConstants.EIDAS_LOA_SUBSTANTIAL, requiredLoAs, matchingMode); QaaLevelVerifier.verifyQaaLevel(EaafConstants.EIDAS_LOA_HIGH, requiredLoAs, matchingMode); try { QaaLevelVerifier.verifyQaaLevel("not_exist", requiredLoAs, matchingMode); Assert.fail("LoA should not be allowed"); } catch (QaaNotAllowedException e) { Assert.assertNotNull("No errorMsg", e.getMessage()); } } @Test public void matchingMinimumRequiredHigh() throws QaaNotAllowedException { String matchingMode = EaafConstants.EIDAS_LOA_MATCHING_MINIMUM; List requiredLoAs = Arrays.asList(EaafConstants.EIDAS_LOA_HIGH); try { QaaLevelVerifier.verifyQaaLevel(EaafConstants.EIDAS_LOA_LOW, requiredLoAs, matchingMode); Assert.fail("LoA should not be allowed"); } catch (QaaNotAllowedException e) { Assert.assertNotNull("No errorMsg", e.getMessage()); } try { QaaLevelVerifier.verifyQaaLevel(EaafConstants.EIDAS_LOA_SUBSTANTIAL, requiredLoAs, matchingMode); Assert.fail("LoA should not be allowed"); } catch (QaaNotAllowedException e) { Assert.assertNotNull("No errorMsg", e.getMessage()); } QaaLevelVerifier.verifyQaaLevel(EaafConstants.EIDAS_LOA_HIGH, requiredLoAs, matchingMode); try { QaaLevelVerifier.verifyQaaLevel("not_exist", requiredLoAs, matchingMode); Assert.fail("LoA should not be allowed"); } catch (QaaNotAllowedException e) { Assert.assertNotNull("No errorMsg", e.getMessage()); } } @Test public void matchingExact1() throws QaaNotAllowedException { String matchingMode = EaafConstants.EIDAS_LOA_MATCHING_EXACT; List requiredLoAs = Arrays.asList(EaafConstants.EIDAS_LOA_SUBSTANTIAL, EaafConstants.EIDAS_LOA_LOW); try { QaaLevelVerifier.verifyQaaLevel(EaafConstants.EIDAS_LOA_HIGH, requiredLoAs, matchingMode); Assert.fail("LoA should not be allowed"); } catch (QaaNotAllowedException e) { Assert.assertNotNull("No errorMsg", e.getMessage()); } QaaLevelVerifier.verifyQaaLevel(EaafConstants.EIDAS_LOA_LOW, requiredLoAs, matchingMode); QaaLevelVerifier.verifyQaaLevel(EaafConstants.EIDAS_LOA_SUBSTANTIAL, requiredLoAs, matchingMode); try { QaaLevelVerifier.verifyQaaLevel("not_exist", requiredLoAs, matchingMode); Assert.fail("LoA should not be allowed"); } catch (QaaNotAllowedException e) { Assert.assertNotNull("No errorMsg", e.getMessage()); } } }