forked from wildfly/wildfly
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WFLY-8278] Tests for Elytron+Batch subsystem integration
- Loading branch information
Showing
14 changed files
with
1,034 additions
and
18 deletions.
There are no files selected for viewing
392 changes: 392 additions & 0 deletions
392
.../test/java/org/wildfly/test/integration/elytron/batch/BatchSubsystemSecurityTestCase.java
Large diffs are not rendered by default.
Oops, something went wrong.
51 changes: 51 additions & 0 deletions
51
...ite/elytron/src/test/java/org/wildfly/test/integration/elytron/batch/FailingBatchlet.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,51 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2017, Red Hat, Inc., and individual contributors | ||
* as indicated by the @author tags. See the copyright.txt file in the | ||
* distribution for a full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
|
||
package org.wildfly.test.integration.elytron.batch; | ||
|
||
import javax.batch.api.BatchProperty; | ||
import javax.batch.api.Batchlet; | ||
import javax.inject.Inject; | ||
import javax.inject.Named; | ||
|
||
/** | ||
* @author Jan Martiska | ||
*/ | ||
@Named | ||
public class FailingBatchlet implements Batchlet { | ||
|
||
@Inject | ||
@BatchProperty(name = "should.fail") | ||
private Boolean shouldFail; | ||
|
||
@Override | ||
public String process() throws Exception { | ||
if(shouldFail) | ||
throw new Exception("failing the job on purpose"); | ||
return "OK"; | ||
} | ||
|
||
@Override | ||
public void stop() throws Exception { | ||
|
||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
...te/elytron/src/test/java/org/wildfly/test/integration/elytron/batch/IdentityBatchlet.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,51 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2017, Red Hat, Inc., and individual contributors | ||
* as indicated by the @author tags. See the copyright.txt file in the | ||
* distribution for a full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
|
||
package org.wildfly.test.integration.elytron.batch; | ||
|
||
import javax.batch.api.Batchlet; | ||
import javax.inject.Named; | ||
|
||
import org.jboss.logging.Logger; | ||
import org.wildfly.security.auth.server.SecurityDomain; | ||
|
||
/** | ||
* @author Jan Martiska | ||
*/ | ||
@Named | ||
public class IdentityBatchlet implements Batchlet { | ||
|
||
private Logger logger = Logger.getLogger(IdentityBatchlet.class); | ||
|
||
@Override | ||
public String process() throws Exception { | ||
final String name = SecurityDomain.getCurrent().getCurrentSecurityIdentity().getPrincipal().getName(); | ||
logger.info("Batchlet running as username: " + name); | ||
BatchSubsystemSecurityTestCase.identityWithinJob.complete(name); | ||
return "OK"; | ||
} | ||
|
||
@Override | ||
public void stop() throws Exception { | ||
|
||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
...elytron/src/test/java/org/wildfly/test/integration/elytron/batch/LongRunningBatchlet.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,55 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2017, Red Hat, Inc., and individual contributors | ||
* as indicated by the @author tags. See the copyright.txt file in the | ||
* distribution for a full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
|
||
package org.wildfly.test.integration.elytron.batch; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
import java.util.concurrent.TimeUnit; | ||
import javax.batch.api.Batchlet; | ||
import javax.batch.runtime.context.JobContext; | ||
import javax.inject.Inject; | ||
import javax.inject.Named; | ||
|
||
import org.jboss.as.test.shared.TimeoutUtil; | ||
|
||
/** | ||
* @author Jan Martiska | ||
*/ | ||
@Named | ||
public class LongRunningBatchlet implements Batchlet { | ||
|
||
private final CompletableFuture<Void> SHOULD_STOP = new CompletableFuture<>(); | ||
|
||
@Inject | ||
JobContext ctx; | ||
|
||
@Override | ||
public String process() throws Exception { | ||
SHOULD_STOP.get(TimeoutUtil.adjust(10), TimeUnit.SECONDS); | ||
return null; | ||
} | ||
|
||
@Override | ||
public void stop() throws Exception { | ||
SHOULD_STOP.complete(null); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...on/src/test/java/org/wildfly/test/integration/elytron/batch/SecurityDomainSettingEJB.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,39 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2017, Red Hat, Inc., and individual contributors | ||
* as indicated by the @author tags. See the copyright.txt file in the | ||
* distribution for a full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
|
||
package org.wildfly.test.integration.elytron.batch; | ||
|
||
import javax.ejb.LocalBean; | ||
import javax.ejb.Stateless; | ||
|
||
import org.jboss.ejb3.annotation.SecurityDomain; | ||
|
||
/** | ||
* This is here as just a hack to be able to set the security domain of a deployment. | ||
* See https://issues.jboss.org/browse/JBEAP-8702 discussion for more context. | ||
* @author Jan Martiska | ||
*/ | ||
@Stateless | ||
@SecurityDomain("BatchDomain") | ||
@LocalBean | ||
public class SecurityDomainSettingEJB { | ||
} |
8 changes: 8 additions & 0 deletions
8
...elytron/src/test/resources/org/wildfly/test/integration/elytron/batch/assert-identity.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,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<job id="assert-identity" xmlns="http://xmlns.jcp.org/xml/ns/javaee" version="1.0"> | ||
|
||
<step id="perform"> | ||
<batchlet ref="identityBatchlet"/> | ||
</step> | ||
|
||
</job> |
12 changes: 12 additions & 0 deletions
12
...lytron/src/test/resources/org/wildfly/test/integration/elytron/batch/failing-batchlet.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,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<job id="failing-batchlet" xmlns="http://xmlns.jcp.org/xml/ns/javaee" version="1.0"> | ||
|
||
<step id="perform"> | ||
<batchlet ref="failingBatchlet"> | ||
<properties> | ||
<property name="should.fail" value="#{jobParameters['should.fail']}"/> | ||
</properties> | ||
</batchlet> | ||
</step> | ||
|
||
</job> |
8 changes: 8 additions & 0 deletions
8
...n/src/test/resources/org/wildfly/test/integration/elytron/batch/long-running-batchlet.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,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<job id="long-running-batchlet" xmlns="http://xmlns.jcp.org/xml/ns/javaee" version="1.0"> | ||
|
||
<step id="perform"> | ||
<batchlet ref="longRunningBatchlet"/> | ||
</step> | ||
|
||
</job> |
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
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
55 changes: 55 additions & 0 deletions
55
...in/java/org/wildfly/test/security/common/elytron/EJBApplicationSecurityDomainMapping.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,55 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2017, Red Hat, Inc., and individual contributors | ||
* as indicated by the @author tags. See the copyright.txt file in the | ||
* distribution for a full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
|
||
package org.wildfly.test.security.common.elytron; | ||
|
||
import org.jboss.as.test.integration.management.util.CLIWrapper; | ||
|
||
/** | ||
* @author Jan Martiska | ||
*/ | ||
public class EJBApplicationSecurityDomainMapping implements ConfigurableElement { | ||
|
||
private final String appDomain; | ||
private final String elytronDomain; | ||
|
||
|
||
public EJBApplicationSecurityDomainMapping(String appDomain, String elytronDomain) { | ||
this.appDomain = appDomain; | ||
this.elytronDomain = elytronDomain; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return appDomain; | ||
} | ||
|
||
@Override | ||
public void create(CLIWrapper cli) throws Exception { | ||
cli.sendLine("/subsystem=ejb3/application-security-domain="+ appDomain +":add(security-domain="+elytronDomain+")"); | ||
} | ||
|
||
@Override | ||
public void remove(CLIWrapper cli) throws Exception { | ||
cli.sendLine("/subsystem=ejb3/application-security-domain="+ appDomain +":remove"); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...suite/shared/src/main/java/org/wildfly/test/security/common/elytron/PermissionMapper.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,49 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2017, Red Hat, Inc., and individual contributors | ||
* as indicated by the @author tags. See the copyright.txt file in the | ||
* distribution for a full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
|
||
package org.wildfly.test.security.common.elytron; | ||
|
||
/** | ||
* @author Jan Martiska | ||
*/ | ||
public interface PermissionMapper extends ConfigurableElement { | ||
|
||
enum MappingMode { | ||
AND("and"), | ||
FIRST("first"), | ||
OR("or"), | ||
UNLESS("unless"), | ||
XOR("xor"); | ||
|
||
MappingMode(String string) { | ||
this.string = string; | ||
} | ||
|
||
private String string; | ||
|
||
@Override | ||
public String toString() { | ||
return string; | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.