-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #905 from amido/feature/4944-4965-XRay-And-Secrets
feature/4944-4965-Added XRay and AWS Secret Support
- Loading branch information
Showing
12 changed files
with
498 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export BASE_URL=http://localhost:9000 | ||
|
||
mvn -f ../api-tests/pom.xml clean verify | ||
open ../api-tests/target/site/serenity/index.html | ||
|
||
mvn -f ../api-tests-karate/pom.xml clean test | ||
open ../api-tests-karate/target/surefire-reports/karate-summary.html |
25 changes: 25 additions & 0 deletions
25
java/src/main/java/com/amido/stacks/workloads/menu/api/v1/SecretsController.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,25 @@ | ||
package com.amido.stacks.workloads.menu.api.v1; | ||
|
||
import com.amido.stacks.workloads.menu.service.v1.SecretsService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping( | ||
path = "/v1/secrets", | ||
produces = MediaType.APPLICATION_JSON_VALUE + "; charset=utf-8") | ||
@RequiredArgsConstructor | ||
public class SecretsController { | ||
|
||
private final SecretsService secretsService; | ||
|
||
@GetMapping | ||
public ResponseEntity<String> getSecrets() { | ||
|
||
return ResponseEntity.ok(secretsService.getSecrets()); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
java/src/main/java/com/amido/stacks/workloads/menu/service/v1/SecretsService.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,33 @@ | ||
package com.amido.stacks.workloads.menu.service.v1; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@Slf4j | ||
public class SecretsService { | ||
|
||
@Value(value = "${stacks-secret-1:secret-not-available}") | ||
private String secret1; | ||
|
||
@Value(value = "${stacks-secret-2:secret-not-available}") | ||
private String secret2; | ||
|
||
@Value(value = "${stacks-secret-3:secret-not-available}") | ||
private String secret3; | ||
|
||
@Value(value = "${stacks-secret-4:secret-not-available}") | ||
private String secret4; | ||
|
||
public String getSecrets() { | ||
|
||
log.info("Getting some secrets..."); | ||
|
||
return showSecrets(); | ||
} | ||
|
||
private String showSecrets() { | ||
return "Secrets -> " + secret1 + ", " + secret2 + ", " + secret3 + ", " + secret4; | ||
} | ||
} |
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,9 @@ | ||
spring.config.import: | ||
- optional:aws-secretsmanager:/stacks-secret/example-1/ | ||
- optional:aws-secretsmanager:/stacks-secret/example-2/ | ||
|
||
aws: | ||
xray: | ||
enabled: ${AWS_XRAY_ENABLED:false} | ||
secretsmanager: | ||
enabled: ${AWS_SECRETS_ENABLED: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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
azure: | ||
application-insights: | ||
instrumentation-key: xxxxxx | ||
enabled: true | ||
keyvault: | ||
enabled: false | ||
uri: https://amido.stacks-tmp.vault.azure.net/ | ||
client-id: xxxxxx | ||
client-key: xxxxxx | ||
tenant-id: xxxxxx |
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,9 @@ | ||
spring.config.import: | ||
- optional:aws-secretsmanager:/stacks-secret/example-1/ | ||
- optional:aws-secretsmanager:/stacks-secret/example-2/ | ||
|
||
aws: | ||
xray: | ||
enabled: ${AWS_XRAY_ENABLED:false} | ||
secretsmanager: | ||
enabled: ${AWS_SECRETS_ENABLED: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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
azure: | ||
application-insights: | ||
instrumentation-key: xxxxxx | ||
enabled: true | ||
keyvault: | ||
enabled: false | ||
uri: https://amido.stacks-tmp.vault.azure.net/ | ||
client-id: xxxxxx | ||
client-key: xxxxxx | ||
tenant-id: xxxxxx |
55 changes: 55 additions & 0 deletions
55
java/src/test/java/com/amido/stacks/workloads/menu/api/v1/SecretsControllerTest.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 @@ | ||
package com.amido.stacks.workloads.menu.api.v1; | ||
|
||
import static org.assertj.core.api.BDDAssertions.then; | ||
|
||
import com.amido.stacks.workloads.Application; | ||
import com.amido.stacks.workloads.util.TestHelper; | ||
import org.junit.jupiter.api.Tag; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.boot.test.web.client.TestRestTemplate; | ||
import org.springframework.boot.web.server.LocalServerPort; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.test.context.ActiveProfiles; | ||
import org.springframework.test.context.TestPropertySource; | ||
|
||
@SpringBootTest( | ||
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, | ||
classes = Application.class, | ||
properties = { | ||
"stacks-secret-1=SEC1", | ||
"stacks-secret-2=SEC2", | ||
"stacks-secret-3=SEC3", | ||
"stacks-secret-4=SEC4" | ||
}) | ||
@TestPropertySource( | ||
properties = { | ||
"management.port=0", | ||
"aws.xray.enabled=false", | ||
"aws.secretsmanager.enabled=false" | ||
}) | ||
@Tag("Integration") | ||
@ActiveProfiles("test") | ||
class SecretsControllerTest { | ||
|
||
public static final String GET_SECRETS = "/v1/secrets"; | ||
|
||
@LocalServerPort private int port; | ||
|
||
@Autowired private TestRestTemplate testRestTemplate; | ||
|
||
@Test | ||
void shouldReturnValidSecrets() { | ||
// Given | ||
|
||
// When | ||
var response = | ||
this.testRestTemplate.getForEntity( | ||
String.format("%s/v1/secrets", TestHelper.getBaseURL(port)), String.class); | ||
|
||
// Then | ||
then(response.getStatusCode()).isEqualTo(HttpStatus.OK); | ||
then(response.getBody()).isEqualTo("Secrets -> SEC1, SEC2, SEC3, SEC4"); | ||
} | ||
} |
Oops, something went wrong.