Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.jboss.eap.qe.microprofile.jwt.testapp.jaxrs;

import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;

import org.eclipse.microprofile.auth.LoginConfig;

/**
* Application which normally activates JWT subsystem using {@code org.eclipse.microprofile.auth.LoginConfig}
* annotation. This is however annotated by an annotation which is missing {@code realmName};
*/
@LoginConfig(authMethod = "MP-JWT")
@ApplicationPath("/")
public class UnsetRealmNameJaxRsTestApplication extends Application {

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.jboss.eap.qe.microprofile.jwt.EnableJwtSubsystemSetupTask;
import org.jboss.eap.qe.microprofile.jwt.testapp.jaxrs.NonJwtJaxRsTestApplication;
import org.jboss.eap.qe.microprofile.jwt.testapp.jaxrs.SecuredJaxRsEndpoint;
import org.jboss.eap.qe.microprofile.jwt.testapp.jaxrs.UnsetRealmNameJaxRsTestApplication;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
Expand All @@ -23,6 +24,7 @@ public class ActivationPropertiesUnsetTest {

private static final String UNSET_AUTH_ACTIVATION_PROPERTY_DEPLOYMENT_NAME = "PROPERTIES_UNSET_DEPLOYMENT";
private static final String NON_JWT_AUTH_ACTIVATION_PROPERTY_DEPLOYMENT_NAME = "OTHER_VALUE_DEPLOYMENT";
private static final String UNSET_REALM_NAME_DEPLOYMENT_NAME = "UNSET_REALM_NAME_DEPLOYMENT";

@Deployment(name = UNSET_AUTH_ACTIVATION_PROPERTY_DEPLOYMENT_NAME, managed = false)
public static Archive<?> createDeploymentNoValue() {
Expand Down Expand Up @@ -57,6 +59,23 @@ public static Archive<?> createDeploymentOtherValue() {
"key.public.pem");
}

@Deployment(name = UNSET_REALM_NAME_DEPLOYMENT_NAME, managed = false)
public static Archive<?> createDeploymentUnsetRealmName() {
return ShrinkWrap
.create(WebArchive.class,
ActivationPropertiesUnsetTest.class.getSimpleName() + UNSET_REALM_NAME_DEPLOYMENT_NAME
+ ".war")
.addClass(SecuredJaxRsEndpoint.class)
.addClass(UnsetRealmNameJaxRsTestApplication.class)
.setWebXML(ActivationPropertiesUnsetTest.class.getClassLoader().getResource("basic-auth-web.xml"))
.addAsManifestResource(
ActivationPropertiesUnsetTest.class.getClassLoader().getResource("mp-config-basic.properties"),
"microprofile-config.properties")
.addAsManifestResource(
ActivationPropertiesUnsetTest.class.getClassLoader().getResource("pki/key.public.pem"),
"key.public.pem");
}

/**
* @tpTestDetails Test that subsystem is not activated when there is not {@code MP-JWT} set as an
* {@code auth-method} anywhere (both web.xml and {@code @LoginConfig} annotation).
Expand All @@ -80,4 +99,17 @@ public void testDeploymentFailsWithUnsetAuth(@ArquillianResource Deployer deploy
public void testDeploymentFailsAuthOtherValue(@ArquillianResource Deployer deployer) {
deployer.deploy(NON_JWT_AUTH_ACTIVATION_PROPERTY_DEPLOYMENT_NAME);
}

/**
* @tpTestDetails Test that subsystem is not activated when the {@code auth-method} is set to {@code MP-JWT} but
* the {@code realm-name} is not set..
* @tpPassCrit Deployment fails because classes required by deployment (MP-JWT API) are not loaded due to the fact
* that the subsystem was not activated.
* @tpSince EAP 7.3.1.GA-CR1
* See https://issues.redhat.com/browse/JBEAP-19164
*/
@Test(expected = org.jboss.arquillian.container.spi.client.container.DeploymentException.class)
public void testDeploymentFailsRealmNameNotSet(@ArquillianResource Deployer deployer) {
deployer.deploy(UNSET_REALM_NAME_DEPLOYMENT_NAME);
}
}