Fix another inconsistent set of PolicySet values
* EAS can send both "simple password" and a non-zero number of required complex characters; we're supposed to ignore the complex character requirement in this case * Force complex characters to zero if password is "simple" * Update constructor test to check the fix Bug: 2903349 Change-Id: I3d42bd3c8f3667d8f3027da9e91e0dd18722d9bf
This commit is contained in:
parent
1b65ea576a
commit
61911d4ff7
@ -483,6 +483,11 @@ public class SecurityPolicy {
|
||||
(passwordMode != PASSWORD_MODE_STRONG)) {
|
||||
throw new IllegalArgumentException("password mode");
|
||||
}
|
||||
// If we're only requiring a simple password, set complex chars to zero; note
|
||||
// that EAS can erroneously send non-zero values in this case
|
||||
if (passwordMode == PASSWORD_MODE_SIMPLE) {
|
||||
passwordComplexChars = 0;
|
||||
}
|
||||
// The next four values have hard limits which cannot be supported if exceeded.
|
||||
if (minPasswordLength > PASSWORD_LENGTH_MAX) {
|
||||
throw new IllegalArgumentException("password length");
|
||||
|
@ -112,12 +112,15 @@ public class SecurityPolicyTests extends ProviderTestCase2<EmailProvider> {
|
||||
fail("Illegal password mode allowed");
|
||||
} catch (IllegalArgumentException e) {
|
||||
}
|
||||
|
||||
PolicySet ps = new PolicySet(0, PolicySet.PASSWORD_MODE_SIMPLE, 0,
|
||||
PolicySet.SCREEN_LOCK_TIME_MAX + 1, false, 0, 0, 0);
|
||||
assertEquals(PolicySet.SCREEN_LOCK_TIME_MAX, ps.getMaxScreenLockTime());
|
||||
|
||||
ps = new PolicySet(0, PolicySet.PASSWORD_MODE_SIMPLE,
|
||||
PolicySet.PASSWORD_MAX_FAILS_MAX + 1, 0, false, 0, 0, 0);
|
||||
assertEquals(PolicySet.PASSWORD_MAX_FAILS_MAX, ps.getMaxPasswordFails());
|
||||
|
||||
// All password related fields should be zero when password mode is NONE
|
||||
// Illegal values for these fields should be ignored
|
||||
ps = new PolicySet(999/*length*/, PolicySet.PASSWORD_MODE_NONE,
|
||||
@ -129,6 +132,12 @@ public class SecurityPolicyTests extends ProviderTestCase2<EmailProvider> {
|
||||
assertEquals(0, ps.mPasswordExpiration);
|
||||
assertEquals(0, ps.mPasswordHistory);
|
||||
assertEquals(0, ps.mPasswordComplexChars);
|
||||
|
||||
// With a simple password, we should set complex chars to zero
|
||||
ps = new PolicySet(4/*length*/, PolicySet.PASSWORD_MODE_SIMPLE,
|
||||
0, 0, false, 0, 0, 3/*complex*/);
|
||||
assertEquals(4, ps.mMinPasswordLength);
|
||||
assertEquals(0, ps.mPasswordComplexChars);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -303,9 +312,9 @@ public class SecurityPolicyTests extends ProviderTestCase2<EmailProvider> {
|
||||
assertEquals(0, p.mPasswordComplexChars);
|
||||
assertFalse(p.mRequireRemoteWipe);
|
||||
|
||||
p = new PolicySet(0, PolicySet.PASSWORD_MODE_SIMPLE, 0, 0, false, 0, 0,
|
||||
p = new PolicySet(0, PolicySet.PASSWORD_MODE_STRONG, 0, 0, false, 0, 0,
|
||||
PolicySet.PASSWORD_COMPLEX_CHARS_MAX);
|
||||
assertEquals(PolicySet.PASSWORD_MODE_SIMPLE, p.mPasswordMode);
|
||||
assertEquals(PolicySet.PASSWORD_MODE_STRONG, p.mPasswordMode);
|
||||
assertEquals(0, p.mMinPasswordLength);
|
||||
assertEquals(0, p.mMaxPasswordFails);
|
||||
assertEquals(0, p.mMaxScreenLockTime);
|
||||
|
Loading…
Reference in New Issue
Block a user