-
Notifications
You must be signed in to change notification settings - Fork 872
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
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
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
69 changes: 69 additions & 0 deletions
69
instrumentation/aws-sdk/aws-sdk-2.2/javaagent/src/s3PresignerTest/java/S3PresignerTest.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,69 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import io.opentelemetry.api.trace.Span; | ||
import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension; | ||
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; | ||
import java.time.Duration; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; | ||
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; | ||
import software.amazon.awssdk.regions.Region; | ||
import software.amazon.awssdk.services.s3.S3Client; | ||
import software.amazon.awssdk.services.s3.presigner.S3Presigner; | ||
import software.amazon.awssdk.services.s3.presigner.model.GetObjectPresignRequest; | ||
import software.amazon.awssdk.services.s3.presigner.model.PutObjectPresignRequest; | ||
|
||
class S3PresignerTest { | ||
@RegisterExtension | ||
static final InstrumentationExtension testing = AgentInstrumentationExtension.create(); | ||
|
||
private static final StaticCredentialsProvider CREDENTIALS_PROVIDER = | ||
StaticCredentialsProvider.create( | ||
AwsBasicCredentials.create("my-access-key", "my-secret-key")); | ||
|
||
private static S3Presigner s3Presigner; | ||
|
||
@BeforeAll | ||
static void setUp() { | ||
// trigger adding tracing interceptor | ||
S3Client.builder() | ||
.region(Region.AP_NORTHEAST_1) | ||
.credentialsProvider(CREDENTIALS_PROVIDER) | ||
.build(); | ||
|
||
s3Presigner = | ||
S3Presigner.builder() | ||
.region(Region.AP_NORTHEAST_1) | ||
.credentialsProvider(CREDENTIALS_PROVIDER) | ||
.build(); | ||
} | ||
|
||
@Test | ||
void testPresignGetObject() { | ||
s3Presigner.presignGetObject( | ||
GetObjectPresignRequest.builder() | ||
.getObjectRequest(builder -> builder.bucket("test").key("test")) | ||
.signatureDuration(Duration.ofDays(1)) | ||
.build()); | ||
|
||
assertThat(Span.current().getSpanContext().isValid()).isFalse(); | ||
} | ||
|
||
@Test | ||
void testPresignPutObject() { | ||
s3Presigner.presignPutObject( | ||
PutObjectPresignRequest.builder() | ||
.putObjectRequest(builder -> builder.bucket("test").key("test")) | ||
.signatureDuration(Duration.ofDays(1)) | ||
.build()); | ||
|
||
assertThat(Span.current().getSpanContext().isValid()).isFalse(); | ||
} | ||
} |
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