Skip to content

Commit 553915c

Browse files
authored
Support stage property on Breached Password Detection (#456)
1 parent 48de95c commit 553915c

5 files changed

Lines changed: 103 additions & 2 deletions

File tree

src/main/java/com/auth0/json/mgmt/attackprotection/BreachedPassword.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public class BreachedPassword {
2323
private List<String> shields;
2424
@JsonProperty("admin_notification_frequency")
2525
private List<String> adminNotificationFrequency;
26+
@JsonProperty("stage")
27+
private BreachedPasswordStage stage;
2628

2729
/**
2830
* @return whether or not breached password detection is active.
@@ -84,5 +86,19 @@ public void setAdminNotificationFrequency(List<String> adminNotificationFrequenc
8486
this.adminNotificationFrequency = adminNotificationFrequency;
8587
}
8688

89+
/**
90+
* @return the per-stage configuration options
91+
*/
92+
public BreachedPasswordStage getStage() {
93+
return stage;
94+
}
95+
96+
/**
97+
* Sets the per-stage configuration options.
98+
* @param stage the per-stage configuration options.
99+
*/
100+
public void setStage(BreachedPasswordStage stage) {
101+
this.stage = stage;
102+
}
87103

88104
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.auth0.json.mgmt.attackprotection;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import com.fasterxml.jackson.annotation.JsonInclude;
5+
import com.fasterxml.jackson.annotation.JsonProperty;
6+
7+
/**
8+
* Represents the BreachedPassword stage configuration options
9+
*
10+
* @see com.auth0.client.mgmt.AttackProtectionEntity
11+
*/
12+
@JsonIgnoreProperties(ignoreUnknown = true)
13+
@JsonInclude(JsonInclude.Include.NON_NULL)
14+
public class BreachedPasswordStage {
15+
16+
@JsonProperty("pre-user-registration")
17+
BreachedPasswordStageEntry preUserRegistrationStage;
18+
19+
/**
20+
* Get the pre-user-registration stage entry.
21+
* @return the pre-user-registration stage entry.
22+
*/
23+
public BreachedPasswordStageEntry getPreUserRegistrationStage() {
24+
return preUserRegistrationStage;
25+
}
26+
27+
/**
28+
* Set the pre-user-registration stage entry.
29+
* @param preUserRegistrationStage the pre-user-registration stage entry.
30+
*/
31+
public void setPreUserRegistrationStage(BreachedPasswordStageEntry preUserRegistrationStage) {
32+
this.preUserRegistrationStage = preUserRegistrationStage;
33+
}
34+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.auth0.json.mgmt.attackprotection;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import com.fasterxml.jackson.annotation.JsonInclude;
5+
import com.fasterxml.jackson.annotation.JsonProperty;
6+
7+
import java.util.List;
8+
9+
/**
10+
* Represents the per-stage configuration options for BreachedPasswordStage
11+
*
12+
* @see Stage
13+
* @see com.auth0.client.mgmt.AttackProtectionEntity
14+
*/
15+
@JsonIgnoreProperties(ignoreUnknown = true)
16+
@JsonInclude(JsonInclude.Include.NON_NULL)
17+
public class BreachedPasswordStageEntry {
18+
@JsonProperty("shields")
19+
private List<String> shields;
20+
21+
/**
22+
* Get the shields for this Stage entry
23+
* @return the shields for this Stage entry
24+
*/
25+
public List<String> getShields() {
26+
return shields;
27+
}
28+
29+
/**
30+
* Sets the shields for this Stage entry
31+
* @param shields the shields for this Stage entry
32+
*/
33+
public void setShields(List<String> shields) {
34+
this.shields = shields;
35+
}
36+
}

src/test/java/com/auth0/client/mgmt/AttackProtectionEntityTest.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,22 @@ public void shouldListBreachedPasswordSettings() throws Exception {
3939
assertThat(response.getAdminNotificationFrequency(), is(notNullValue()));
4040
assertThat(response.getAdminNotificationFrequency().size(), is(2));
4141
assertThat(response.getAdminNotificationFrequency(), contains("immediately", "weekly"));
42+
assertThat(response.getStage().getPreUserRegistrationStage().getShields(), contains("admin_notification"));
4243
}
4344

4445
@Test
4546
public void shouldUpdateBreachedPasswordSettings() throws Exception {
47+
BreachedPasswordStage stage = new BreachedPasswordStage();
48+
BreachedPasswordStageEntry preReg = new BreachedPasswordStageEntry();
49+
preReg.setShields(Arrays.asList("admin_notification"));
50+
stage.setPreUserRegistrationStage(preReg);
51+
4652
BreachedPassword breachedPassword = new BreachedPassword();
4753
breachedPassword.setEnabled(true);
4854
breachedPassword.setMethod("standard");
4955
breachedPassword.setAdminNotificationFrequency(Arrays.asList("immediately", "daily"));
5056
breachedPassword.setShields(Arrays.asList("admin_notification", "block"));
57+
breachedPassword.setStage(stage);
5158

5259
Request<BreachedPassword> request = api.attackProtection().updateBreachedPasswordSettings(breachedPassword);
5360
assertThat(request, is(notNullValue()));
@@ -63,11 +70,12 @@ public void shouldUpdateBreachedPasswordSettings() throws Exception {
6370
Map<String, Object> body = bodyFromRequest(recordedRequest);
6471
System.out.println(body);
6572

66-
assertThat(body.size(), is(4));
73+
assertThat(body.size(), is(5));
6774
assertThat(body.get("method"), is("standard"));
6875
assertThat(body.get("enabled"), is(true));
6976
assertThat(((List<?>)body.get("shields")).size(), is(2));
7077
assertThat((List<?>) body.get("shields"), contains("admin_notification", "block"));
78+
assertThat(body.get("stage"), is(notNullValue()));
7179

7280
assertThat(response, is(notNullValue()));
7381
}

src/test/resources/mgmt/breached_password_settings.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,12 @@
88
"immediately",
99
"weekly"
1010
],
11-
"method": "standard"
11+
"method": "standard",
12+
"stage": {
13+
"pre-user-registration": {
14+
"shields": [
15+
"admin_notification"
16+
]
17+
}
18+
}
1219
}

0 commit comments

Comments
 (0)