Skip to content

Commit

Permalink
add testName
Browse files Browse the repository at this point in the history
Signed-off-by: Neeharika-Sompalli <neeharika.sompalli@swirldslabs.com>
  • Loading branch information
Neeharika-Sompalli committed Apr 27, 2024
1 parent b89672d commit b6dc987
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ public record Hip540TestScenario(
@Nullable TokenKeyValidation keyValidation,
@NonNull Set<AuthorizingSignature> authorizingSignatures,
@NonNull ExpectedResponse expectedResponse,
@NonNull String registryNameSalt) {
@NonNull String registryNameSalt,
@NonNull String testName) {

public Hip540TestScenario(
@NonNull NonAdminTokenKey targetKey,
Expand All @@ -73,7 +74,8 @@ public Hip540TestScenario(
@NonNull ManagementAction action,
@Nullable TokenKeyValidation keyValidation,
@NonNull Set<AuthorizingSignature> authorizingSignatures,
@NonNull ExpectedResponse expectedResponse) {
@NonNull ExpectedResponse expectedResponse,
@NonNull String testName) {
this(
targetKey,
adminKeyState,
Expand All @@ -82,7 +84,8 @@ public Hip540TestScenario(
keyValidation,
authorizingSignatures,
expectedResponse,
randomAlphaNumeric(5));
randomAlphaNumeric(5),
testName);
}

public Hip540TestScenario {
Expand All @@ -93,6 +96,7 @@ public Hip540TestScenario(
requireNonNull(authorizingSignatures);
requireNonNull(expectedResponse);
requireNonNull(registryNameSalt);
requireNonNull(testName);
}

private static final String ADMIN_KEY = "adminKey";
Expand Down Expand Up @@ -239,7 +243,8 @@ private HapiTokenCreate creation() {

@Override
public String toString() {
return "Hip540TestScenario{" + "\n targetKey="
return "Hip540TestScenario {" + "\n testName="
+ testName + ",\n targetKey="
+ targetKey + ",\n adminKeyState="
+ adminKeyState + ",\n targetKeyState="
+ targetKeyState + ",\n action="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,15 @@
import java.util.List;
import java.util.stream.Stream;

/**
* A collection of all HIP-540 test scenarios.
*/
public class Hip540TestScenarios {
private Hip540TestScenarios() {
throw new UnsupportedOperationException("Utility Class");
}

/** The list of all HIP-540 test scenarios. */
public static final List<Hip540TestScenario> ALL_HIP_540_SCENARIOS = new ArrayList<>();

static {
Expand Down Expand Up @@ -84,23 +88,26 @@ private static void addPositiveNonAdminScenarios(
REPLACE,
FULL_VALIDATION,
EnumSet.of(EXTANT_NON_ADMIN, NEW_NON_ADMIN),
ExpectedResponse.atConsensus(SUCCESS)),
ExpectedResponse.atConsensus(SUCCESS),
"noAdminKeyReplaceAUsableRoleKeyWithUsableKeyFullValidationSucceeds"),
new Hip540TestScenario(
targetKey,
MISSING,
USABLE,
REPLACE,
NO_VALIDATION,
EnumSet.of(EXTANT_NON_ADMIN),
ExpectedResponse.atConsensus(SUCCESS)),
ExpectedResponse.atConsensus(SUCCESS),
"noAdminKeyReplaceAUsableRoleKeyWithUsableKeyNoValidationSucceeds"),
new Hip540TestScenario(
targetKey,
MISSING,
USABLE,
ZERO_OUT,
NO_VALIDATION,
EnumSet.of(EXTANT_NON_ADMIN),
ExpectedResponse.atConsensus(SUCCESS))));
ExpectedResponse.atConsensus(SUCCESS),
"noAdminKeyZeroOutAUsableRoleKeyNoValidationSucceeds")));
}

