Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

port JCA enterpriseApp test bucket to open liberty #10567

Merged
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
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2017 IBM Corporation and others.
* Copyright (c) 2017,2020 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand All @@ -20,6 +20,8 @@
@SuiteClasses({
AlwaysPassesTest.class,
DerbyResourceAdapterTest.class,
DerbyResourceAdapterSecurityTest.class
DerbyResourceAdapterSecurityTest.class,
LoginModuleInStandaloneResourceAdapterTest.class
})
public class FATSuite {}
public class FATSuite {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*******************************************************************************
* Copyright (c) 2017, 2020 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package com.ibm.ws.jca.fat.derbyra;

import java.io.File;

import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;

import com.ibm.websphere.simplicity.ShrinkHelper;

import componenttest.annotation.Server;
import componenttest.custom.junit.runner.FATRunner;
import componenttest.topology.impl.LibertyServer;
import componenttest.topology.utils.FATServletClient;

@RunWith(FATRunner.class)
public class LoginModuleInStandaloneResourceAdapterTest extends FATServletClient {

private static final String APP = "derbyRAApp";
private static final String WAR_NAME = "fvtweb";
private static final String DerbyRAServlet = "fvtweb/DerbyRAServlet";
private static final String DerbyRAAnnoServlet = "fvtweb/DerbyRAAnnoServlet";

@Server("com.ibm.ws.jca.fat.derbyra.loginModuleInRA")
public static LibertyServer server;

@BeforeClass
public static void setUp() throws Exception {

WebArchive war = ShrinkWrap.create(WebArchive.class, WAR_NAME + ".war");
war.addPackage("web");
war.addAsWebInfResource(new File("test-applications/fvtweb/resources/WEB-INF/ibm-web-bnd.xml"));
war.addAsWebInfResource(new File("test-applications/fvtweb/resources/WEB-INF/web.xml"));

EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, APP + ".ear");
ear.addAsModule(war);
ShrinkHelper.addDirectory(ear, "lib/LibertyFATTestFiles/derbyRAApp");
ShrinkHelper.exportToServer(server, "apps", ear);

ResourceAdapterArchive rar = ShrinkWrap.create(ResourceAdapterArchive.class, "DerbyLMRA.rar");
rar.as(JavaArchive.class).addPackage("fat.derbyra.resourceadapter");
rar.addAsManifestResource(new File("test-resourceadapters/fvt-resourceadapter/resources/META-INF/ra.xml"));
rar.addAsManifestResource(new File("test-resourceadapters/fvt-resourceadapter/resources/META-INF/permissions.xml"));

rar.addAsLibrary(new File("publish/shared/resources/derby/derby.jar"));

rar.as(JavaArchive.class).addPackage("com.ibm.ws.jca.fat.security.login");
// TODO switch to JAR within resource adapter once implemented to properly read from the rar
//JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "loginModule.jar");
//jar.addPackage("com.ibm.ws.jca.fat.security.login");
//rar.addAsLibraries(jar);

ShrinkHelper.exportToServer(server, "connectors", rar);

server.addInstalledAppForValidation(APP);
server.startServer();
}

@AfterClass
public static void tearDown() throws Exception {
server.stopServer("SRVE9967W"); // The manifest class path derbyLocale_cs.jar can not be found in jar file wsjar:file:/C:/Users/IBM_ADMIN/Documents/workspace/build.image/wlp/usr/servers/com.ibm.ws.jca.fat.derbyra/connectors/DerbyRA.rar!/derby.jar or its parent.
// This may just be because we don't care about including manifest files in our test buckets, if that's the case, we can ignore this.
}

@Test
public void testJCADataSourceResourceRefLoginModuleInRAR() throws Exception {
FATServletClient.runTest(server, DerbyRAServlet, "testJCADataSourceResourceRefSecurity");
}

@Test
public void testCustomLoginModuleInRARCF() throws Exception {
FATServletClient.runTest(server, DerbyRAAnnoServlet, "testCustomLoginModuleCF");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
com.ibm.ws.logging.trace.specification=*=event=enabled:logservice=all:rarInstall=all:WAS.j2c=all:test=all:web.*=all:com.ibm.ws.security.jca.*=all
com.ibm.ws.logging.max.file.size=0
osgi.console=5678

bootstrap.include=../testports.properties
ds.lock.timeout.milliseconds=30000
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<!--
Copyright (c) 2020 IBM Corporation and others.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html

Contributors:
IBM Corporation - initial API and implementation
-->
<server>
<featureManager>
<feature>appSecurity-2.0</feature>
<feature>componenttest-1.0</feature>
<feature>concurrent-1.0</feature>
<feature>jca-1.7</feature>
<feature>jndi-1.0</feature>
<feature>servlet-4.0</feature>
</featureManager>

<include optional="true" location="../fatTestPorts.xml"/>

<variable name="onError" value="FAIL"/>

<application location="derbyRAApp.ear"/>

<resourceAdapter id="DerbyLMRA" location="${server.config.dir}/connectors/DerbyLMRA.rar"/>

<!-- injected into application, but otherwise not used by tests -->
<adminObject jndiName="eis/bootstrapContext">
<properties.DerbyLMRA.BootstrapContext/>
</adminObject>

<!-- injected into application, but otherwise not used by tests -->
<adminObject jndiName="eis/map1">
<properties.DerbyLMRA.Map tableName="MAP1"/>
</adminObject>

<connectionFactory jndiName="eis/ds1">
<containerAuthData user="DS1USER" password="{xor}GwxuDwgb"/>
<properties.DerbyLMRA/>
</connectionFactory>

<jaasLoginContextEntry id="myJAASLoginEntry" name="myJAASLoginEntryName">
<!-- TODO replace with classProviderRef="DerbyLMRA" once implemented -->
<loginModule className="com.ibm.ws.jca.fat.security.login.TestLoginModule" libraryRef="temp"/>
</jaasLoginContextEntry>

<!-- TODO remove this -->
<library id="temp">
<file name="${server.config.dir}/connectors/DerbyLMRA.rar"/>
</library>

<!-- "APP" is the default schema for Derby -->
<authData id="APP" user="APP" password="{aes}APb9ZaYzUL+JsfFD/OOBGaPM0evjmx5AnvmzbaKgffyX"/>

<!-- TODO go through these copied permissions once we are properly loading the login module from the resource adapter -->
<!--
NOTE: for this bucket to run cleanly with j2sec enabled with IBM JDK, the following permission must
be manually granted in the java.policy file at $JAVA_HOME/jre/lib/security/java.policy:
permission java.lang.RuntimePermission "accessClassInPackage.com.sun.xml.internal.bind.v2.runtime.reflect";
-->
<javaPermission className="java.util.PropertyPermission" name="*" actions="read"/>
<javaPermission codebase="${server.config.dir}/connectors/DerbyLMRA.rar" className="javax.security.auth.AuthPermission" name="modifyPrivateCredentials"/>
<javaPermission className="javax.security.auth.AuthPermission" name="createLoginContext.myJAASLoginEntryName"/>
<javaPermission className="javax.security.auth.PrivateCredentialPermission" signedBy="javax.resource.spi.security.PasswordCredential" principalType="*" principalName="*" actions="read"/>
<javaPermission className="javax.security.auth.PrivateCredentialPermission" signedBy="java.util.HashMap" principalType="*" principalName="*" actions="read"/>
<javaPermission className="java.lang.RuntimePermission" name="modifyThread"/>
<javaPermission className="java.lang.RuntimePermission" name="getClassLoader"/>
<javaPermission className="javax.management.MBeanPermission" name="*" actions="*"/>
<javaPermission className="javax.management.MBeanServerPermission" name="createMBeanServer"/>
</server>
9 changes: 9 additions & 0 deletions dev/com.ibm.ws.jca_fat_enterpriseApp/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="fat/src"/>
<classpathentry kind="src" path="test-applications/fvtweb/src"/>
<classpathentry kind="src" path="test-resourceadapters/enterpriseAppRA/src"/>
<classpathentry kind="con" path="aQute.bnd.classpath.container"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="output" path="bin"/>
</classpath>
23 changes: 23 additions & 0 deletions dev/com.ibm.ws.jca_fat_enterpriseApp/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.ibm.ws.jca_fat_enterpriseApp</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>bndtools.core.bndbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>bndtools.core.bndnature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
compileErrorAction=build
eclipse.preferences.version=1
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#Ant properties
#Automatically generated by the ant prepare.settings.files task
eclipse.preferences.version=1
encoding/<project>=UTF-8
Loading