-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
154 additions
and
59 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
src/main/java/com/casinthecloud/simpletest/cas/CasDelegateTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package com.casinthecloud.simpletest.cas; | ||
|
||
import com.casinthecloud.simpletest.execution.Context; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
import lombok.val; | ||
|
||
import static org.apache.commons.lang3.StringUtils.substringBetween; | ||
|
||
/** | ||
* A test performing a CAS authn delegation in the CAS server. | ||
* | ||
* @author Jerome LELEU | ||
* @since 1.0.0 | ||
*/ | ||
@Getter | ||
@Setter | ||
public class CasDelegateTest extends CasLoginTest { | ||
|
||
private final String clientName; | ||
|
||
public CasDelegateTest(final String clientName, final CasTest casTest) { | ||
this.tests = new CasTest[] { casTest }; | ||
this.clientName = clientName; | ||
} | ||
|
||
public void run(final Context ctx) throws Exception { | ||
|
||
val loginUrl = callLoginPage(ctx); | ||
|
||
delegate(ctx, loginUrl); | ||
|
||
super.run(ctx); | ||
|
||
callbackCas(ctx); | ||
|
||
callbackCas(ctx); | ||
|
||
} | ||
|
||
protected void delegate(final Context ctx, final String loginUrl) throws Exception { | ||
val webflow = substringBetween(ctx.getBody(), "name=\"execution\" value=\"", "\"/>"); | ||
|
||
ctx.getFormParameters().put("client_name", getClientName()); | ||
ctx.getFormParameters().put("_eventId", "delegatedAuthenticationRedirect"); | ||
ctx.getFormParameters().put("execution", webflow); | ||
|
||
ctx.setRequest(post(ctx, loginUrl)); | ||
execute(ctx); | ||
|
||
saveCasSession(ctx); | ||
} | ||
|
||
protected void callbackCas(final Context ctx) throws Exception { | ||
val callbackUrl = getLocation(ctx); | ||
|
||
useCasSession(ctx); | ||
|
||
ctx.setRequest(get(ctx, callbackUrl)); | ||
execute(ctx); | ||
assertStatus(ctx, 302); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/test/java/com/casinthecloud/simpletest/MainDelegate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.casinthecloud.simpletest; | ||
|
||
import com.casinthecloud.simpletest.cas.CasDelegateTest; | ||
import com.casinthecloud.simpletest.cas.CasLoginTest; | ||
import com.casinthecloud.simpletest.cas.CasOIDCLoginTest; | ||
import com.casinthecloud.simpletest.cas.CasOIDCValidateOCTest; | ||
import com.casinthecloud.simpletest.execution.Execution; | ||
|
||
import static com.casinthecloud.simpletest.util.Utils.AND; | ||
|
||
public class MainDelegate { | ||
|
||
public static void main(final String... args) throws Exception { | ||
new Execution(() -> { | ||
return AND(new CasOIDCLoginTest(new CasDelegateTest("CasClient", new CasLoginTest())), new CasOIDCValidateOCTest()); | ||
}).launch(); | ||
} | ||
} |