diff --git a/agama/engine/src/test/java/io/jans/agama/test/InexistentFlowTest.java b/agama/engine/src/test/java/io/jans/agama/test/InexistentFlowTest.java new file mode 100644 index 00000000000..a5d04dfb05c --- /dev/null +++ b/agama/engine/src/test/java/io/jans/agama/test/InexistentFlowTest.java @@ -0,0 +1,17 @@ +package io.jans.agama.test; + +import com.gargoylesoftware.htmlunit.html.HtmlPage; + +import org.testng.annotations.Test; + +import static org.testng.Assert.*; + +public class InexistentFlowTest extends BaseTest { + + @Test + public void test() { + HtmlPage page = launch("flow" + Math.random(), null); + assertFalse(page.getUrl().toString().endsWith(".fls")); + } + +} diff --git a/agama/engine/src/test/java/io/jans/agama/test/MathFlowTest.java b/agama/engine/src/test/java/io/jans/agama/test/MathFlowTest.java index 1d5ebeead10..7bc90353edf 100644 --- a/agama/engine/src/test/java/io/jans/agama/test/MathFlowTest.java +++ b/agama/engine/src/test/java/io/jans/agama/test/MathFlowTest.java @@ -11,7 +11,6 @@ import static org.testng.Assert.*; -@org.testng.annotations.Ignore public class MathFlowTest extends BaseTest { private static final String QNAME = "io.jans.agama.test.math"; diff --git a/agama/engine/src/test/java/io/jans/agama/test/UidOnlyAuthTest.java b/agama/engine/src/test/java/io/jans/agama/test/UidOnlyAuthTest.java index ef04eb25d94..d4d290e5c78 100644 --- a/agama/engine/src/test/java/io/jans/agama/test/UidOnlyAuthTest.java +++ b/agama/engine/src/test/java/io/jans/agama/test/UidOnlyAuthTest.java @@ -1,12 +1,10 @@ package io.jans.agama.test; +import com.gargoylesoftware.htmlunit.Page; import com.gargoylesoftware.htmlunit.html.HtmlPage; import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput; -import java.util.Arrays; -import java.util.ArrayList; import java.util.Collections; -import java.util.List; import org.testng.annotations.BeforeClass; import org.testng.annotations.Parameters; @@ -26,27 +24,24 @@ public void enableJS() { @Test public void randUid() { - HtmlPage page = start("" + Math.random()); - page = proceed(page); - assertOK(page); + start("" + Math.random()); + HtmlPage page = (HtmlPage) currentPageAfter(2000); + assertOK(page); assertTrue(page.getUrl().toString().endsWith("error.htm")); assertTextContained(page.getVisibleText().toLowerCase(), "failed", "authenticate"); } - + @Test(dependsOnMethods = "randUid", alwaysRun = true) @Parameters("redirectUri") public void adminUid(String redirectUri) { - HtmlPage page = start("admin"); - page = proceed(page); + start("admin"); + Page page = currentPageAfter(2000); + assertOK(page); - - if (!page.getUrl().toString().startsWith(redirectUri)) { - //check if this is the consent page - assertTextContained(page.getVisibleText().toLowerCase(), "permission", "allow"); - } + assertTrue(page.getUrl().toString().startsWith(redirectUri)); } @@ -59,15 +54,15 @@ private HtmlPage start(String uid) { } - private HtmlPage proceed(HtmlPage page) { + private Page currentPageAfter(long wait) { try { //wait for the auto-submitting javascript to execute (see finished.ftlh) and redirections to take place - Thread.sleep(2000); - page = (HtmlPage) client.getCurrentWindow().getEnclosedPage(); + Thread.sleep(wait); + Page p = client.getCurrentWindow().getEnclosedPage(); - logger.debug("Landed at {}",page.getUrl()); - return page; + logger.debug("Landed at {}", p.getUrl()); + return p; } catch (Exception e) { fail(e.getMessage(), e); } diff --git a/agama/engine/src/test/resources/flows/io.jans.agama.test.math b/agama/engine/src/test/resources/flows/io.jans.agama.test.math index 22df7423929..f9ca23b221f 100644 --- a/agama/engine/src/test/resources/flows/io.jans.agama.test.math +++ b/agama/engine/src/test/resources/flows/io.jans.agama.test.math @@ -36,13 +36,11 @@ small = Call java.lang.Math#decrementExact small Repeat small times max divisor = Call java.lang.Math#incrementExact divisor - k = 0 //Try to divide the numbers by 2, 3, ... small+1 - Iterate over numbers using n + k = Iterate over numbers using n modulus = Call java.lang.Math#floorMod n divisor Quit When modulus is 0 - k = Call java.lang.Math#incrementExact k Quit When k is numbers.length diff --git a/agama/engine/src/test/resources/testng.properties b/agama/engine/src/test/resources/testng.properties index 125373fd648..bfdee1a2710 100644 --- a/agama/engine/src/test/resources/testng.properties +++ b/agama/engine/src/test/resources/testng.properties @@ -1,7 +1,7 @@ authzEndpoint=${server}/jans-auth/restv1/authorize -redirectUri=${server}/admin-ui +redirectUri=${server}/.well-known/openid-configuration clientId=${clientId} diff --git a/agama/engine/src/test/resources/testng.xml b/agama/engine/src/test/resources/testng.xml index ec431e7e897..9a75f0fb6fb 100644 --- a/agama/engine/src/test/resources/testng.xml +++ b/agama/engine/src/test/resources/testng.xml @@ -40,4 +40,10 @@ + + + + + +