Class TestSecurity

java.lang.Object
dev.relism.flash.ext.security.test.TestSecurity
All Implemented Interfaces:
dev.relism.flash.extension.FlashExtension

public final class TestSecurity extends Object implements dev.relism.flash.extension.FlashExtension
Authenticates test requests as any Principal, whatever mechanisms the application installs — an OIDC user, an API key, a plain name — without an identity provider.

 FlashTest app = FlashTest.of(flash -> flash.apply(new MyApp()).install(new TestSecurity()));
 app.request().with(TestSecurity.as(() -> "alice")).get("/me");
 

Works because FlashTest serves the application in the test's own JVM: the principal is handed over by reference, under a token only this process can have issued.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Consumer<dev.relism.flash.testing.FlashRequest>
    as(dev.relism.flash.ext.security.Principal principal)
    Sends the request as principal.
    void
    configure(dev.relism.flash.extension.FlashRegistrar<?> app, dev.relism.flash.extension.FlashContext ctx)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TestSecurity

      public TestSecurity()
  • Method Details

    • as

      public static Consumer<dev.relism.flash.testing.FlashRequest> as(dev.relism.flash.ext.security.Principal principal)
      Sends the request as principal.
    • configure

      public void configure(dev.relism.flash.extension.FlashRegistrar<?> app, dev.relism.flash.extension.FlashContext ctx)
      Specified by:
      configure in interface dev.relism.flash.extension.FlashExtension