Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwdouglas authored and n1hility committed Feb 9, 2012
1 parent 9b76d29 commit c74f352
Show file tree
Hide file tree
Showing 38 changed files with 174 additions and 597 deletions.
1 change: 1 addition & 0 deletions build/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,7 @@
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-client-all</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,18 @@ public static ServiceName createName(String connectorName) {

public void start(StartContext startContext) throws StartException {
String path = tmpDirValue.getValue();

File authDir = new File(path, "auth");
if (authDir.exists()) {
if (!authDir.isDirectory()) {
throw MESSAGES.unableToCreateTempDirForAuthTokensFileExists();
}
} else if (!authDir.mkdirs()) {
throw MESSAGES.unableToCreateAuthDir();
//there is a race if multiple services are starting for the same
//security realm
if(!authDir.isDirectory()) {
throw MESSAGES.unableToCreateAuthDir(authDir.getAbsolutePath());
}
} else {
// As a precaution make perms user restricted for directories created (if the OS allows)
authDir.setWritable(false, false);
Expand Down
19 changes: 10 additions & 9 deletions remoting/src/main/java/org/jboss/as/remoting/RemotingMessages.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@

package org.jboss.as.remoting;

import java.io.IOException;
import java.net.BindException;
import java.net.URISyntaxException;

import javax.security.auth.callback.Callback;
import javax.security.auth.callback.UnsupportedCallbackException;
import javax.security.sasl.SaslException;

import org.jboss.as.controller.OperationFailedException;
import org.jboss.logging.Cause;
import org.jboss.logging.Message;
Expand All @@ -30,13 +38,6 @@
import org.jboss.logging.Param;
import org.jboss.msc.service.StartException;

import javax.security.auth.callback.Callback;
import javax.security.auth.callback.UnsupportedCallbackException;
import javax.security.sasl.SaslException;
import java.io.IOException;
import java.net.BindException;
import java.net.URISyntaxException;

/**
* Date: 05.11.2011
*
Expand Down Expand Up @@ -91,8 +92,8 @@ public interface RemotingMessages {
@Message(id = 17122, value = "Unable to create tmp dir for auth tokens as file already exists.")
StartException unableToCreateTempDirForAuthTokensFileExists();

@Message(id = 17123, value = "Unable to create auth dir.")
StartException unableToCreateAuthDir();
@Message(id = 17123, value = "Unable to create auth dir %s.")
StartException unableToCreateAuthDir(String dir);

@Message(id = 17124, value = "Could not register a connection provider factory for %s uri scheme")
StartException couldNotRegisterConnectionProvider(String remoteUriScheme, @Cause IOException ioe);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@

package org.jboss.as.test.integration.ejb.client.descriptor;

import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;

import javax.ejb.EJBException;
import javax.naming.Context;
import javax.naming.InitialContext;

import org.jboss.arquillian.container.test.api.Deployer;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.OperateOnDeployment;
Expand All @@ -40,13 +48,6 @@
import org.junit.Test;
import org.junit.runner.RunWith;

import javax.ejb.EJBException;
import javax.naming.Context;
import javax.naming.InitialContext;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;

/**
* Tests that deployments containing a jboss-ejb-client.xml are processed correctly for EJB client context
*
Expand Down Expand Up @@ -135,6 +136,7 @@ private static void setupRemoteOutboundConnection() throws Exception {
final Map<String, String> connectionCreationOptions = new HashMap<String, String>();
connectionCreationOptions.put("SSL_ENABLED", "false"); //without class name should also work
connectionCreationOptions.put("org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false");
connectionCreationOptions.put("org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");
logger.info("Creatng remote outbound connection " + outboundConnectionName);
EJBManagementUtil.createRemoteOutboundConnection("localhost", 9999, outboundConnectionName, outboundSocketName, connectionCreationOptions, Authentication.getCallbackHandler());
outboundConnectionCreated = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,27 @@

import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.TimeUnit;

import com.sun.xml.internal.xsom.impl.Const;
import javassist.CtNewConstructor;
import javax.ejb.EJBAccessException;
import javax.naming.Context;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.NameCallback;
import javax.security.auth.callback.PasswordCallback;
import javax.security.auth.callback.UnsupportedCallbackException;
import javax.security.sasl.RealmCallback;

import org.jboss.as.test.integration.ejb.security.authorization.AnnOnlyCheckSFSBForInjection;
import org.jboss.as.test.integration.ejb.security.authorization.AnnOnlyCheckSLSBForInjection;
import org.jboss.as.test.integration.ejb.security.authorization.ParentAnnOnlyCheck;
import org.jboss.as.test.integration.ejb.security.authorization.SimpleAuthorizationRemote;
import org.jboss.as.test.shared.integration.ejb.security.Util;
import org.jboss.ejb.client.ConstantContextSelector;
import org.jboss.ejb.client.ContextSelector;
import org.jboss.ejb.client.EJBClientConfiguration;
import org.jboss.ejb.client.EJBClientContext;
import org.jboss.ejb.client.EJBReceiver;
import org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration;
import org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector;
import org.jboss.ejb.client.remoting.IoFutureHelper;
import org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver;
import org.jboss.logging.Logger;
Expand All @@ -57,20 +57,10 @@
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Assert;
import org.xnio.IoFuture;
import org.xnio.Option;
import org.xnio.OptionMap;
import org.xnio.Options;
import org.xnio.Sequence;

import javax.ejb.EJBAccessException;
import javax.naming.Context;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.NameCallback;
import javax.security.auth.callback.PasswordCallback;
import javax.security.auth.callback.UnsupportedCallbackException;
import javax.security.sasl.RealmCallback;

/**
* This is a common parent for test cases to check whether basic EJB authorization works from an EJB client to a remote EJB.
*
Expand Down Expand Up @@ -106,7 +96,7 @@ public static Archive<JavaArchive> testAppDeployment(final Logger LOG, final Str
*/
public void testSingleMethodAnnotationsNoUserTemplate(final String MODULE, final Logger log, final Class SB_CLASS) throws Exception {
final Context ctx = Util.createNamingContext();
ContextSelector<EJBClientContext> old = setupEJBClientContextSelector(null, null);
ContextSelector<EJBClientContext> old = setupEJBClientContextSelector("$local", null);
try {

String myContext = Util.createRemoteEjbJndiContext(
Expand Down Expand Up @@ -135,9 +125,8 @@ public void testSingleMethodAnnotationsNoUserTemplate(final String MODULE, final
try {
echoValue = singleMethodsAnnOnlyBean.roleBasedAccessMore("alohomora");
Assert.fail("Method cannot be successfully called without logged in user");
} catch (Exception e) {
} catch (EJBAccessException e) {
// expected
Assert.assertTrue("Thrown exception must be EJBAccessException, but was " + e.getClass().getSimpleName(), e instanceof EJBAccessException);
}

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,13 @@ public void testSingleMethodAnnotationsNoUser() throws Exception {
}

@Test
@Ignore("AS7-2999")
public void testSingleMethodAnnotationsUser1() throws Exception {
testSingleMethodAnnotationsUser1Template(MODULE, log, beanClass());
}

@Test
@Ignore("AS7-2999")
public void testSingleMethodAnnotationsUser2() throws Exception {
testSingleMethodAnnotationsUser2Template(MODULE, log, beanClass());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,13 @@ public void testSingleMethodAnnotationsNoUser() throws Exception {
}

@Test
@Ignore("AS7-2999")
public void testSingleMethodAnnotationsUser1() throws Exception {
testSingleMethodAnnotationsUser1Template(MODULE, log, beanClass());
}

@Test
@Ignore("AS7-2999")
public void testSingleMethodAnnotationsUser2() throws Exception {
testSingleMethodAnnotationsUser2Template(MODULE, log, beanClass());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
*/
@RunWith(Arquillian.class)
@RunAsClient
@Ignore("AS7-2999")
public class InjectionAnnSFSBtoSFSBTestCase extends AnnSBTest {

private static final Logger log = Logger.getLogger(testClass());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,16 @@
*/
@RunWith(Arquillian.class)
@RunAsClient
@Ignore("AS7-2999")
public class InjectionAnnSFSBtoSLSBTestCase extends AnnSBTest {

private static final Logger log = Logger.getLogger(testClass());
private static final String MODULE = "injectionAnnOnlySFSBtoSLSB";

private static Class testClass(){
return InjectionAnnSFSBtoSLSBTestCase.class;
}

private static Class beanClass(){
return InjectionSFSBtoSLSB.class;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
*/
@RunWith(Arquillian.class)
@RunAsClient
@Ignore("AS7-2999")
public class InjectionAnnSLSBtoSFSBTestCase extends AnnSBTest {

private static final Logger log = Logger.getLogger(testClass());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
*/
@RunWith(Arquillian.class)
@RunAsClient
@Ignore("AS7-2999")
public class InjectionAnnSLSBtoSLSBTestCase extends AnnSBTest {

private static final Logger log = Logger.getLogger(testClass());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@
*/
package org.jboss.as.test.integration.ejb.security;

import org.jboss.as.test.shared.integration.ejb.security.Util;
import org.junit.Ignore;
import org.junit.Test;
import javax.ejb.EJBAccessException;
import javax.naming.InitialContext;

import org.jboss.logging.Logger;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.test.integration.ejb.security.runasprincipal.Caller;
import org.jboss.as.test.integration.ejb.security.runasprincipal.CallerWithIdentity;
import org.jboss.as.test.integration.ejb.security.runasprincipal.WhoAmI;
import org.jboss.as.test.shared.integration.ejb.security.Util;
import org.jboss.logging.Logger;
import org.jboss.security.client.SecurityClient;
import org.jboss.security.client.SecurityClientFactory;
import org.jboss.shrinkwrap.api.Archive;
Expand All @@ -39,11 +39,10 @@
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.util.Base64;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;

import javax.ejb.EJBAccessException;
import javax.naming.InitialContext;

/**
* Migration of test from EJB3 testsuite [JBQA-5451] Testing calling with runasprincipal annotation (ejbthree1945)
*
Expand Down Expand Up @@ -72,8 +71,6 @@ public static Archive<?> runAsDeployment() {
.addClass(RunAsPrincipalTestCase.class)
.addClass(Base64.class)
.addClass(SecurityTest.class)
.addAsResource(CallerWithIdentity.class.getPackage(),"users.properties", "users.properties")
.addAsResource(CallerWithIdentity.class.getPackage(),"roles.properties", "roles.properties")
.addAsManifestResource(new StringAsset("Dependencies: org.jboss.as.controller-client,org.jboss.dmr\n"),"MANIFEST.MF");
log.info(war.toString(true));
return war;
Expand All @@ -90,7 +87,7 @@ private WhoAmI lookupCaller() throws Exception {
@Test
public void testJackInABox() throws Exception {
SecurityClient client = SecurityClientFactory.getSecurityClient();
client.setSimple("thomas", "valid");
client.setSimple("user1", "password1");
client.login();
try {
WhoAmI bean = lookupCallerWithIdentity();
Expand All @@ -116,7 +113,7 @@ public void testRunAsPrincipal() throws Exception {
@Test
public void testAnonymous() throws Exception {
SecurityClient client = SecurityClientFactory.getSecurityClient();
client.setSimple("thomas", "valid");
client.setSimple("user1", "password1");
client.login();
try {
WhoAmI bean = lookupCaller();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,16 @@

package org.jboss.as.test.integration.ejb.security;

import org.jboss.as.test.shared.integration.ejb.security.Util;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.test.integration.ejb.security.authorization.SingleMethodsAnnOnlyCheckSLSB;
import org.jboss.logging.Logger;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.Ignore;

/**
* This test case check whether basic EJB authorization works from EJB client to remote stateful EJB.
Expand Down Expand Up @@ -65,11 +64,13 @@ public void testSingleMethodAnnotationsNoUser() throws Exception {
}

@Test
@Ignore("AS7-2999")
public void testSingleMethodAnnotationsUser1() throws Exception {
testSingleMethodAnnotationsUser1Template(MODULE, log, beanClass());
}

@Test
@Ignore("AS7-2999")
public void testSingleMethodAnnotationsUser2() throws Exception {
testSingleMethodAnnotationsUser2Template(MODULE, log, beanClass());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public class GetCallerPrincipalTestCase extends SecurityTest {
private static final String OK = "OK";

private static ModelControllerClient modelControllerClient;
public static final String LOCAL_USER = "$local";

@ArquillianResource
Deployer deployer;
Expand Down Expand Up @@ -293,7 +294,7 @@ public void testStatefulLifecycle() throws Exception {

bean.remove();

Assert.assertEquals(ANONYMOUS + "stop", results.getSfsb("predestroy"));
Assert.assertEquals(LOCAL_USER + "stop", results.getSfsb("predestroy"));
} finally {
deployer.undeploy("sfsb");
client.logout();
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ public class SecuredSingletonBean implements SingletonSecurity {
private EJBContext ejbContext;

@Override
@RolesAllowed("role1")
@RolesAllowed("Role1")
public void allowedForRole1() {
if (!this.ejbContext.isCallerInRole("role1")) {
throw new RuntimeException("Only role1 was expected to be allowed to invoke this method");
if (!this.ejbContext.isCallerInRole("Role1")) {
throw new RuntimeException("Only Role1 was expected to be allowed to invoke this method");
}
}
}
Loading

0 comments on commit c74f352

Please sign in to comment.