Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WFLY-12190] EJB over HTTP discovery: EjbOverHttpWrongCredentialsTest…
…Case
- Loading branch information
Showing
4 changed files
with
155 additions
and
11 deletions.
There are no files selected for viewing
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
85 changes: 85 additions & 0 deletions
85
...c/test/java/org/jboss/as/test/multinode/ejb/http/EjbOverHttpWrongCredentialsTestCase.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,85 @@ | ||
package org.jboss.as.test.multinode.ejb.http; | ||
|
||
import static org.jboss.as.test.shared.integration.ejb.security.PermissionUtils.createFilePermission; | ||
import static org.jboss.as.test.shared.integration.ejb.security.PermissionUtils.createPermissionsXmlAsset; | ||
|
||
import java.net.SocketPermission; | ||
import java.util.Arrays; | ||
import javax.naming.InitialContext; | ||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.arquillian.container.test.api.OperateOnDeployment; | ||
import org.jboss.arquillian.container.test.api.TargetsContainer; | ||
import org.jboss.arquillian.junit.Arquillian; | ||
import org.jboss.arquillian.test.api.ArquillianResource; | ||
import org.jboss.as.arquillian.api.ServerSetup; | ||
import org.jboss.as.test.shared.TestSuiteEnvironment; | ||
import org.jboss.shrinkwrap.api.Archive; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
/** | ||
* EJB over HTTP remote call should fail with incorrect wildfly-config.xml credentials | ||
* | ||
* @author <a href="mailto:szhantem@redhat.com">Sultan Zhantemirov</a> | ||
*/ | ||
@RunWith(Arquillian.class) | ||
@ServerSetup(EjbOverHttpTestCase.EjbOverHttpTestCaseServerSetup.class) | ||
public class EjbOverHttpWrongCredentialsTestCase { | ||
|
||
public static final String ARCHIVE_NAME_SERVER = "ejboverhttp-test-server"; | ||
public static final String ARCHIVE_NAME_CLIENT_WRONG_CREDENTIALS = "ejboverhttp-test-client-wrong-credentials"; | ||
private static final int serverPort = 8180; | ||
|
||
@Deployment(name = "server") | ||
@TargetsContainer("multinode-server") | ||
public static Archive<?> deployment0() { | ||
JavaArchive jar = createJar(ARCHIVE_NAME_SERVER); | ||
return jar; | ||
} | ||
|
||
@Deployment(name = "client-wrong-credentials") | ||
@TargetsContainer("multinode-client") | ||
public static Archive<?> deployment1() { | ||
JavaArchive jar = createClientJar(); | ||
return jar; | ||
} | ||
|
||
private static JavaArchive createJar(String archiveName) { | ||
JavaArchive jar = ShrinkWrap.create(JavaArchive.class, archiveName + ".jar"); | ||
jar.addClasses(StatelessBean.class, StatelessLocal.class, StatelessRemote.class); | ||
return jar; | ||
} | ||
|
||
private static JavaArchive createClientJar() { | ||
JavaArchive jar = createJar(EjbOverHttpWrongCredentialsTestCase.ARCHIVE_NAME_CLIENT_WRONG_CREDENTIALS); | ||
jar.addClasses(EjbOverHttpTestCase.class); | ||
jar.addAsManifestResource("META-INF/jboss-ejb-client-profile.xml", "jboss-ejb-client.xml") | ||
.addAsManifestResource("ejb-http-wildfly-config-wrong.xml", "wildfly-config.xml") | ||
.addAsManifestResource(createPermissionsXmlAsset(createFilePermission("read,write", | ||
"jbossas.multinode.client", Arrays.asList("standalone", "data", "ejb-xa-recovery")), | ||
createFilePermission("read,write", | ||
"jbossas.multinode.client", Arrays.asList("standalone", "data", "ejb-xa-recovery", "-")), | ||
new SocketPermission(TestSuiteEnvironment.formatPossibleIpv6Address(System.getProperty("node0")) + ":" + serverPort, | ||
"connect,resolve")), | ||
"permissions.xml"); | ||
return jar; | ||
} | ||
|
||
@Test | ||
@OperateOnDeployment("client-wrong-credentials") | ||
public void testBasicInvocationWithWrongCredentials(@ArquillianResource InitialContext ctx) throws Exception { | ||
StatelessRemote bean = (StatelessRemote) ctx.lookup("java:module/" + StatelessBean.class.getSimpleName() + "!" | ||
+ StatelessRemote.class.getName()); | ||
Assert.assertNotNull(bean); | ||
|
||
try { | ||
int methodCount = bean.remoteCall(); | ||
Assert.assertEquals(EjbOverHttpTestCase.NO_EJB_RETURN_CODE, methodCount); | ||
} catch (javax.naming.AuthenticationException e) { | ||
// expected | ||
} | ||
} | ||
} |
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
23 changes: 23 additions & 0 deletions
23
testsuite/integration/multinode/src/test/resources/ejb-http-wildfly-config-wrong.xml
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,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<configuration> | ||
<authentication-client xmlns="urn:elytron:1.0"> | ||
<authentication-rules> | ||
<rule use-configuration="jta"> | ||
<match-protocol name="http"/> | ||
</rule> | ||
</authentication-rules> | ||
<authentication-configurations> | ||
<configuration name="jta"> | ||
<sasl-mechanism-selector selector="DIGEST-MD5"/> | ||
<providers> | ||
<use-service-loader /> | ||
</providers> | ||
<set-user-name name="remoteejbuser"/> | ||
<credentials> | ||
<clear-password password="wrong-password"/> | ||
</credentials> | ||
<set-mechanism-realm name="ApplicationRealm" /> | ||
</configuration> | ||
</authentication-configurations> | ||
</authentication-client> | ||
</configuration> |