Skip to content

Commit 30be49b

Browse files
authored
test: add missing unit test for maxConsecutiveCharacters (OKTA-1228272) (#1702)
test: add missing unit test coverage for maxConsecutiveCharacters (OKTA-1228272) The maxConsecutiveCharacters field was added to PasswordPolicyPasswordSettingsComplexity in #1699, but never got a dedicated regression test. Add one covering both directions: a caller value is no longer silently dropped on deserialization, and it's correctly included on serialization. Co-Authored-By: Claude Code
1 parent a96cc66 commit 30be49b

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright 2026-Present Okta, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.okta.sdk.resource.model;
17+
18+
import com.fasterxml.jackson.databind.ObjectMapper;
19+
import org.testng.annotations.Test;
20+
21+
import static org.testng.Assert.assertEquals;
22+
import static org.testng.Assert.assertTrue;
23+
24+
/**
25+
* OKTA-1228272: maxConsecutiveCharacters was missing from the SDK's PasswordPolicyPasswordSettingsComplexity
26+
* model even though the Okta API accepts it. Because McpObjectMapper-style deserialization typically runs
27+
* with FAIL_ON_UNKNOWN_PROPERTIES=false, a caller-supplied value for this field was silently dropped
28+
* instead of surfaced, giving a false impression the field was accepted.
29+
*/
30+
public class PasswordPolicyPasswordSettingsComplexityTest {
31+
32+
private final ObjectMapper objectMapper = new ObjectMapper();
33+
34+
@Test
35+
public void deserialize_maxConsecutiveCharacters_isPopulated() throws Exception {
36+
String json = "{\"minLength\":8,\"minLowerCase\":1,\"maxConsecutiveCharacters\":1}";
37+
38+
PasswordPolicyPasswordSettingsComplexity complexity =
39+
objectMapper.readValue(json, PasswordPolicyPasswordSettingsComplexity.class);
40+
41+
assertEquals(complexity.getMinLength(), Integer.valueOf(8));
42+
assertEquals(complexity.getMaxConsecutiveCharacters(), Integer.valueOf(1));
43+
}
44+
45+
@Test
46+
public void serialize_maxConsecutiveCharacters_isIncluded() throws Exception {
47+
PasswordPolicyPasswordSettingsComplexity complexity = new PasswordPolicyPasswordSettingsComplexity()
48+
.maxConsecutiveCharacters(1);
49+
50+
String json = objectMapper.writeValueAsString(complexity);
51+
52+
assertTrue(json.contains("\"maxConsecutiveCharacters\":1"), "expected maxConsecutiveCharacters in output, got: " + json);
53+
}
54+
}

0 commit comments

Comments
 (0)