Skip to content

Commit

Permalink
Change TEST-KEY-2 to have a different secret
Browse files Browse the repository at this point in the history
  • Loading branch information
jframe committed Jul 19, 2023
1 parent a59be16 commit 1007dae
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.hasSize;

import tech.pegasys.web3signer.dsl.signer.SignerConfigurationBuilder;
Expand Down Expand Up @@ -42,6 +43,8 @@ public class AzureKeyVaultAcceptanceTest extends AcceptanceTestBase {
private static final String VAULT_NAME = System.getenv("AZURE_KEY_VAULT_NAME");
private static final String EXPECTED_KEY =
"0x989d34725a2bfc3f15105f3f5fc8741f436c25ee1ee4f948e425d6bcb8c56bce6e06c269635b7e985a7ffa639e2409bf";
private static final String EXPECTED_TAGGED_KEY =
"0xb3b6fb8dab2a4c9d00247c18c4b7e91c62da3f7ad31c822c00097f93ac8ff2c4a526611f7d0a9c85946e93f371852c69";

@BeforeAll
public static void setup() {
Expand All @@ -62,7 +65,11 @@ void ensureSecretsInKeyVaultAreLoadedAndReportedViaPublicKeysApi() {
startSigner(configBuilder.build());

final Response response = signer.callApiPublicKeys(KeyType.BLS);
response.then().statusCode(200).contentType(ContentType.JSON).body("", hasItem(EXPECTED_KEY));
response
.then()
.statusCode(200)
.contentType(ContentType.JSON)
.body("", hasItems(EXPECTED_KEY, EXPECTED_TAGGED_KEY));

// Since our Azure vault contains some invalid keys, the healthcheck would return 503.
final Response healthcheckResponse = signer.healthcheck();
Expand All @@ -72,10 +79,10 @@ void ensureSecretsInKeyVaultAreLoadedAndReportedViaPublicKeysApi() {
.contentType(ContentType.JSON)
.body("status", equalTo("UP"));

// keys loaded are ACCTEST-MULTILINE-KEY (200), TEST-KEY (1), TEST-KEY-2 (1)
final String jsonBody = healthcheckResponse.body().asString();
int keysLoaded = getAzureBulkLoadingData(jsonBody, "keys-loaded");
assertThat(keysLoaded).isEqualTo(201);
assertThat(keysLoaded)
.isEqualTo(202); // ACCTEST-MULTILINE-KEY (200) + TEST-KEY (1) + TEST-KEY-2 (1)
}

@ParameterizedTest(name = "{index} - Using config file: {0}")
Expand All @@ -94,7 +101,11 @@ void azureSecretsViaTag(boolean useConfigFile) {
startSigner(configBuilder.build());

final Response response = signer.callApiPublicKeys(KeyType.BLS);
response.then().statusCode(200).contentType(ContentType.JSON).body("", hasItem(EXPECTED_KEY));
response
.then()
.statusCode(200)
.contentType(ContentType.JSON)
.body("", hasItem(EXPECTED_TAGGED_KEY));

// the tag filter will return only valid keys. The healtcheck should be UP
final Response healthcheckResponse = signer.healthcheck();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public class AzureKeyVaultTest {
private static final String SECRET_NAME = "TEST-KEY";
private static final String EXPECTED_KEY =
"3ee2224386c82ffea477e2adf28a2929f5c349165a4196158c7f3a2ecca40f35";
private static final String EXPECTED_KEY2 =
"0x5aba5b89c1d8b731dba1ba29128a4070df0dbfd7e0a67edb40ae7f860cd3ca1c";

@BeforeAll
public static void setup() {
Expand Down Expand Up @@ -109,7 +111,7 @@ void mapSecretsUsingTags() {
.filter(entry -> "TEST-KEY-2".equals(entry.getKey()))
.findFirst();
Assertions.assertThat(secretEntry).isPresent();
Assertions.assertThat(secretEntry.get().getValue()).isEqualTo(EXPECTED_KEY);
Assertions.assertThat(secretEntry.get().getValue()).isEqualTo(EXPECTED_KEY2);

// we should not encounter any error count
Assertions.assertThat(result.getErrorCount()).isZero();
Expand Down Expand Up @@ -178,6 +180,6 @@ void azureVaultThrowsAwayObjectsWhichMapToNull() {
final Optional<SimpleEntry<String, String>> myBlsEntry =
entries.stream().filter(e -> e.getKey().equals("TEST-KEY-2")).findAny();
Assertions.assertThat(myBlsEntry).isPresent();
Assertions.assertThat(myBlsEntry.get().getValue()).isEqualTo(EXPECTED_KEY);
Assertions.assertThat(myBlsEntry.get().getValue()).isEqualTo(EXPECTED_KEY2);
}
}

0 comments on commit 1007dae

Please sign in to comment.