/**
Expand Down Expand Up @@ -128,31 +135,35 @@ private static void addNegativeNonAdminScenarios(
ManagementAction.REMOVE,
null,
EnumSet.of(EXTANT_NON_ADMIN),
ExpectedResponse.atConsensus(TOKEN_IS_IMMUTABLE)),
ExpectedResponse.atConsensus(TOKEN_IS_IMMUTABLE),
"noAdminKeyRemoveAUsableRoleKeyFails"),
new Hip540TestScenario(
targetKey,
MISSING,
USABLE,
REPLACE,
FULL_VALIDATION,
EnumSet.of(NEW_NON_ADMIN),
ExpectedResponse.atConsensus(INVALID_SIGNATURE)),
ExpectedResponse.atConsensus(INVALID_SIGNATURE),
"noAdminKeyReplaceAUsableRoleKeyFullValidationWithoutNewKeySignatureFails"),
new Hip540TestScenario(
targetKey,
MISSING,
USABLE,
ZERO_OUT,
FULL_VALIDATION,
EnumSet.of(EXTANT_NON_ADMIN),
ExpectedResponse.atConsensus(INVALID_SIGNATURE)),
ExpectedResponse.atConsensus(INVALID_SIGNATURE),
"noAdminKeyZeroOutAUsableRoleKeyFullValidationFails"),
new Hip540TestScenario(
targetKey,
MISSING,
USABLE,
REPLACE_WITH_INVALID,
FULL_VALIDATION,
EnumSet.of(EXTANT_NON_ADMIN),
ExpectedResponse.atIngest(targetKey.invalidKeyStatus()))));
ExpectedResponse.atIngest(targetKey.invalidKeyStatus()),
"noAdminKeyReplaceAUsableRoleKeyWithInvalidKeyFullValidationFails")));
}

/**
Expand All @@ -177,23 +188,26 @@ private static void addPositiveAdminOnlyScenarios(
ManagementAction.REMOVE,
null,
EnumSet.of(EXTANT_ADMIN),
ExpectedResponse.atConsensus(SUCCESS)),
ExpectedResponse.atConsensus(SUCCESS),
"withAdminKeyRemoveAUsableRoleKeySucceeds"),
new Hip540TestScenario(
targetKey,
USABLE,
USABLE,
REPLACE,
FULL_VALIDATION,
EnumSet.of(EXTANT_ADMIN),
ExpectedResponse.atConsensus(SUCCESS)),
ExpectedResponse.atConsensus(SUCCESS),
"withAdminKeyReplaceAUsableRoleKeyFullValidationSucceeds"),
new Hip540TestScenario(
targetKey,
USABLE,
USABLE,
ZERO_OUT,
FULL_VALIDATION,
EnumSet.of(EXTANT_ADMIN),
ExpectedResponse.atConsensus(SUCCESS))));
ExpectedResponse.atConsensus(SUCCESS),
"withAdminKeyZeroOutAUsableRoleKeyFullValidationSucceeds")));
}

/**
Expand All @@ -216,14 +230,16 @@ private static void addNegativeAdminOnlyScenarios(
ManagementAction.ADD,
NO_VALIDATION,
EnumSet.of(EXTANT_ADMIN),
ExpectedResponse.atConsensus(targetKey.tokenHasNoKeyStatus())),
ExpectedResponse.atConsensus(targetKey.tokenHasNoKeyStatus()),
"withAdminKeyAndMissingRoleKeyAddAUsableRoleKeyFails"),
new Hip540TestScenario(
targetKey,
USABLE,
MISSING,
ManagementAction.REMOVE,
null,
EnumSet.of(EXTANT_ADMIN),
ExpectedResponse.atConsensus(targetKey.tokenHasNoKeyStatus()))));
ExpectedResponse.atConsensus(targetKey.tokenHasNoKeyStatus()),
"withAdminKeyAndMissingRoleKeyRemoveRoleKeyFails")));
}
}

0 comments on commit b6dc987

Please sign in to comment.