Skip to content

Commit

Permalink
Merge pull request #102 from okta/iabdullin/password_policy_fix
Browse files Browse the repository at this point in the history
Github issue: passwordExpireDays not decoded into model from response
  • Loading branch information
IldarAbdullin-okta authored Aug 23, 2019
2 parents e070727 + feb9af9 commit 7b4c91a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
10 changes: 8 additions & 2 deletions Source/DomainObjects/OktaModels.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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?
}
Expand All @@ -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)
Expand Down
9 changes: 7 additions & 2 deletions Tests/Resources/PASSWORD_WARN
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@
"minLowerCase": 1,
"minUpperCase": 1,
"minNumber": 1,
"minSymbol": 0
"minSymbol": 0,
"excludeUsername": true
},
"age":{
"minAgeMinutes":0,
"historyCount":0
}
}
},
Expand Down Expand Up @@ -56,4 +61,4 @@
}
}
}
}
}
14 changes: 14 additions & 0 deletions Tests/Statuses/OktaAuthStatusPasswordWarningTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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!")
Expand Down

0 comments on commit 7b4c91a

Please sign in to comment.