diff --git a/WalletLibrary/WalletLibrary.xcodeproj/project.pbxproj b/WalletLibrary/WalletLibrary.xcodeproj/project.pbxproj index d61a093c..de991fed 100644 --- a/WalletLibrary/WalletLibrary.xcodeproj/project.pbxproj +++ b/WalletLibrary/WalletLibrary.xcodeproj/project.pbxproj @@ -16,7 +16,7 @@ 550E3214298B11A5004E7716 /* Requirement.swift in Sources */ = {isa = PBXBuildFile; fileRef = 550E3213298B11A5004E7716 /* Requirement.swift */; }; 550E3217298B1236004E7716 /* RequesterStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 550E3216298B1236004E7716 /* RequesterStyle.swift */; }; 552E509B293E6AB200868F47 /* WalletLibrary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 552E5092293E6AB200868F47 /* WalletLibrary.framework */; }; - 552E50A0293E6AB200868F47 /* VerifiedIdFlowTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 552E509F293E6AB200868F47 /* VerifiedIdFlowTests.swift */; }; + 552E50A0293E6AB200868F47 /* VerifiedIdClientTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 552E509F293E6AB200868F47 /* VerifiedIdClientTests.swift */; }; 552E50A1293E6AB200868F47 /* WalletLibrary.h in Headers */ = {isa = PBXBuildFile; fileRef = 552E5095293E6AB200868F47 /* WalletLibrary.h */; settings = {ATTRIBUTES = (Public, ); }; }; 5534E5972948B8C2005D0765 /* VCServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55E336E7293FCE4F00CD2ED7 /* VCServices.framework */; platformFilter = ios; }; 5534E5982948B8C2005D0765 /* VCServices.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 55E336E7293FCE4F00CD2ED7 /* VCServices.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; @@ -36,7 +36,7 @@ 55E336D1293FA6F400CD2ED7 /* VerifiedIdRequirement.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55E336D0293FA6F400CD2ED7 /* VerifiedIdRequirement.swift */; }; 55E336D4293FA75300CD2ED7 /* VerifiedId.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55E336D3293FA75300CD2ED7 /* VerifiedId.swift */; }; 55E336D6293FA78C00CD2ED7 /* VerifiedIdClaim.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55E336D5293FA78C00CD2ED7 /* VerifiedIdClaim.swift */; }; - 55E336D8293FCE0500CD2ED7 /* CredentialIssuanceParams.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55E336D7293FCE0500CD2ED7 /* CredentialIssuanceParams.swift */; }; + 55E336D8293FCE0500CD2ED7 /* IssuanceOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55E336D7293FCE0500CD2ED7 /* IssuanceOptions.swift */; }; 55E33708293FD25900CD2ED7 /* AccessTokenRequirement.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55E33707293FD25900CD2ED7 /* AccessTokenRequirement.swift */; }; 55E3370A293FD3E000CD2ED7 /* IdTokenRequirement.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55E33709293FD3E000CD2ED7 /* IdTokenRequirement.swift */; }; 55E3370C293FD61E00CD2ED7 /* SelfAttestedClaimRequirement.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55E3370B293FD61E00CD2ED7 /* SelfAttestedClaimRequirement.swift */; }; @@ -235,7 +235,7 @@ 552E5092293E6AB200868F47 /* WalletLibrary.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = WalletLibrary.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 552E5095293E6AB200868F47 /* WalletLibrary.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WalletLibrary.h; sourceTree = ""; }; 552E509A293E6AB200868F47 /* WalletLibraryTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = WalletLibraryTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 552E509F293E6AB200868F47 /* VerifiedIdFlowTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VerifiedIdFlowTests.swift; sourceTree = ""; }; + 552E509F293E6AB200868F47 /* VerifiedIdClientTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VerifiedIdClientTests.swift; sourceTree = ""; }; 552E50BD293E71D600868F47 /* VCEntities.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = VCEntities.xcodeproj; path = VCEntities/VCEntities.xcodeproj; sourceTree = ""; }; 552E51AE293E71D700868F47 /* VCServices.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = VCServices.xcodeproj; path = VCServices/VCServices.xcodeproj; sourceTree = ""; }; 552E51D8293E71D700868F47 /* VCToken.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = VCToken.xcodeproj; path = VCToken/VCToken.xcodeproj; sourceTree = ""; }; @@ -257,7 +257,7 @@ 55E336D0293FA6F400CD2ED7 /* VerifiedIdRequirement.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VerifiedIdRequirement.swift; sourceTree = ""; }; 55E336D3293FA75300CD2ED7 /* VerifiedId.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VerifiedId.swift; sourceTree = ""; }; 55E336D5293FA78C00CD2ED7 /* VerifiedIdClaim.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VerifiedIdClaim.swift; sourceTree = ""; }; - 55E336D7293FCE0500CD2ED7 /* CredentialIssuanceParams.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CredentialIssuanceParams.swift; sourceTree = ""; }; + 55E336D7293FCE0500CD2ED7 /* IssuanceOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IssuanceOptions.swift; sourceTree = ""; }; 55E33707293FD25900CD2ED7 /* AccessTokenRequirement.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccessTokenRequirement.swift; sourceTree = ""; }; 55E33709293FD3E000CD2ED7 /* IdTokenRequirement.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IdTokenRequirement.swift; sourceTree = ""; }; 55E3370B293FD61E00CD2ED7 /* SelfAttestedClaimRequirement.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelfAttestedClaimRequirement.swift; sourceTree = ""; }; @@ -342,7 +342,7 @@ children = ( 5534E67C294A392F005D0765 /* Extensions */, 55E3376929478C3300CD2ED7 /* Utilities */, - 552E509F293E6AB200868F47 /* VerifiedIdFlowTests.swift */, + 552E509F293E6AB200868F47 /* VerifiedIdClientTests.swift */, ); path = WalletLibraryTests; sourceTree = ""; @@ -488,7 +488,7 @@ children = ( 55E33707293FD25900CD2ED7 /* AccessTokenRequirement.swift */, 55E3379D2948B4B000CD2ED7 /* CredentialFormat.swift */, - 55E336D7293FCE0500CD2ED7 /* CredentialIssuanceParams.swift */, + 55E336D7293FCE0500CD2ED7 /* IssuanceOptions.swift */, 55E33709293FD3E000CD2ED7 /* IdTokenRequirement.swift */, 55E337B32948B4B000CD2ED7 /* PinRequirement.swift */, 55E3370B293FD61E00CD2ED7 /* SelfAttestedClaimRequirement.swift */, @@ -938,7 +938,7 @@ 5534E667294A0B6C005D0765 /* Mappable.swift in Sources */, 55E3370E293FD84700CD2ED7 /* IssuanceRequest.swift in Sources */, 55E3370A293FD3E000CD2ED7 /* IdTokenRequirement.swift in Sources */, - 55E336D8293FCE0500CD2ED7 /* CredentialIssuanceParams.swift in Sources */, + 55E336D8293FCE0500CD2ED7 /* IssuanceOptions.swift in Sources */, 550E320C298B0F30004E7716 /* WalletLibraryLogConsumer.swift in Sources */, 550E3217298B1236004E7716 /* RequesterStyle.swift in Sources */, 55E336D1293FA6F400CD2ED7 /* VerifiedIdRequirement.swift in Sources */, @@ -974,7 +974,7 @@ 55E3376B29478C5000CD2ED7 /* AsyncWrapperTests.swift in Sources */, 5534E6AD294AAFA6005D0765 /* PresentationDescriptorMappingTests.swift in Sources */, 5534E68C294A8B8F005D0765 /* AccessTokenDescriptorMappingTests.swift in Sources */, - 552E50A0293E6AB200868F47 /* VerifiedIdFlowTests.swift in Sources */, + 552E50A0293E6AB200868F47 /* VerifiedIdClientTests.swift in Sources */, 5534E688294A5F16005D0765 /* IdTokenDescriptorMappingTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/WalletLibrary/WalletLibrary/Extensions/Mappings/VCSDK/IdTokenDescriptor+Mappable.swift b/WalletLibrary/WalletLibrary/Extensions/Mappings/VCSDK/IdTokenDescriptor+Mappable.swift index a8d41758..77693215 100644 --- a/WalletLibrary/WalletLibrary/Extensions/Mappings/VCSDK/IdTokenDescriptor+Mappable.swift +++ b/WalletLibrary/WalletLibrary/Extensions/Mappings/VCSDK/IdTokenDescriptor+Mappable.swift @@ -27,7 +27,6 @@ extension VCEntities.IdTokenDescriptor: Mappable { configuration: configuration, clientId: clientID, redirectUri: redirectUri, - scope: scope, - nonce: nil) + scope: scope) } } diff --git a/WalletLibrary/WalletLibrary/Extensions/Mappings/VCSDK/PresentationDescriptor+Mappable.swift b/WalletLibrary/WalletLibrary/Extensions/Mappings/VCSDK/PresentationDescriptor+Mappable.swift index e64b87a2..3cfe4cb7 100644 --- a/WalletLibrary/WalletLibrary/Extensions/Mappings/VCSDK/PresentationDescriptor+Mappable.swift +++ b/WalletLibrary/WalletLibrary/Extensions/Mappings/VCSDK/PresentationDescriptor+Mappable.swift @@ -15,11 +15,11 @@ extension VCEntities.PresentationDescriptor: Mappable { let acceptedIssuers = issuers?.compactMap { $0.iss } ?? [] - var issuanceParams: CredentialIssuanceParams? = nil + var issuanceOptions: IssuanceOptions? = nil if let contracts = contracts, !contracts.isEmpty { - issuanceParams = CredentialIssuanceParams(acceptedIssuers: acceptedIssuers, - credentialIssuerMetadata: contracts) + issuanceOptions = IssuanceOptions(acceptedIssuers: acceptedIssuers, + credentialIssuerMetadata: contracts) } return VerifiedIdRequirement(encrypted: encrypted ?? false, @@ -27,6 +27,6 @@ extension VCEntities.PresentationDescriptor: Mappable { types: [credentialType], acceptedIssuers: acceptedIssuers, purpose: nil, - credentialIssuanceParams: issuanceParams) + issuanceOptions: issuanceOptions) } } diff --git a/WalletLibrary/WalletLibrary/Requests/Requirements/AccessTokenRequirement.swift b/WalletLibrary/WalletLibrary/Requests/Requirements/AccessTokenRequirement.swift index 0ccc687c..6b48a390 100644 --- a/WalletLibrary/WalletLibrary/Requests/Requirements/AccessTokenRequirement.swift +++ b/WalletLibrary/WalletLibrary/Requests/Requirements/AccessTokenRequirement.swift @@ -6,8 +6,8 @@ /** * Information to describe an access token required for a Verified Id issuance flow. */ -public struct AccessTokenRequirement: Equatable { - +public class AccessTokenRequirement: Requirement { + /// If the requirement should be encrypted. let encrypted: Bool @@ -25,5 +25,22 @@ public struct AccessTokenRequirement: Equatable { /// The scope value used to get the access token through an authentication library. public let scope: String + + init(encrypted: Bool, + required: Bool, + configuration: String, + clientId: String?, + resourceId: String, + scope: String) { + self.encrypted = encrypted + self.required = required + self.configuration = configuration + self.clientId = clientId + self.resourceId = resourceId + self.scope = scope + } + + public func validate() throws { + throw VerifiedIdClientError.TODO(message: "implement validate") + } } - diff --git a/WalletLibrary/WalletLibrary/Requests/Requirements/IdTokenRequirement.swift b/WalletLibrary/WalletLibrary/Requests/Requirements/IdTokenRequirement.swift index 835c9650..9677558f 100644 --- a/WalletLibrary/WalletLibrary/Requests/Requirements/IdTokenRequirement.swift +++ b/WalletLibrary/WalletLibrary/Requests/Requirements/IdTokenRequirement.swift @@ -6,7 +6,7 @@ /** * Information to describe an id token required for a Verified Id issuance flow. */ -public struct IdTokenRequirement: Equatable { +public class IdTokenRequirement: Requirement { /// If the requirement should be encrypted. let encrypted: Bool @@ -30,5 +30,22 @@ public struct IdTokenRequirement: Equatable { /// within the id token request through an authentication library. The nonce will be placed within /// the id token retrieved and can be used for validation during an issuance request to an issuance service. public internal(set) var nonce: String? = nil + + init(encrypted: Bool, + required: Bool, + configuration: URL, + clientId: String, + redirectUri: String, + scope: String) { + self.encrypted = encrypted + self.required = required + self.configuration = configuration + self.clientId = clientId + self.redirectUri = redirectUri + self.scope = scope + } + + public func validate() throws { + throw VerifiedIdClientError.TODO(message: "implement validate") + } } - diff --git a/WalletLibrary/WalletLibrary/Requests/Requirements/CredentialIssuanceParams.swift b/WalletLibrary/WalletLibrary/Requests/Requirements/IssuanceOptions.swift similarity index 93% rename from WalletLibrary/WalletLibrary/Requests/Requirements/CredentialIssuanceParams.swift rename to WalletLibrary/WalletLibrary/Requests/Requirements/IssuanceOptions.swift index ee7de6c9..70bf5cd5 100644 --- a/WalletLibrary/WalletLibrary/Requests/Requirements/CredentialIssuanceParams.swift +++ b/WalletLibrary/WalletLibrary/Requests/Requirements/IssuanceOptions.swift @@ -7,7 +7,7 @@ * Parameters used for an Issuance during Presentation flow * to define information needed for the issuance of the requested Verified Id. */ -public struct CredentialIssuanceParams: Equatable { +public struct IssuanceOptions: Equatable { /// A list of issuers that are accepted. public let acceptedIssuers: [String] @@ -15,5 +15,3 @@ public struct CredentialIssuanceParams: Equatable { /// Information such as a contract URL to describe where to get contract. public let credentialIssuerMetadata: [String] } - - diff --git a/WalletLibrary/WalletLibrary/Requests/Requirements/PinRequirement.swift b/WalletLibrary/WalletLibrary/Requests/Requirements/PinRequirement.swift index 7b834aab..caec40a7 100644 --- a/WalletLibrary/WalletLibrary/Requests/Requirements/PinRequirement.swift +++ b/WalletLibrary/WalletLibrary/Requests/Requirements/PinRequirement.swift @@ -6,11 +6,26 @@ /** * Information to describe a pin that is required. */ -public struct PinRequirement { +public class PinRequirement: Requirement { + + /// If the requirement is required or not. + public let required: Bool /// The length of the pin to display. public let length: Int /// The type of the pin such as alphanumeric or numeric. public let type: String + + init(required: Bool, + length: Int, + type: String) { + self.required = required + self.length = length + self.type = type + } + + public func validate() throws { + throw VerifiedIdClientError.TODO(message: "implement validate") + } } diff --git a/WalletLibrary/WalletLibrary/Requests/Requirements/SelfAttestedClaimRequirement.swift b/WalletLibrary/WalletLibrary/Requests/Requirements/SelfAttestedClaimRequirement.swift index 1d05c83b..c4a0a47e 100644 --- a/WalletLibrary/WalletLibrary/Requests/Requirements/SelfAttestedClaimRequirement.swift +++ b/WalletLibrary/WalletLibrary/Requests/Requirements/SelfAttestedClaimRequirement.swift @@ -6,7 +6,7 @@ /** * Information to describe a self attested claim required for a Verified Id issuance flow. */ -public struct SelfAttestedClaimRequirement: Equatable { +public class SelfAttestedClaimRequirement: Requirement { /// If the requirement should be encrypted. let encrypted: Bool @@ -16,5 +16,14 @@ public struct SelfAttestedClaimRequirement: Equatable { /// The claim requested. public let claim: String + + init(encrypted: Bool, required: Bool, claim: String) { + self.encrypted = encrypted + self.required = required + self.claim = claim + } + + public func validate() throws { + throw VerifiedIdClientError.TODO(message: "implement validate") + } } - diff --git a/WalletLibrary/WalletLibrary/Requests/Requirements/VerifiedIdRequirement.swift b/WalletLibrary/WalletLibrary/Requests/Requirements/VerifiedIdRequirement.swift index 54b83ff3..c0b7b21f 100644 --- a/WalletLibrary/WalletLibrary/Requests/Requirements/VerifiedIdRequirement.swift +++ b/WalletLibrary/WalletLibrary/Requests/Requirements/VerifiedIdRequirement.swift @@ -6,7 +6,7 @@ /** * Information to describe Verified IDs required. */ -public struct VerifiedIdRequirement: Equatable { +public class VerifiedIdRequirement: Requirement { /// If requirement must be encrypted. let encrypted: Bool @@ -24,10 +24,28 @@ public struct VerifiedIdRequirement: Equatable { public let purpose: String? /// An optional property for information needed for issuance during presentation flow. - public let credentialIssuanceParams: CredentialIssuanceParams? + public let issuanceOptions: IssuanceOptions? /// TODO: helper method that returns verified id that match the requirement from a list of verified ids. public func getMatches(verifiedIds: [VerifiedId]) -> [VerifiedId] { return [] } + + init(encrypted: Bool, + required: Bool, + types: [String], + acceptedIssuers: [String], + purpose: String?, + issuanceOptions: IssuanceOptions?) { + self.encrypted = encrypted + self.required = required + self.types = types + self.acceptedIssuers = acceptedIssuers + self.purpose = purpose + self.issuanceOptions = issuanceOptions + } + + public func validate() throws { + throw VerifiedIdClientError.TODO(message: "implement validate") + } } diff --git a/WalletLibrary/WalletLibraryTests/Extensions/Translations/VCSDK/AccessTokenDescriptorMappingTests.swift b/WalletLibrary/WalletLibraryTests/Extensions/Translations/VCSDK/AccessTokenDescriptorMappingTests.swift index a56345a1..ff46d203 100644 --- a/WalletLibrary/WalletLibraryTests/Extensions/Translations/VCSDK/AccessTokenDescriptorMappingTests.swift +++ b/WalletLibrary/WalletLibraryTests/Extensions/Translations/VCSDK/AccessTokenDescriptorMappingTests.swift @@ -24,31 +24,31 @@ class AccessTokenDescriptorMappingTests: XCTestCase { func testSuccessfulMapping() throws { let (input, expectedResult) = try setUpInput(encrypted: false, required: false) let actualResult = try mapper.map(input) - XCTAssertEqual(actualResult, expectedResult) + assertEqual(actual: actualResult, expected: expectedResult) } func testMappingWithEncryptedAsTrueValue() throws { let (input, expectedResult) = try setUpInput(encrypted: true, required: false) let actualResult = try mapper.map(input) - XCTAssertEqual(actualResult, expectedResult) + assertEqual(actual: actualResult, expected: expectedResult) } func testMappingWithEncryptedAsNilValue() throws { let (input, expectedResult) = try setUpInput(encrypted: nil, required: false) let actualResult = try mapper.map(input) - XCTAssertEqual(actualResult, expectedResult) + assertEqual(actual: actualResult, expected: expectedResult) } func testMappingWithRequiredAsTrueValue() throws { let (input, expectedResult) = try setUpInput(encrypted: false, required: true) let actualResult = try mapper.map(input) - XCTAssertEqual(actualResult, expectedResult) + assertEqual(actual: actualResult, expected: expectedResult) } func testMappingWithRequiredAsNilValue() throws { let (input, expectedResult) = try setUpInput(encrypted: false, required: nil) let actualResult = try mapper.map(input) - XCTAssertEqual(actualResult, expectedResult) + assertEqual(actual: actualResult, expected: expectedResult) } func testMappingWithNoConfigurationPresentError() throws { @@ -102,6 +102,15 @@ class AccessTokenDescriptorMappingTests: XCTestCase { } } + private func assertEqual(actual: AccessTokenRequirement, expected: AccessTokenRequirement) { + XCTAssertEqual(actual.encrypted, expected.encrypted) + XCTAssertEqual(actual.required, expected.required) + XCTAssertEqual(actual.configuration, expected.configuration) + XCTAssertEqual(actual.clientId, expected.clientId) + XCTAssertEqual(actual.resourceId, expected.resourceId) + XCTAssertEqual(actual.scope, expected.scope) + } + private func setUpInput(encrypted: Bool?, required: Bool?) throws -> (AccessTokenDescriptor, AccessTokenRequirement) { let input = AccessTokenDescriptor(id: expectedId, diff --git a/WalletLibrary/WalletLibraryTests/Extensions/Translations/VCSDK/IdTokenDescriptorMappingTests.swift b/WalletLibrary/WalletLibraryTests/Extensions/Translations/VCSDK/IdTokenDescriptorMappingTests.swift index b5b441f3..af080b17 100644 --- a/WalletLibrary/WalletLibraryTests/Extensions/Translations/VCSDK/IdTokenDescriptorMappingTests.swift +++ b/WalletLibrary/WalletLibraryTests/Extensions/Translations/VCSDK/IdTokenDescriptorMappingTests.swift @@ -23,31 +23,31 @@ class IdTokenDescriptorMappingTests: XCTestCase { func testSuccessfulMapping() throws { let (input, expectedResult) = try setUpInput(encrypted: false, required: false) let actualResult = try mapper.map(input) - XCTAssertEqual(actualResult, expectedResult) + assertEqual(actualResult, expectedResult) } func testMappingWithEncryptedAsTrueValue() throws { let (input, expectedResult) = try setUpInput(encrypted: true, required: false) let actualResult = try mapper.map(input) - XCTAssertEqual(actualResult, expectedResult) + assertEqual(actualResult, expectedResult) } func testMappingWithEncryptedAsNilValue() throws { let (input, expectedResult) = try setUpInput(encrypted: nil, required: false) let actualResult = try mapper.map(input) - XCTAssertEqual(actualResult, expectedResult) + assertEqual(actualResult, expectedResult) } func testMappingWithRequiredAsTrueValue() throws { let (input, expectedResult) = try setUpInput(encrypted: false, required: true) let actualResult = try mapper.map(input) - XCTAssertEqual(actualResult, expectedResult) + assertEqual(actualResult, expectedResult) } func testMappingWithRequiredAsNilValue() throws { let (input, expectedResult) = try setUpInput(encrypted: false, required: nil) let actualResult = try mapper.map(input) - XCTAssertEqual(actualResult, expectedResult) + assertEqual(actualResult, expectedResult) } func testMappingWithNoRedirectUrlPresentError() throws { @@ -98,6 +98,16 @@ class IdTokenDescriptorMappingTests: XCTestCase { } } + private func assertEqual(_ actual: IdTokenRequirement, _ expected: IdTokenRequirement) { + XCTAssertEqual(actual.encrypted, expected.encrypted) + XCTAssertEqual(actual.required, expected.required) + XCTAssertEqual(actual.configuration, expected.configuration) + XCTAssertEqual(actual.clientId, expected.clientId) + XCTAssertEqual(actual.redirectUri, expected.redirectUri) + XCTAssertEqual(actual.scope, expected.scope) + XCTAssertEqual(actual.nonce, expected.nonce) + } + private func setUpInput(encrypted: Bool?, required: Bool?) throws -> (IdTokenDescriptor, IdTokenRequirement) { let input = IdTokenDescriptor(encrypted: encrypted, claims: [], diff --git a/WalletLibrary/WalletLibraryTests/Extensions/Translations/VCSDK/PresentationDescriptorMappingTests.swift b/WalletLibrary/WalletLibraryTests/Extensions/Translations/VCSDK/PresentationDescriptorMappingTests.swift index 30976cea..a0648420 100644 --- a/WalletLibrary/WalletLibraryTests/Extensions/Translations/VCSDK/PresentationDescriptorMappingTests.swift +++ b/WalletLibrary/WalletLibraryTests/Extensions/Translations/VCSDK/PresentationDescriptorMappingTests.swift @@ -20,31 +20,31 @@ class PresentationDescriptorMappingTests: XCTestCase { func testSuccessfulMapping() throws { let (input, expectedResult) = try setUpInput(encrypted: false, required: false) let actualResult = try mapper.map(input) - XCTAssertEqual(actualResult, expectedResult) + assertEqual(actualResult, expectedResult) } func testMappingWithEncryptedAsTrue() throws { let (input, expectedResult) = try setUpInput(encrypted: true, required: false) let actualResult = try mapper.map(input) - XCTAssertEqual(actualResult, expectedResult) + assertEqual(actualResult, expectedResult) } func testMappingWithRequiredAsTrue() throws { let (input, expectedResult) = try setUpInput(encrypted: false, required: true) let actualResult = try mapper.map(input) - XCTAssertEqual(actualResult, expectedResult) + assertEqual(actualResult, expectedResult) } func testMappingWithOneNilIssuerValue() throws { let (input, expectedResult) = try setUpInput(issuers: [nil]) let actualResult = try mapper.map(input) - XCTAssertEqual(actualResult, expectedResult) + assertEqual(actualResult, expectedResult) } func testMappingWithOneIssuerValue() throws { let (input, expectedResult) = try setUpInput(issuers: ["issuer235"]) let actualResult = try mapper.map(input) - XCTAssertEqual(actualResult, expectedResult) + assertEqual(actualResult, expectedResult) } func testMappingWithThreeIssuerValue() throws { @@ -52,25 +52,25 @@ class PresentationDescriptorMappingTests: XCTestCase { "issuer7345", "issuer9083"]) let actualResult = try mapper.map(input) - XCTAssertEqual(actualResult, expectedResult) + assertEqual(actualResult, expectedResult) } func testMappingWithNilIssuerValue() throws { let (input, expectedResult) = try setUpInput(issuers: nil) let actualResult = try mapper.map(input) - XCTAssertEqual(actualResult, expectedResult) + assertEqual(actualResult, expectedResult) } func testMappingWithNilContractValue() throws { let (input, expectedResult) = try setUpInput(contracts: nil) let actualResult = try mapper.map(input) - XCTAssertEqual(actualResult, expectedResult) + assertEqual(actualResult, expectedResult) } func testMappingWithOneContractValue() throws { let (input, expectedResult) = try setUpInput(contracts: ["contract2645"]) let actualResult = try mapper.map(input) - XCTAssertEqual(actualResult, expectedResult) + assertEqual(actualResult, expectedResult) } func testMappingWithThreeContractValue() throws { @@ -78,7 +78,16 @@ class PresentationDescriptorMappingTests: XCTestCase { "contract0394", "contract2343"]) let actualResult = try mapper.map(input) - XCTAssertEqual(actualResult, expectedResult) + assertEqual(actualResult, expectedResult) + } + + private func assertEqual(_ actual: VerifiedIdRequirement, _ expected: VerifiedIdRequirement) { + XCTAssertEqual(actual.encrypted, expected.encrypted) + XCTAssertEqual(actual.required, expected.required) + XCTAssertEqual(actual.types, expected.types) + XCTAssertEqual(actual.acceptedIssuers, expected.acceptedIssuers) + XCTAssertEqual(actual.purpose, expected.purpose) + XCTAssertEqual(actual.issuanceOptions, expected.issuanceOptions) } private func setUpInput(encrypted: Bool? = false, @@ -96,11 +105,11 @@ class PresentationDescriptorMappingTests: XCTestCase { let expectedIssuers = issuers?.compactMap { $0 } ?? [] - var expectedIssuanceParams: CredentialIssuanceParams? = nil + var expectedIssuanceOptions: IssuanceOptions? = nil if let expectedContracts = contracts, !expectedContracts.isEmpty { - expectedIssuanceParams = CredentialIssuanceParams(acceptedIssuers: expectedIssuers, - credentialIssuerMetadata: expectedContracts) + expectedIssuanceOptions = IssuanceOptions(acceptedIssuers: expectedIssuers, + credentialIssuerMetadata: expectedContracts) } let expectedResult = VerifiedIdRequirement(encrypted: encrypted ?? false, @@ -108,7 +117,7 @@ class PresentationDescriptorMappingTests: XCTestCase { types: [exceptedCredentialType], acceptedIssuers: expectedIssuers, purpose: nil, - credentialIssuanceParams: expectedIssuanceParams) + issuanceOptions: expectedIssuanceOptions) return (input, expectedResult) } } diff --git a/WalletLibrary/WalletLibraryTests/VerifiedIdFlowTests.swift b/WalletLibrary/WalletLibraryTests/VerifiedIdClientTests.swift similarity index 87% rename from WalletLibrary/WalletLibraryTests/VerifiedIdFlowTests.swift rename to WalletLibrary/WalletLibraryTests/VerifiedIdClientTests.swift index 126c86f7..4315c35f 100644 --- a/WalletLibrary/WalletLibraryTests/VerifiedIdFlowTests.swift +++ b/WalletLibrary/WalletLibraryTests/VerifiedIdClientTests.swift @@ -6,7 +6,7 @@ import XCTest @testable import WalletLibrary -class VerifiedIdFlowTests: XCTestCase { +class VerifiedIdClientTests: XCTestCase { override func setUpWithError() throws { // Put setup code here. This method is called before the invocation of each test method in the class. @@ -16,15 +16,10 @@ class VerifiedIdFlowTests: XCTestCase { // Put teardown code here. This method is called after the invocation of each test method in the class. } - func testInitiateFlow() throws { - print(VerifiedIdFlow().initiate()) - } - func testPerformanceExample() throws { // This is an example of a performance test case. self.measure { // Put the code you want to measure the time of here. } } - }