-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WFLY-18466] ejb-security-context-propagation Quickstart Common Enhan…
…cements CY2023Q3
- Loading branch information
Prarthona Paul
committed
Oct 19, 2023
1 parent
4b23029
commit bf4701d
Showing
7 changed files
with
298 additions
and
37 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
.github/workflows/quickstart_ejb_security_context_propagation_ci.yml
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,21 @@ | ||
name: WildFly ejb-security-context-propagation Quickstart CI | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened, ready_for_review] | ||
paths: | ||
- 'ejb-security-context-propagation/**' | ||
- '.github/workflows/quickstart_ci.yml' | ||
|
||
# Only run the latest job | ||
concurrency: | ||
group: '${{ github.workflow }} @ ${{ github.ref || github.run_id }}' | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
call-quickstart_ci: | ||
uses: ./.github/workflows/quickstart_ci.yml | ||
with: | ||
QUICKSTART_PATH: ejb-security-context-propagation | ||
TEST_PROVISIONED_SERVER: true | ||
TEST_OPENSHIFT: false |
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
56 changes: 56 additions & 0 deletions
56
...n/src/main/java/org/jboss/as/quickstarts/ejb_security_context_propagation/EJBServlet.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,56 @@ | ||
/* | ||
* Copyright 2023 JBoss by Red Hat. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.jboss.as.quickstarts.ejb_security_context_propagation; | ||
|
||
import java.io.IOException; | ||
import java.io.PrintWriter; | ||
|
||
import jakarta.servlet.annotation.WebServlet; | ||
import jakarta.servlet.http.HttpServlet; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
/** | ||
* <p> | ||
* A simple servlet taking advantage of features added in 3.0. | ||
* </p> | ||
* | ||
* <p> | ||
* The servlet is registered and mapped to /EJBServlet using the {@linkplain WebServlet | ||
* @HttpServlet}. | ||
* </p> | ||
* | ||
* @author Prarthona Paul | ||
* | ||
*/ | ||
|
||
@WebServlet("/ejb-security-context-propagation") | ||
public class EJBServlet extends HttpServlet { | ||
|
||
static String PAGE_HEADER = "<html><head><title>helloworld</title></head><body>"; | ||
|
||
static String PAGE_FOOTER = "</body></html>"; | ||
|
||
@Override | ||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { | ||
resp.setContentType("text/html"); | ||
PrintWriter writer = resp.getWriter(); | ||
writer.println(PAGE_HEADER); | ||
writer.println("<h1> Hello World! </h1>"); | ||
writer.println(PAGE_FOOTER); | ||
writer.close(); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
ejb-security-context-propagation/src/main/webapp/WEB-INF/beans.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,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright 2023 JBoss by Red Hat. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
|
||
<!-- Marker file indicating CDI should be enabled --> | ||
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation=" | ||
http://xmlns.jcp.org/xml/ns/javaee | ||
http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd" bean-discovery-mode="all"> | ||
</beans> |
20 changes: 20 additions & 0 deletions
20
ejb-security-context-propagation/src/main/webapp/index.html
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,20 @@ | ||
<!-- | ||
Copyright 2023 JBoss by Red Hat. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<!-- Plain HTML page that kicks us into the app --> | ||
|
||
<html> | ||
<head> | ||
<meta http-equiv="Refresh" content="0; URL=ejb-security-context-propagation"> | ||
</head> | ||
</html> |
58 changes: 58 additions & 0 deletions
58
...c/test/java/org/jboss/as/quickstarts/ejb_security_context_propagation/BasicRuntimeIT.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,58 @@ | ||
/* | ||
* Copyright 2023 JBoss by Red Hat. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jboss.as.quickstarts.ejb_security_context_propagation; | ||
|
||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
import java.net.http.HttpClient; | ||
import java.net.http.HttpRequest; | ||
import java.net.http.HttpResponse; | ||
import java.time.Duration; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
/** | ||
* The very basic runtime integration testing. | ||
* @author Prarthona Paul | ||
* @author emartins | ||
*/ | ||
public class BasicRuntimeIT { | ||
private static final String DEFAULT_SERVER_HOST = "http://localhost:8080/ejb-security-context-propagation"; | ||
|
||
@Test | ||
public void testHTTPEndpointIsAvailable() throws IOException, InterruptedException, URISyntaxException { | ||
String serverHost = System.getenv("SERVER_HOST"); | ||
if (serverHost == null) { | ||
serverHost = System.getProperty("server.host"); | ||
} | ||
if (serverHost == null) { | ||
serverHost = DEFAULT_SERVER_HOST; | ||
} | ||
final HttpRequest request = HttpRequest.newBuilder() | ||
.uri(new URI(serverHost+"/")) | ||
.GET() | ||
.build(); | ||
final HttpClient client = HttpClient.newBuilder() | ||
.followRedirects(HttpClient.Redirect.ALWAYS) | ||
.connectTimeout(Duration.ofMinutes(1)) | ||
.build(); | ||
final HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString()); | ||
assertEquals(200, response.statusCode()); | ||
} | ||
} |