From a2bdf66d440ccf295f0408cf3f19cc982b39e6ed Mon Sep 17 00:00:00 2001 From: Ildar Abdullin Date: Fri, 23 Aug 2019 14:52:35 -0700 Subject: [PATCH 1/2] Github issue: passwordExpireDays not decoded into model from response https://github.com/okta/okta-auth-swift/issues/100 --- Source/DomainObjects/OktaModels.swift | 10 ++++++++-- Tests/Resources/PASSWORD_WARN | 9 +++++++-- .../OktaAuthStatusPasswordWarningTests.swift | 14 ++++++++++++++ 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/Source/DomainObjects/OktaModels.swift b/Source/DomainObjects/OktaModels.swift index f0cdc3e..208bdf7 100644 --- a/Source/DomainObjects/OktaModels.swift +++ b/Source/DomainObjects/OktaModels.swift @@ -271,7 +271,7 @@ public struct EmbeddedResponse: Codable { public enum Policy: Codable { /// A subset of policy settings of the Sign-On Policy or App Sign-On Policy. public struct RememberDevice: Codable { - public let allowRememberDevice: Bool? + public let allowRememberDevice: Bool public let rememberDeviceByDefault: Bool? public let rememberDeviceLifetimeInMinutes: Int? } @@ -291,11 +291,17 @@ public struct EmbeddedResponse: Codable { public let minUpperCase: Int? public let minNumber: Int? public let minSymbol: Int? - public let excludeUsername: Bool + public let excludeUsername: Bool? + } + + public struct PasswordAge: Codable { + public let minAgeMinutes: Int? + public let historyCount: Int? } public let expiration: PasswordExpiration? public let complexity: PasswordComplexity? + public let age: PasswordAge? } case rememberDevice(RememberDevice) diff --git a/Tests/Resources/PASSWORD_WARN b/Tests/Resources/PASSWORD_WARN index ae1f0a4..d16d000 100644 --- a/Tests/Resources/PASSWORD_WARN +++ b/Tests/Resources/PASSWORD_WARN @@ -24,7 +24,12 @@ "minLowerCase": 1, "minUpperCase": 1, "minNumber": 1, - "minSymbol": 0 + "minSymbol": 0, + "excludeUsername": true + }, + "age":{ + "minAgeMinutes":0, + "historyCount":0 } } }, @@ -56,4 +61,4 @@ } } } -} \ No newline at end of file +} diff --git a/Tests/Statuses/OktaAuthStatusPasswordWarningTests.swift b/Tests/Statuses/OktaAuthStatusPasswordWarningTests.swift index bc9c48b..431bfb5 100644 --- a/Tests/Statuses/OktaAuthStatusPasswordWarningTests.swift +++ b/Tests/Statuses/OktaAuthStatusPasswordWarningTests.swift @@ -22,6 +22,20 @@ class OktaAuthStatusPasswordWarningTests: XCTestCase { return } + XCTAssertNotNil(status.model.expirationDate) + XCTAssertNotNil(status.model.links?.next) + XCTAssertNotNil(status.model.links?.skip) + XCTAssertNotNil(status.model.links?.cancel) + XCTAssertNotNil(status.model.embedded) + XCTAssertNotNil(status.model.embedded?.policy) + if case .password(let password) = status.model.embedded?.policy { + XCTAssertNotNil(password.complexity) + XCTAssertNotNil(password.expiration) + XCTAssertNotNil(password.age) + } else { + XCTFail("Failed to parse policy.") + } + status.setupApiMockResponse(.SUCCESS) let ex = expectation(description: "Callback is expected!") From feb9af933668deb02255f1f57249a100134b6aa7 Mon Sep 17 00:00:00 2001 From: Ildar Abdullin Date: Fri, 23 Aug 2019 15:32:04 -0700 Subject: [PATCH 2/2] Github issue: passwordExpireDays not decoded into model from response https://github.com/okta/okta-auth-swift/issues/100 --- Tests/Statuses/OktaAuthStatusPasswordWarningTests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Statuses/OktaAuthStatusPasswordWarningTests.swift b/Tests/Statuses/OktaAuthStatusPasswordWarningTests.swift index 431bfb5..032f606 100644 --- a/Tests/Statuses/OktaAuthStatusPasswordWarningTests.swift +++ b/Tests/Statuses/OktaAuthStatusPasswordWarningTests.swift @@ -28,7 +28,7 @@ class OktaAuthStatusPasswordWarningTests: XCTestCase { XCTAssertNotNil(status.model.links?.cancel) XCTAssertNotNil(status.model.embedded) XCTAssertNotNil(status.model.embedded?.policy) - if case .password(let password) = status.model.embedded?.policy { + if case .password(let password)? = status.model.embedded?.policy { XCTAssertNotNil(password.complexity) XCTAssertNotNil(password.expiration) XCTAssertNotNil(password.age)