mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
test(cognito): read the MFA config tests in their execution order
The methods were laid out 1, 2, 3, 4, 5, 8, 6, 10, 7, 9, 11, 12, 13, an artifact of adding cases across three review rounds. The chain is stateful, so a reader following the pool through it had to jump around the file. Pure move: the methods are reordered to match their @Order values, no annotation value and no test body is changed, so the execution order is exactly what it was.
This commit is contained in:
1 parent
a0860948b1
commit
63086a30f5
1 file changed
+42
-42
+42
-42
@@ -106,6 +106,38 @@ class CognitoSetUserPoolMfaConfigIntegrationTest {
|
||||
assertTrue(body.contains("can't turn off MFA and configure an MFA together"), body);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(6)
|
||||
void turningMfaOffAlongsideEmailOrSmsIsRejected() {
|
||||
// Measured: the rule covers EmailMfaConfiguration and SmsMfaConfiguration too, not
|
||||
// just the software token, and it fires on the member being present rather than on
|
||||
// its value.
|
||||
for (String factor : new String[] {
|
||||
"\"EmailMfaConfiguration\":{\"Message\":\"code {####}\",\"Subject\":\"code\"}",
|
||||
"\"SmsMfaConfiguration\":{\"SmsAuthenticationMessage\":\"code {####}\"}"}) {
|
||||
String body = cognitoAction("SetUserPoolMfaConfig", """
|
||||
{"UserPoolId":"%s","MfaConfiguration":"OFF",%s}
|
||||
""".formatted(poolId, factor))
|
||||
.then().statusCode(400).extract().asString();
|
||||
assertTrue(body.contains("InvalidParameterException"), body);
|
||||
assertTrue(body.contains("can't turn off MFA and configure an MFA together"), body);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(7)
|
||||
void enablingMfaWithNoFactorAtAllIsRejected() {
|
||||
for (String mode : new String[] {"ON", "OPTIONAL"}) {
|
||||
String body = cognitoAction("SetUserPoolMfaConfig", """
|
||||
{"UserPoolId":"%s","MfaConfiguration":"%s"}
|
||||
""".formatted(poolId, mode))
|
||||
.then().statusCode(400).extract().asString();
|
||||
assertTrue(body.contains("InvalidParameterException"), body);
|
||||
assertTrue(body.contains("SMS MFA, Email MFA, or Software Token MFA must be enabled"),
|
||||
body);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(8)
|
||||
void omittingMfaConfigurationEntirelyResetsThePoolToOff() throws Exception {
|
||||
@@ -126,21 +158,16 @@ class CognitoSetUserPoolMfaConfigIntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(6)
|
||||
void turningMfaOffAlongsideEmailOrSmsIsRejected() {
|
||||
// Measured: the rule covers EmailMfaConfiguration and SmsMfaConfiguration too, not
|
||||
// just the software token, and it fires on the member being present rather than on
|
||||
// its value.
|
||||
for (String factor : new String[] {
|
||||
"\"EmailMfaConfiguration\":{\"Message\":\"code {####}\",\"Subject\":\"code\"}",
|
||||
"\"SmsMfaConfiguration\":{\"SmsAuthenticationMessage\":\"code {####}\"}"}) {
|
||||
String body = cognitoAction("SetUserPoolMfaConfig", """
|
||||
{"UserPoolId":"%s","MfaConfiguration":"OFF",%s}
|
||||
""".formatted(poolId, factor))
|
||||
.then().statusCode(400).extract().asString();
|
||||
assertTrue(body.contains("InvalidParameterException"), body);
|
||||
assertTrue(body.contains("can't turn off MFA and configure an MFA together"), body);
|
||||
}
|
||||
@Order(9)
|
||||
void aDisabledFactorStillCountsAsConfigured() throws Exception {
|
||||
// The message says "must be enabled", but the live service accepts ON alongside
|
||||
// SoftwareTokenMfaConfiguration{Enabled:false}: presence is what it checks.
|
||||
JsonNode set = cognitoJson("SetUserPoolMfaConfig", """
|
||||
{"UserPoolId":"%s","MfaConfiguration":"ON",
|
||||
"SoftwareTokenMfaConfiguration":{"Enabled":false}}
|
||||
""".formatted(poolId));
|
||||
assertEquals("ON", set.path("MfaConfiguration").asText());
|
||||
assertEquals(false, set.path("SoftwareTokenMfaConfiguration").path("Enabled").asBoolean());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -165,33 +192,6 @@ class CognitoSetUserPoolMfaConfigIntegrationTest {
|
||||
assertTrue(body.contains("SMS MFA, Email MFA, or Software Token MFA must be enabled"), body);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(7)
|
||||
void enablingMfaWithNoFactorAtAllIsRejected() {
|
||||
for (String mode : new String[] {"ON", "OPTIONAL"}) {
|
||||
String body = cognitoAction("SetUserPoolMfaConfig", """
|
||||
{"UserPoolId":"%s","MfaConfiguration":"%s"}
|
||||
""".formatted(poolId, mode))
|
||||
.then().statusCode(400).extract().asString();
|
||||
assertTrue(body.contains("InvalidParameterException"), body);
|
||||
assertTrue(body.contains("SMS MFA, Email MFA, or Software Token MFA must be enabled"),
|
||||
body);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(9)
|
||||
void aDisabledFactorStillCountsAsConfigured() throws Exception {
|
||||
// The message says "must be enabled", but the live service accepts ON alongside
|
||||
// SoftwareTokenMfaConfiguration{Enabled:false}: presence is what it checks.
|
||||
JsonNode set = cognitoJson("SetUserPoolMfaConfig", """
|
||||
{"UserPoolId":"%s","MfaConfiguration":"ON",
|
||||
"SoftwareTokenMfaConfiguration":{"Enabled":false}}
|
||||
""".formatted(poolId));
|
||||
assertEquals("ON", set.path("MfaConfiguration").asText());
|
||||
assertEquals(false, set.path("SoftwareTokenMfaConfiguration").path("Enabled").asBoolean());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(11)
|
||||
void invalidMfaConfigurationIsRejected() {
|
||||
|
||||
Reference in new issue
Block a user