-
Notifications
You must be signed in to change notification settings - Fork 879
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add security manager test app (#8115)
For testing #7983
- Loading branch information
Showing
6 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
.github/workflows/pr-smoke-test-security-manager-images.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,14 @@ | ||
name: PR build Security Manager test app images for smoke tests | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- 'smoke-tests/images/security-manager/**' | ||
- '.github/workflows/pr-smoke-test-security-manager-images.yml' | ||
|
||
jobs: | ||
build: | ||
uses: ./.github/workflows/reusable-smoke-test-images.yml | ||
with: | ||
project: ":smoke-tests:images:security-manager" | ||
cache-read-only: true |
23 changes: 23 additions & 0 deletions
23
.github/workflows/publish-smoke-test-security-manager-images.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,23 @@ | ||
name: Publish Security Manager test app images for smoke tests | ||
|
||
on: | ||
push: | ||
paths: | ||
- 'smoke-tests/images/security-manager/**' | ||
- '.github/workflows/publish-smoke-test-security-manager-images.yml' | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
publish: | ||
uses: ./.github/workflows/reusable-smoke-test-images.yml | ||
with: | ||
project: ":smoke-tests:images:security-manager" | ||
publish: true | ||
|
||
open-issue-on-failure: | ||
needs: | ||
- publish | ||
if: failure() && github.run_attempt == 1 | ||
uses: ./.github/workflows/reusable-open-issue-on-failure.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
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,33 @@ | ||
import java.time.LocalDateTime | ||
import java.time.format.DateTimeFormatter | ||
|
||
plugins { | ||
id("otel.java-conventions") | ||
|
||
id("com.google.cloud.tools.jib") | ||
} | ||
|
||
dependencies { | ||
implementation(platform("io.opentelemetry:opentelemetry-bom:1.0.0")) | ||
|
||
implementation("io.opentelemetry:opentelemetry-api") | ||
} | ||
|
||
val targetJDK = project.findProperty("targetJDK") ?: "11" | ||
|
||
val tag = findProperty("tag") | ||
?: DateTimeFormatter.ofPattern("yyyyMMdd.HHmmSS").format(LocalDateTime.now()) | ||
|
||
java { | ||
// needed by jib to detect java version used in project | ||
// for jdk9+ jib uses an entrypoint that doesn't work with jdk8 | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
|
||
jib { | ||
from.image = "openjdk:$targetJDK" | ||
to.image = "ghcr.io/open-telemetry/opentelemetry-java-instrumentation/smoke-test-security-manager:jdk$targetJDK-$tag" | ||
container.mainClass = "io.opentelemetry.smoketest.securitymanager.Main" | ||
container.jvmFlags = listOf("-Djava.security.manager", "-Djava.security.policy=/app/resources/security.policy") | ||
} |
28 changes: 28 additions & 0 deletions
28
...mages/security-manager/src/main/java/io/opentelemetry/smoketest/securitymanager/Main.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,28 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.smoketest.securitymanager; | ||
|
||
import io.opentelemetry.api.GlobalOpenTelemetry; | ||
import io.opentelemetry.api.trace.Span; | ||
import io.opentelemetry.api.trace.Tracer; | ||
import io.opentelemetry.context.Scope; | ||
|
||
public class Main { | ||
|
||
private Main() {} | ||
|
||
@SuppressWarnings("SystemOut") | ||
public static void main(String[] args) { | ||
Tracer tracer = GlobalOpenTelemetry.get().getTracer("test-tracer"); | ||
Span span = tracer.spanBuilder("test").startSpan(); | ||
try (Scope ignore = span.makeCurrent()) { | ||
// empty | ||
} finally { | ||
span.end(); | ||
} | ||
System.out.println("completed successfully"); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
smoke-tests/images/security-manager/src/main/resources/security.policy
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,10 @@ | ||
// io.opentelemetry.context.LazyStorage reads system properties | ||
// grant permission to read these to test application code, but not the agent code | ||
grant codeBase "file:/app/classes/" { | ||
permission java.util.PropertyPermission "io.opentelemetry.context.contextStorageProvider", "read"; | ||
permission java.util.PropertyPermission "io.opentelemetry.context.enableStrictContext", "read"; | ||
}; | ||
grant codeBase "file:/app/libs/-" { | ||
permission java.util.PropertyPermission "io.opentelemetry.context.contextStorageProvider", "read"; | ||
permission java.util.PropertyPermission "io.opentelemetry.context.enableStrictContext", "read"; | ||
}; |