Skip to content

Commit

Permalink
chore: add agama resources for reference #2672
Browse files Browse the repository at this point in the history
  • Loading branch information
jgomer2001 committed Oct 19, 2022
1 parent cf50167 commit 0b8f4cc
Show file tree
Hide file tree
Showing 12 changed files with 231 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//This flow is based on the "hello world" flow found in Agama docs (quick-start quide)
Flow io.jans.agama.test.auth.uidOnly
Basepath "hello"
Inputs uid

in = { name: uid }
RRF "index.ftlh" in

Log "Done!"
Finish uid
54 changes: 54 additions & 0 deletions agama/engine/src/test/resources/flows/io.jans.agama.test.math
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//This flow is used to test some Java calls. It does not make use of idiomatic Agama. There is no UI either here
Flow io.jans.agama.test.math
Basepath ""
Inputs numbers //A non-empty list of positive integers

// 1. Find the smallest
small = Call java.util.Collections#min numbers
Log "min element is" small


// 2. Concat them all in a string
strings = [ ]
Iterate over numbers using n
i = strings.length
strings[i] = Call java.lang.Integer#toString n

cat = Call java.lang.String#join "" strings
Log "concatenation is" cat


// 3. Sumation (with Repeat)
s = 0
Repeat numbers.length times max
i = idx[0]
s = Call java.lang.Math#addExact s numbers[i]

Log "sumation is" s


// 4. Find if they are mutually relatively prime (no integer divides them all)
When numbers.length is 1 or small is 1
Finish true

divisor = 1
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
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

When k is numbers.length
Log "% are relative primes" numbers
Otherwise
Log "All numbers can be divided by" divisor

Finish true
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Flow io.jans.agama.test.showConfig
Basepath ""
Timeout 10 seconds
Configs conf

RRF "printConfigs.ftlh" conf

Finish false
11 changes: 11 additions & 0 deletions agama/engine/src/test/resources/flows/org.gluu.flow1
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//This flow appeared originally in the demos of the authentication-trees project
Flow org.gluu.flow1
Basepath "f1"

data = RRF "index.ftl"

data = Trigger org.gluu.flow2 data.secret[0]

Log "@debug Subflow finished successfully?" data.success

Finish data
14 changes: 14 additions & 0 deletions agama/engine/src/test/resources/flows/org.gluu.flow2
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//This flow appeared originally in the demos of the authentication-trees project
Flow org.gluu.flow2
Basepath "f1"
Inputs val

x = {value: val}
data = RRF "index2.ftl" x

When data.something is ""
Log "There was a missing value"
ret = { success: false, error: "You forgot something!" }
Finish ret
Otherwise
Finish true
7 changes: 7 additions & 0 deletions agama/engine/src/test/resources/flows/org.gluu.flow3
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Flow org.gluu.flow3
Basepath "me"

obj = Trigger org.gluu.flow1
Override templates "f1/index.ftl" "myindex.ftlh"

Finish obj
14 changes: 14 additions & 0 deletions agama/engine/src/test/resources/templates/custom/printConfigs.ftlh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<body>

<#!-- rendering this page crashes if neither joke nor phrase are defined -->
<p>${joke}
<p>${phrase}

<form method="post" enctype="application/x-www-form-urlencoded">
<input type="submit" value="Continue">
</form>

</body>
</html>
14 changes: 14 additions & 0 deletions agama/engine/src/test/resources/templates/f1/index.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<#ftl output_format="HTML">
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<p>Hi I'm Flow 1!</p>

<form method="post" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="secret" value="Gluu">
<input type="hidden" name="secret" value="Janssen">
<input type="submit" value="Continue">
</form>

</body>
</html>
15 changes: 15 additions & 0 deletions agama/engine/src/test/resources/templates/f1/index2.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<#ftl output_format="HTML">
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<p>Hi I'm Flow 2!</p>
<p>${value!""}</p>

<form method="post" enctype="application/x-www-form-urlencoded">
<label for="name">Say something
<input type="text" id="something" name="something" placeHolder="I don't like cloud native">
<input type="submit" value="Continue">
</form>

</body>
</html>
11 changes: 11 additions & 0 deletions agama/engine/src/test/resources/templates/hello/index.ftlh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<p>Hi ${name}</p>

<form method="post" enctype="application/x-www-form-urlencoded">
<input type="submit" value="Continue">
</form>

</body>
</html>
59 changes: 59 additions & 0 deletions agama/engine/src/test/resources/templates/login.ftlh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="${webCtx.contextPath}/servlet/favicon" type="image/x-icon">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<style>
#logo {
max-height: 3rem;
margin: 0.5rem;
}
</style>
</head>
<body>

<div class="d-flex flex-column align-items-center justify-content-between min-vh-100 w-100">
<header class="d-flex w-100 justify-content-between border-bottom">
<img id="logo" src="https://gluu.org/wp-content/uploads/2021/02/janssen-project-transparent-630px-182px-300x86.png" />
</header>

<div class="row col-sm-10 col-md-5 mb-5 pb-3">

<div class="border border-1 rounded mb-3 p-5">
<p class="fs-4 mb-5">Welcome</p>

<#if !(success!true)>
<p class="fs-6 text-danger mb-3">${msgs["login.errorMessage"]}</p>
</#if>

<form method="post" enctype="application/x-www-form-urlencoded">
<div class="mb-3 row">
<label for="username" class="col-md-3 col-form-label">${msgs["login.username"]}</label>
<div class="col-md-9">
<input type="text" class="form-control" name="username" id="username" value="${uid!}" required>
</div>
</div>
<div class="mb-4 row">
<label for="password" class="col-md-3 col-form-label">${msgs["login.password"]}</label>
<div class="col-md-9">
<input type="password" class="form-control" id="password" name="password">
</div>
</div>
<div class="row">
<div class="col-md-12 d-flex justify-content-end">
<input type="submit" class="btn btn-success px-4" value="${msgs["login.login"]}">
</div>
</div>
</form>
</div>

</div>
<footer class="d-flex flex-column align-items-center w-100 pb-2">
<hr class="w-75">
</footer>
</div>

</body>
</html>
14 changes: 14 additions & 0 deletions agama/engine/src/test/resources/templates/me/myindex.ftlh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<p>Hi I'm Flow 3!</p>

<form method="post" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="secret" value="Agama">
<input type="hidden" name="secret" value="Gluu">
<input type="hidden" name="secret" value="Janssen">
<input type="submit" value="Go">
</form>

</body>
</html>

0 comments on commit 0b8f4cc

Please sign in to comment.