Skip to content

Commit

Permalink
[WFLY-8562] Move EjbElytronDomainSetup to wildfly-testsuite-shared an…
Browse files Browse the repository at this point in the history
…d update it so it can also be used by tests in the basic integration testsuite
  • Loading branch information
fjuma committed Apr 20, 2017
1 parent 0657c4b commit 160b248
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import static org.junit.Assert.fail;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
Expand Down Expand Up @@ -69,6 +70,7 @@
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.wildfly.test.security.common.elytron.EjbElytronDomainSetup;

/**
* Test case to hold the authentication scenarios, these range from calling a servlet which calls a bean to calling a bean which
Expand All @@ -78,7 +80,7 @@
* @author <a href="mailto:[email protected]">Darran Lofthouse</a>
*/
@RunWith(Arquillian.class)
@ServerSetup({EjbElytronDomainSetup.class})
@ServerSetup({AuthenticationTestCase.EjbSecurityDomainSetup.class})
@Category(CommonCriteria.class)
public class AuthenticationTestCase {

Expand Down Expand Up @@ -509,4 +511,12 @@ public void testICIR_TwoBeans_ReAuth_ViaServlet() throws Exception {
// 17.6.7 - Principal Mapping
// 17.6.9 - Runtime Security Enforcement
// 17.6.10 - Audit Trail

static class EjbSecurityDomainSetup extends EjbElytronDomainSetup {
public EjbSecurityDomainSetup() {
super(new File(AuthenticationTestCase.class.getResource("users.properties").getFile()).getAbsolutePath(),
new File(AuthenticationTestCase.class.getResource("roles.properties").getFile()).getAbsolutePath());
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

package org.wildfly.test.integration.elytron.ejb;
package org.wildfly.test.security.common.elytron;

import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.*;

import java.io.File;
import java.util.LinkedList;
import java.util.List;

Expand All @@ -44,6 +43,8 @@
*/
public class EjbElytronDomainSetup extends AbstractSecurityDomainSetup {

private static final String DEFAULT_SECURITY_DOMAIN_NAME = "ejb3-tests";

private PathAddress realmAddress;

private PathAddress domainAddress;
Expand All @@ -62,40 +63,54 @@ public class EjbElytronDomainSetup extends AbstractSecurityDomainSetup {

private PathAddress undertowDomainAddress;

private final String usersFile;
private final String groupsFile;
private final String securityDomainName;

public EjbElytronDomainSetup(final String usersFile, final String groupsFile) {
this(usersFile, groupsFile, DEFAULT_SECURITY_DOMAIN_NAME);
}

public EjbElytronDomainSetup(final String usersFile, final String groupsFile, final String securityDomainName) {
this.usersFile = usersFile;
this.groupsFile = groupsFile;
this.securityDomainName = securityDomainName;
}

protected String getSecurityDomainName() {
return "ejb3-tests";
return securityDomainName;
}

protected String getSecurityRealmName() {
return "ejb3-UsersRoles";
return getSecurityDomainName() + "-ejb3-UsersRoles";
}

protected String getUndertowDomainName() {
return "ejb3-tests";
return getSecurityDomainName();
}

protected String getEjbDomainName() {
return "ejb3-tests";
return getSecurityDomainName();
}

protected String getSaslAuthenticationName() {
return "ejb3-tests";
return getSecurityDomainName();
}

protected String getRemotingConnectorName() {
return "ejb3-tests";
return getSecurityDomainName();
}

protected String getHttpAuthenticationName() {
return "ejb3-tests";
return getSecurityDomainName();
}

protected String getUsersFile() {
return new File(EjbElytronDomainSetup.class.getResource("users.properties").getFile()).getAbsolutePath();
return usersFile;
}

protected String getGroupsFile() {
return new File(EjbElytronDomainSetup.class.getResource("roles.properties").getFile()).getAbsolutePath();
return groupsFile;
}

protected boolean isUsersFilePlain() {
Expand Down Expand Up @@ -143,8 +158,8 @@ public void setup(final ManagementClient managementClient, final String containe
// /subsystem=elytron/properties-realm=UsersRoles:add(users-properties={path=users.properties},groups-properties={path=roles.properties})
ModelNode addRealm = Util.createAddOperation(realmAddress);
addRealm.get("users-properties").get("path").set(getUsersFile());
addRealm.get("users-properties").get("plain-text").set(isUsersFilePlain()); // not hashed
addRealm.get("groups-properties").get("path").set(getGroupsFile());
addRealm.get("plain-text").set(isUsersFilePlain()); // not hashed
steps.add(addRealm);

// /subsystem=elytron/security-domain=EjbDomain:add(default-realm=UsersRoles, realms=[{realm=UsersRoles}])
Expand Down Expand Up @@ -174,7 +189,7 @@ public void setup(final ManagementClient managementClient, final String containe
addEjbDomain.get("security-domain").set(getSecurityDomainName());
steps.add(addEjbDomain);

steps.add(Util.getWriteAttributeOperation(ejbRemoteAddress, "connector-ref", "ejb3-tests-connector"));
steps.add(Util.getWriteAttributeOperation(ejbRemoteAddress, "connector-ref", getSecurityDomainName() + "-connector"));

ModelNode addHttpAuthentication = Util.createAddOperation(httpAuthenticationAddress);
addHttpAuthentication.get("security-domain").set(getSecurityDomainName());
Expand Down

0 comments on commit 160b248

Please sign in to comment.