diff --git a/WalletLibrary/WalletLibrary.xcodeproj/project.pbxproj b/WalletLibrary/WalletLibrary.xcodeproj/project.pbxproj index 71de2bb5..87f324f6 100644 --- a/WalletLibrary/WalletLibrary.xcodeproj/project.pbxproj +++ b/WalletLibrary/WalletLibrary.xcodeproj/project.pbxproj @@ -11,7 +11,7 @@ 550A916F299310D40014D030 /* OpenIdRequestHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 550A9157299310D40014D030 /* OpenIdRequestHandler.swift */; }; 550A9170299310D40014D030 /* OpenIdURLRequestResolver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 550A916E299310D40014D030 /* OpenIdURLRequestResolver.swift */; }; 550A9173299311A10014D030 /* VerifiedIdRequestURL.swift in Sources */ = {isa = PBXBuildFile; fileRef = 550A9172299311A10014D030 /* VerifiedIdRequestURL.swift */; }; - 550A9192299400820014D030 /* OpenIdForVCResponder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 550A9191299400820014D030 /* OpenIdForVCResponder.swift */; }; + 550A9192299400820014D030 /* OpenIdResponder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 550A9191299400820014D030 /* OpenIdResponder.swift */; }; 550A91952994025C0014D030 /* OpenIdURLRequestResolverTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 550A91942994025C0014D030 /* OpenIdURLRequestResolverTests.swift */; }; 550A919829940DCE0014D030 /* MockOpenIdforVCResolver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 550A919729940DCE0014D030 /* MockOpenIdforVCResolver.swift */; }; 550A919B29940E9E0014D030 /* PresentationRequest+OpenIdRawRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 550A919A29940E9E0014D030 /* PresentationRequest+OpenIdRawRequest.swift */; }; @@ -100,13 +100,19 @@ 55A81C0D2991BF86002C259A /* MockInput.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55A81C0C2991BF86002C259A /* MockInput.swift */; }; 55A81C102991C211002C259A /* MockResolver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55A81C0F2991C211002C259A /* MockResolver.swift */; }; 55A81C132991C829002C259A /* MockHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55A81C122991C829002C259A /* MockHandler.swift */; }; + 55DECBD029B922D200D5C802 /* MockPresentationResponder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55DECBCF29B922D200D5C802 /* MockPresentationResponder.swift */; }; + 55DECBE729B92E3900D5C802 /* PresentationResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55DECBE629B92E3900D5C802 /* PresentationResponse.swift */; }; + 55DECBE929B934B900D5C802 /* IssuanceRequestContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55DECBE829B934B900D5C802 /* IssuanceRequestContent.swift */; }; + 55DECBEB29B954F500D5C802 /* PresentationResponseContainer+WalletLibrary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55DECBEA29B954F500D5C802 /* PresentationResponseContainer+WalletLibrary.swift */; }; + 55DECBED29BA29FB00D5C802 /* PresentationResponseContainerExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55DECBEC29BA29FB00D5C802 /* PresentationResponseContainerExtensionTests.swift */; }; + 55DECBEF29BA2BEE00D5C802 /* IssuanceRequestContentTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55DECBEE29BA2BEE00D5C802 /* IssuanceRequestContentTests.swift */; }; 55E2F06C299553300008010D /* PresentationRequest+Mappable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55E2F056299553300008010D /* PresentationRequest+Mappable.swift */; }; 55E2F06F299553B40008010D /* OpenIdRequestHandlerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55E2F06E299553B40008010D /* OpenIdRequestHandlerTests.swift */; }; 55E2F071299554110008010D /* LibraryConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55E2F070299554110008010D /* LibraryConfiguration.swift */; }; 55E2F076299555280008010D /* MockRequirement.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55E2F073299555280008010D /* MockRequirement.swift */; }; 55E2F077299555280008010D /* MockRequesterStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55E2F075299555280008010D /* MockRequesterStyle.swift */; }; 55E2F07D2995561E0008010D /* OpenIdPresentationRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55E2F07C2995561E0008010D /* OpenIdPresentationRequest.swift */; }; - 55E2F07F29955A3B0008010D /* VerifiedIdRequestContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55E2F07E29955A3B0008010D /* VerifiedIdRequestContent.swift */; }; + 55E2F07F29955A3B0008010D /* PresentationRequestContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55E2F07E29955A3B0008010D /* PresentationRequestContent.swift */; }; 55E2F08129955A960008010D /* RequestType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55E2F08029955A960008010D /* RequestType.swift */; }; 55E2F08429955E8A0008010D /* MockMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55E2F08329955E8A0008010D /* MockMapper.swift */; }; 55E2F086299573C30008010D /* OpenIdVerifierStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55E2F085299573C30008010D /* OpenIdVerifierStyle.swift */; }; @@ -307,7 +313,7 @@ 550A9157299310D40014D030 /* OpenIdRequestHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OpenIdRequestHandler.swift; sourceTree = ""; }; 550A916E299310D40014D030 /* OpenIdURLRequestResolver.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OpenIdURLRequestResolver.swift; sourceTree = ""; }; 550A9172299311A10014D030 /* VerifiedIdRequestURL.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VerifiedIdRequestURL.swift; sourceTree = ""; }; - 550A9191299400820014D030 /* OpenIdForVCResponder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OpenIdForVCResponder.swift; sourceTree = ""; }; + 550A9191299400820014D030 /* OpenIdResponder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OpenIdResponder.swift; sourceTree = ""; }; 550A91942994025C0014D030 /* OpenIdURLRequestResolverTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OpenIdURLRequestResolverTests.swift; sourceTree = ""; }; 550A919729940DCE0014D030 /* MockOpenIdforVCResolver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockOpenIdforVCResolver.swift; sourceTree = ""; }; 550A919A29940E9E0014D030 /* PresentationRequest+OpenIdRawRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PresentationRequest+OpenIdRawRequest.swift"; sourceTree = ""; }; @@ -390,13 +396,19 @@ 55A81C0C2991BF86002C259A /* MockInput.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockInput.swift; sourceTree = ""; }; 55A81C0F2991C211002C259A /* MockResolver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockResolver.swift; sourceTree = ""; }; 55A81C122991C829002C259A /* MockHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockHandler.swift; sourceTree = ""; }; + 55DECBCF29B922D200D5C802 /* MockPresentationResponder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockPresentationResponder.swift; sourceTree = ""; }; + 55DECBE629B92E3900D5C802 /* PresentationResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PresentationResponse.swift; sourceTree = ""; }; + 55DECBE829B934B900D5C802 /* IssuanceRequestContent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IssuanceRequestContent.swift; sourceTree = ""; }; + 55DECBEA29B954F500D5C802 /* PresentationResponseContainer+WalletLibrary.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PresentationResponseContainer+WalletLibrary.swift"; sourceTree = ""; }; + 55DECBEC29BA29FB00D5C802 /* PresentationResponseContainerExtensionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PresentationResponseContainerExtensionTests.swift; sourceTree = ""; }; + 55DECBEE29BA2BEE00D5C802 /* IssuanceRequestContentTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IssuanceRequestContentTests.swift; sourceTree = ""; }; 55E2F056299553300008010D /* PresentationRequest+Mappable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "PresentationRequest+Mappable.swift"; sourceTree = ""; }; 55E2F06E299553B40008010D /* OpenIdRequestHandlerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OpenIdRequestHandlerTests.swift; sourceTree = ""; }; 55E2F070299554110008010D /* LibraryConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LibraryConfiguration.swift; sourceTree = ""; }; 55E2F073299555280008010D /* MockRequirement.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MockRequirement.swift; sourceTree = ""; }; 55E2F075299555280008010D /* MockRequesterStyle.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MockRequesterStyle.swift; sourceTree = ""; }; 55E2F07C2995561E0008010D /* OpenIdPresentationRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OpenIdPresentationRequest.swift; sourceTree = ""; }; - 55E2F07E29955A3B0008010D /* VerifiedIdRequestContent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VerifiedIdRequestContent.swift; sourceTree = ""; }; + 55E2F07E29955A3B0008010D /* PresentationRequestContent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PresentationRequestContent.swift; sourceTree = ""; }; 55E2F08029955A960008010D /* RequestType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RequestType.swift; sourceTree = ""; }; 55E2F08329955E8A0008010D /* MockMapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockMapper.swift; sourceTree = ""; }; 55E2F085299573C30008010D /* OpenIdVerifierStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OpenIdVerifierStyle.swift; sourceTree = ""; }; @@ -447,6 +459,7 @@ 550A9156299310D40014D030 /* Handlers */ = { isa = PBXGroup; children = ( + 55A81BE62991B2F3002C259A /* RequestHandlerFactory.swift */, 550A9157299310D40014D030 /* OpenIdRequestHandler.swift */, ); path = Handlers; @@ -455,6 +468,7 @@ 550A916D299310D40014D030 /* Resolvers */ = { isa = PBXGroup; children = ( + 55A81BE42991B2E5002C259A /* RequestResolverFactory.swift */, 550A916E299310D40014D030 /* OpenIdURLRequestResolver.swift */, ); path = Resolvers; @@ -491,19 +505,11 @@ 550A919A29940E9E0014D030 /* PresentationRequest+OpenIdRawRequest.swift */, 559BD3AC299AE6C000BD61AC /* IssuanceRequest+RawManifest.swift */, 559BD49B299D913F00BD61AC /* IssuanceResponseContainer+WalletLibrary.swift */, + 55DECBEA29B954F500D5C802 /* PresentationResponseContainer+WalletLibrary.swift */, ); path = Entities; sourceTree = ""; }; - 550A919C29940ECA0014D030 /* RawRequests */ = { - isa = PBXGroup; - children = ( - 550A919D29940ED70014D030 /* OpenIdRawRequest.swift */, - 559BD3A7299ADE9C00BD61AC /* RawManifest.swift */, - ); - path = RawRequests; - sourceTree = ""; - }; 550E3215298B1224004E7716 /* Styles */ = { isa = PBXGroup; children = ( @@ -706,6 +712,7 @@ 559BD3A4299AD9A200BD61AC /* Manifest */ = { isa = PBXGroup; children = ( + 559BD3A7299ADE9C00BD61AC /* RawManifest.swift */, 559BD3A5299AD9BD00BD61AC /* ManifestResolver.swift */, 553CC09C29A97181005A5FD6 /* IssuanceResponseContaining.swift */, ); @@ -781,6 +788,7 @@ isa = PBXGroup; children = ( 559BD4E4299EEA3000BD61AC /* IssuanceResponseContainerExtensionTests.swift */, + 55DECBEC29BA29FB00D5C802 /* PresentationResponseContainerExtensionTests.swift */, ); path = Entities; sourceTree = ""; @@ -815,6 +823,7 @@ 559BD4E9299EEAA200BD61AC /* Requirements */, 55A81C062991BB2C002C259A /* RequestResolverFactoryTests.swift */, 55A81C082991BB3A002C259A /* RequestHandlerFactoryTests.swift */, + 55DECBEE29BA2BEE00D5C802 /* IssuanceRequestContentTests.swift */, ); path = Requests; sourceTree = ""; @@ -843,6 +852,7 @@ 559BD3102996D3CE00BD61AC /* MockVerifiedIdRequest.swift */, 559BD3AE299AF42C00BD61AC /* MockManifestResolver.swift */, 559BD4F4299EEC9500BD61AC /* MockVerifiedIdRequester.swift */, + 55DECBCF29B922D200D5C802 /* MockPresentationResponder.swift */, ); path = Requests; sourceTree = ""; @@ -887,15 +897,6 @@ path = Styles; sourceTree = ""; }; - 55E2F07A2995561E0008010D /* RequestProtocols */ = { - isa = PBXGroup; - children = ( - 559BD3A9299ADEF300BD61AC /* Manifest */, - 55E2F07B2995561E0008010D /* OpenId */, - ); - path = RequestProtocols; - sourceTree = ""; - }; 55E2F07B2995561E0008010D /* OpenId */ = { isa = PBXGroup; children = ( @@ -1018,15 +1019,15 @@ 55E3370F293FDDF400CD2ED7 /* Requests */ = { isa = PBXGroup; children = ( - 55E2F07A2995561E0008010D /* RequestProtocols */, + 559BD3A9299ADEF300BD61AC /* Manifest */, + 55E2F07B2995561E0008010D /* OpenId */, 550A91712993117B0014D030 /* Input */, 550A9156299310D40014D030 /* Handlers */, 550A916D299310D40014D030 /* Resolvers */, 55E336CF293FA6D900CD2ED7 /* Requirements */, 5534E5B42948FEB5005D0765 /* RootOfTrust.swift */, - 55A81BE42991B2E5002C259A /* RequestResolverFactory.swift */, - 55A81BE62991B2F3002C259A /* RequestHandlerFactory.swift */, - 55E2F07E29955A3B0008010D /* VerifiedIdRequestContent.swift */, + 55E2F07E29955A3B0008010D /* PresentationRequestContent.swift */, + 55DECBE829B934B900D5C802 /* IssuanceRequestContent.swift */, ); path = Requests; sourceTree = ""; @@ -1053,13 +1054,14 @@ path = Utilities; sourceTree = ""; }; - 55E3376629437E1000CD2ED7 /* OpenIdForVC */ = { + 55E3376629437E1000CD2ED7 /* OpenId */ = { isa = PBXGroup; children = ( 55E3376729437E3500CD2ED7 /* OpenIdForVCResolver.swift */, - 550A9191299400820014D030 /* OpenIdForVCResponder.swift */, + 550A9191299400820014D030 /* OpenIdResponder.swift */, + 550A919D29940ED70014D030 /* OpenIdRawRequest.swift */, ); - path = OpenIdForVC; + path = OpenId; sourceTree = ""; }; 55E3376929478C3300CD2ED7 /* Utilities */ = { @@ -1074,9 +1076,9 @@ isa = PBXGroup; children = ( 559BD3A4299AD9A200BD61AC /* Manifest */, - 550A919C29940ECA0014D030 /* RawRequests */, 55E337B72948B50800CD2ED7 /* Handlers */, - 55E3376629437E1000CD2ED7 /* OpenIdForVC */, + 55E3376629437E1000CD2ED7 /* OpenId */, + 55DECBE629B92E3900D5C802 /* PresentationResponse.swift */, 550E3213298B11A5004E7716 /* Requirement.swift */, 55A81BC92991AB82002C259A /* RequestResolving.swift */, 55E2F08029955A960008010D /* RequestType.swift */, @@ -1408,7 +1410,7 @@ 55E2F08129955A960008010D /* RequestType.swift in Sources */, 55A81BE72991B2F3002C259A /* RequestHandlerFactory.swift in Sources */, 559BD3A3299AD95200BD61AC /* IssuanceService+ManifestResolver.swift in Sources */, - 55E2F07F29955A3B0008010D /* VerifiedIdRequestContent.swift in Sources */, + 55E2F07F29955A3B0008010D /* PresentationRequestContent.swift in Sources */, 550A916F299310D40014D030 /* OpenIdRequestHandler.swift in Sources */, 55E3370A293FD3E000CD2ED7 /* IdTokenRequirement.swift in Sources */, 5585BDE729A6C38C0059710B /* InjectedIdToken.swift in Sources */, @@ -1416,6 +1418,7 @@ 550E3217298B1236004E7716 /* RequesterStyle.swift in Sources */, 55E336D1293FA6F400CD2ED7 /* VerifiedIdRequirement.swift in Sources */, 5534E66E294A0F8F005D0765 /* Mapping.swift in Sources */, + 55DECBE729B92E3900D5C802 /* PresentationResponse.swift in Sources */, 559BD4B3299EDFB400BD61AC /* VerifiableCredential.swift in Sources */, 55E336D6293FA78C00CD2ED7 /* VerifiedIdClaim.swift in Sources */, 553CC09029A955E6005A5FD6 /* PinDescriptor+Mappable.swift in Sources */, @@ -1434,6 +1437,7 @@ 5534E669294A0C3F005D0765 /* Mapper.swift in Sources */, 550E320A298B0EA4004E7716 /* VerifiedIdClient.swift in Sources */, 559BD45B299D587200BD61AC /* Manifest2022IssuerStyle.swift in Sources */, + 55DECBEB29B954F500D5C802 /* PresentationResponseContainer+WalletLibrary.swift in Sources */, 559BD3AD299AE6C000BD61AC /* IssuanceRequest+RawManifest.swift in Sources */, 559BD3B2299B0A0400BD61AC /* AttestationsDescriptor+Mappable.swift in Sources */, 5534E64D294A0888005D0765 /* PresentationDescriptor+Mappable.swift in Sources */, @@ -1447,11 +1451,12 @@ 55A81BE12991AB96002C259A /* RequestHandling.swift in Sources */, 55E2F071299554110008010D /* LibraryConfiguration.swift in Sources */, 550E3209298B0EA4004E7716 /* VerifiedIdClientBuilder.swift in Sources */, - 550A9192299400820014D030 /* OpenIdForVCResponder.swift in Sources */, + 550A9192299400820014D030 /* OpenIdResponder.swift in Sources */, 5534E672294A19D5005D0765 /* IdTokenDescriptor+Mappable.swift in Sources */, 5534E677294A1FA0005D0765 /* AccessTokenDescriptor+Mappable.swift in Sources */, 55E2F08A299576350008010D /* PresentationDefinition+Mappable.swift in Sources */, 553CC09D29A97181005A5FD6 /* IssuanceResponseContaining.swift in Sources */, + 55DECBE929B934B900D5C802 /* IssuanceRequestContent.swift in Sources */, 550A919E29940ED70014D030 /* OpenIdRawRequest.swift in Sources */, 55E337BC2948B5FE00CD2ED7 /* PresentationService+OpenIdForVC.swift in Sources */, 55E336D4293FA75300CD2ED7 /* VerifiedId.swift in Sources */, @@ -1481,14 +1486,17 @@ 559BD4EB299EEAC400BD61AC /* GroupRequirementTests.swift in Sources */, 55A81C072991BB2C002C259A /* RequestResolverFactoryTests.swift in Sources */, 553CC09B29A96ECD005A5FD6 /* MockIssuanceResponseContaining.swift in Sources */, + 55DECBEF29BA2BEE00D5C802 /* IssuanceRequestContentTests.swift in Sources */, 559BD4EF299EEADF00BD61AC /* AccessTokenRequirementTests.swift in Sources */, 55A81C102991C211002C259A /* MockResolver.swift in Sources */, 559BD4E5299EEA3000BD61AC /* IssuanceResponseContainerExtensionTests.swift in Sources */, 55A81C092991BB3A002C259A /* RequestHandlerFactoryTests.swift in Sources */, 559BD30D2996C12500BD61AC /* VerifiedIdClientBuilderTests.swift in Sources */, + 55DECBD029B922D200D5C802 /* MockPresentationResponder.swift in Sources */, 550A91952994025C0014D030 /* OpenIdURLRequestResolverTests.swift in Sources */, 559BD3052995AB8F00BD61AC /* PresentationDefinition+MappableTests.swift in Sources */, 55A81C0D2991BF86002C259A /* MockInput.swift in Sources */, + 55DECBED29BA29FB00D5C802 /* PresentationResponseContainerExtensionTests.swift in Sources */, 559BD3AF299AF42C00BD61AC /* MockManifestResolver.swift in Sources */, 553CC09929A96C38005A5FD6 /* MockVerifiedId.swift in Sources */, 559BD4F8299EED5700BD61AC /* MockRawManifest.swift in Sources */, diff --git a/WalletLibrary/WalletLibrary/Extensions/Entities/PresentationResponseContainer+WalletLibrary.swift b/WalletLibrary/WalletLibrary/Extensions/Entities/PresentationResponseContainer+WalletLibrary.swift new file mode 100644 index 00000000..efc7650d --- /dev/null +++ b/WalletLibrary/WalletLibrary/Extensions/Entities/PresentationResponseContainer+WalletLibrary.swift @@ -0,0 +1,53 @@ +/*--------------------------------------------------------------------------------------------- +* Copyright (c) Microsoft Corporation. All rights reserved. +* Licensed under the MIT License. See License.txt in the project root for license information. +*--------------------------------------------------------------------------------------------*/ + +import VCEntities + +enum PresentationResponseError: Error, Equatable { + case unableToCastVCSDKPresentationRequestFromRawRequestOfType(String) + case unsupportedRequirementOfType(String) + case unableToCastVerifableCredentialFromVerifiedIdOfType(String) + case missingIdInVerifiedIdRequirement +} + +/** + * An extension of the VCEntities.PresentationResponseContainer class + * to convert Requirements to mappings in PresentationResponseContainer. + */ +extension VCEntities.PresentationResponseContainer: PresentationResponse { + + init(rawRequest: any OpenIdRawRequest) throws { + + guard let presentationRequest = rawRequest as? VCEntities.PresentationRequest else { + let requestType = String(describing: type(of: rawRequest)) + throw PresentationResponseError.unableToCastVCSDKPresentationRequestFromRawRequestOfType(requestType) + } + + try self.init(from: presentationRequest) + } + + mutating func add(requirement: Requirement) throws { + switch (requirement) { + case let groupRequirement as GroupRequirement: + try add(groupRequirement: groupRequirement) + case let verifiedIdRequirement as VerifiedIdRequirement: + try add(verifiedIdRequirement: verifiedIdRequirement) + default: + let requirementType = String(describing: type(of: requirement)) + throw PresentationResponseError.unsupportedRequirementOfType(requirementType) + } + } + + private mutating func add(groupRequirement: GroupRequirement) throws { + try groupRequirement.validate() + for requirement in groupRequirement.requirements { + try add(requirement: requirement) + } + } + + private mutating func add(verifiedIdRequirement: VerifiedIdRequirement) throws { + throw VerifiedIdClientError.TODO(message: "Implement in next PR.") + } +} diff --git a/WalletLibrary/WalletLibrary/Extensions/Mappings/VCSDK/Issuance/IssuanceRequest+Mappable.swift b/WalletLibrary/WalletLibrary/Extensions/Mappings/VCSDK/Issuance/IssuanceRequest+Mappable.swift index 1478f703..e6095e33 100644 --- a/WalletLibrary/WalletLibrary/Extensions/Mappings/VCSDK/Issuance/IssuanceRequest+Mappable.swift +++ b/WalletLibrary/WalletLibrary/Extensions/Mappings/VCSDK/Issuance/IssuanceRequest+Mappable.swift @@ -10,7 +10,7 @@ import VCEntities * TODO: Update Style to include VerifiedIdStyle and more requester style attributes. */ extension VCEntities.IssuanceRequest: Mappable { - func map(using mapper: Mapping) throws -> VerifiedIdRequestContent { + func map(using mapper: Mapping) throws -> IssuanceRequestContent { let attestations = try getRequiredProperty(property: content.input.attestations, propertyName: "attestations") @@ -18,8 +18,8 @@ extension VCEntities.IssuanceRequest: Mappable { let rootOfTrust = try mapper.map(linkedDomainResult) let issuerStyle = Manifest2022IssuerStyle(name: content.display.card.issuedBy) - return VerifiedIdRequestContent(style: issuerStyle, - requirement: requirement, - rootOfTrust: rootOfTrust) + return IssuanceRequestContent(style: issuerStyle, + requirement: requirement, + rootOfTrust: rootOfTrust) } } diff --git a/WalletLibrary/WalletLibrary/Extensions/Mappings/VCSDK/Presentation/PresentationRequest+Mappable.swift b/WalletLibrary/WalletLibrary/Extensions/Mappings/VCSDK/Presentation/PresentationRequest+Mappable.swift index c819637b..2b2a8b77 100644 --- a/WalletLibrary/WalletLibrary/Extensions/Mappings/VCSDK/Presentation/PresentationRequest+Mappable.swift +++ b/WalletLibrary/WalletLibrary/Extensions/Mappings/VCSDK/Presentation/PresentationRequest+Mappable.swift @@ -18,7 +18,7 @@ enum PresentationRequestMappingError: Error { */ extension VCEntities.PresentationRequest: Mappable { - func map(using mapper: Mapping) throws -> VerifiedIdRequestContent { + func map(using mapper: Mapping) throws -> PresentationRequestContent { guard let presentationDefinition = content.claims?.vpToken?.presentationDefinition else { throw PresentationRequestMappingError.presentationDefinitionMissingInRequest @@ -31,10 +31,10 @@ extension VCEntities.PresentationRequest: Mappable { let clientName = content.registration?.clientName ?? "" let requesterStyle = OpenIdVerifierStyle(name: clientName) - let content = VerifiedIdRequestContent(style: requesterStyle, - requirement: requirement, - rootOfTrust: rootOfTrust, - injectedIdToken: injectedIdToken) + let content = PresentationRequestContent(style: requesterStyle, + requirement: requirement, + rootOfTrust: rootOfTrust, + injectedIdToken: injectedIdToken) return content } diff --git a/WalletLibrary/WalletLibrary/Extensions/Services/PresentationService+OpenIdForVC.swift b/WalletLibrary/WalletLibrary/Extensions/Services/PresentationService+OpenIdForVC.swift index 8f4feab2..ffca0a6b 100644 --- a/WalletLibrary/WalletLibrary/Extensions/Services/PresentationService+OpenIdForVC.swift +++ b/WalletLibrary/WalletLibrary/Extensions/Services/PresentationService+OpenIdForVC.swift @@ -6,10 +6,14 @@ import VCEntities import VCServices +enum PresentationServiceError: Error { + case unableToCastOpenIdForVCResponseToPresentationResponseContainer +} + /** * An extension of the VCServices.PresentationService class. */ -extension PresentationService: OpenIdForVCResolver, OpenIdForVCResponder { +extension PresentationService: OpenIdForVCResolver, OpenIdResponder { /// Fetches and validates the presentation request. func getRequest(url: String) async throws -> any OpenIdRawRequest { @@ -20,9 +24,14 @@ extension PresentationService: OpenIdForVCResolver, OpenIdForVCResponder { /// Sends the presentation response container and if successful, returns void, /// If unsuccessful, throws an error. - func send(response: VCEntities.PresentationResponseContainer) async throws -> Void { + func send(response: PresentationResponse) async throws -> Void { + + guard let presentationResponseContainer = response as? PresentationResponseContainer else { + throw PresentationServiceError.unableToCastOpenIdForVCResponseToPresentationResponseContainer + } + let _ = try await AsyncWrapper().wrap { () in - self.send(response: response) + self.send(response: presentationResponseContainer) }() } } diff --git a/WalletLibrary/WalletLibrary/Protocols/Requests/RawRequests/RawManifest.swift b/WalletLibrary/WalletLibrary/Protocols/Requests/Manifest/RawManifest.swift similarity index 87% rename from WalletLibrary/WalletLibrary/Protocols/Requests/RawRequests/RawManifest.swift rename to WalletLibrary/WalletLibrary/Protocols/Requests/Manifest/RawManifest.swift index 405cb341..19f76947 100644 --- a/WalletLibrary/WalletLibrary/Protocols/Requests/RawRequests/RawManifest.swift +++ b/WalletLibrary/WalletLibrary/Protocols/Requests/Manifest/RawManifest.swift @@ -7,5 +7,5 @@ * Representation of a Raw Contract. * Object that conforms to this protocol must be able to map to VerifiedIdRequestContent. */ -protocol RawManifest: Mappable where T == VerifiedIdRequestContent {} +protocol RawManifest: Mappable where T == IssuanceRequestContent {} diff --git a/WalletLibrary/WalletLibrary/Protocols/Requests/OpenIdForVC/OpenIdForVCResolver.swift b/WalletLibrary/WalletLibrary/Protocols/Requests/OpenId/OpenIdForVCResolver.swift similarity index 100% rename from WalletLibrary/WalletLibrary/Protocols/Requests/OpenIdForVC/OpenIdForVCResolver.swift rename to WalletLibrary/WalletLibrary/Protocols/Requests/OpenId/OpenIdForVCResolver.swift diff --git a/WalletLibrary/WalletLibrary/Protocols/Requests/RawRequests/OpenIdRawRequest.swift b/WalletLibrary/WalletLibrary/Protocols/Requests/OpenId/OpenIdRawRequest.swift similarity index 83% rename from WalletLibrary/WalletLibrary/Protocols/Requests/RawRequests/OpenIdRawRequest.swift rename to WalletLibrary/WalletLibrary/Protocols/Requests/OpenId/OpenIdRawRequest.swift index 0c274831..fab5b1fd 100644 --- a/WalletLibrary/WalletLibrary/Protocols/Requests/RawRequests/OpenIdRawRequest.swift +++ b/WalletLibrary/WalletLibrary/Protocols/Requests/OpenId/OpenIdRawRequest.swift @@ -7,9 +7,7 @@ * Representation of a Raw Open Id Request. * Object that conforms to this protocol must be able to map to VerifiedIdRequestContent. */ -protocol OpenIdRawRequest: Mappable where T == VerifiedIdRequestContent { +protocol OpenIdRawRequest: Mappable where T == PresentationRequestContent { var type: RequestType { get } - - var raw: Data? { get } } diff --git a/WalletLibrary/WalletLibrary/Protocols/Requests/OpenIdForVC/OpenIdForVCResponder.swift b/WalletLibrary/WalletLibrary/Protocols/Requests/OpenId/OpenIdResponder.swift similarity index 72% rename from WalletLibrary/WalletLibrary/Protocols/Requests/OpenIdForVC/OpenIdForVCResponder.swift rename to WalletLibrary/WalletLibrary/Protocols/Requests/OpenId/OpenIdResponder.swift index f2babc79..9731eef8 100644 --- a/WalletLibrary/WalletLibrary/Protocols/Requests/OpenIdForVC/OpenIdForVCResponder.swift +++ b/WalletLibrary/WalletLibrary/Protocols/Requests/OpenId/OpenIdResponder.swift @@ -8,8 +8,8 @@ import VCEntities /** * Protocol is used as a wrapper to wrap the VC SDK send presentation response method. */ -protocol OpenIdForVCResponder { - /// Sends the presentation response container and if successful, returns void, +protocol OpenIdResponder { + /// Sends the presentation response and if successful, returns void, /// If unsuccessful, throws an error. - func send(response: PresentationResponseContainer) async throws -> Void + func send(response: PresentationResponse) async throws -> Void } diff --git a/WalletLibrary/WalletLibrary/Protocols/Requests/PresentationResponse.swift b/WalletLibrary/WalletLibrary/Protocols/Requests/PresentationResponse.swift new file mode 100644 index 00000000..4a460c1b --- /dev/null +++ b/WalletLibrary/WalletLibrary/Protocols/Requests/PresentationResponse.swift @@ -0,0 +1,12 @@ +/*--------------------------------------------------------------------------------------------- +* Copyright (c) Microsoft Corporation. All rights reserved. +* Licensed under the MIT License. See License.txt in the project root for license information. +*--------------------------------------------------------------------------------------------*/ + +/** + * An object that describes a raw presentation response and defines the behavior of adding a requirement to it. + * For example, a VCSDK.PresentationResponseContainer conforms to this protocol. + */ +protocol PresentationResponse { + mutating func add(requirement: Requirement) throws +} diff --git a/WalletLibrary/WalletLibrary/Requests/Handlers/OpenIdRequestHandler.swift b/WalletLibrary/WalletLibrary/Requests/Handlers/OpenIdRequestHandler.swift index f9f56a1e..40cdfa7a 100644 --- a/WalletLibrary/WalletLibrary/Requests/Handlers/OpenIdRequestHandler.swift +++ b/WalletLibrary/WalletLibrary/Requests/Handlers/OpenIdRequestHandler.swift @@ -19,17 +19,21 @@ struct OpenIdRequestHandler: RequestHandling { private let configuration: LibraryConfiguration + private let openIdResponder: OpenIdResponder + private let manifestResolver: ManifestResolver - private let verifiableCredentialRequester: VerifiedIdRequester + private let verifiedIdRequester: VerifiedIdRequester /// TODO: post private preview, manifest resolving and verified id requester will be handled by processors. init(configuration: LibraryConfiguration, + openIdResponder: OpenIdResponder, manifestResolver: ManifestResolver, verifiableCredentialRequester: VerifiedIdRequester) { self.configuration = configuration + self.openIdResponder = openIdResponder self.manifestResolver = manifestResolver - self.verifiableCredentialRequester = verifiableCredentialRequester + self.verifiedIdRequester = verifiableCredentialRequester } /// Create a VeriifiedIdRequest based on the Open Id raw request given. @@ -45,10 +49,10 @@ struct OpenIdRequestHandler: RequestHandling { return try await handleIssuanceRequest(from: requestContent) } - return try handlePresentationRequest(from: requestContent) + return handlePresentationRequest(requestContent: requestContent, rawRequest: request) } - private func handleIssuanceRequest(from requestContent: VerifiedIdRequestContent) async throws -> any VerifiedIdIssuanceRequest { + private func handleIssuanceRequest(from requestContent: PresentationRequestContent) async throws -> any VerifiedIdIssuanceRequest { guard let verifiedIdRequirement = requestContent.requirement as? VerifiedIdRequirement else { throw OpenIdRequestHandlerError.unableToCastRequirementToVerifiedIdRequirement @@ -69,11 +73,15 @@ struct OpenIdRequestHandler: RequestHandling { return ContractIssuanceRequest(content: issuanceRequestContent, issuanceResponseContainer: issuanceResponseContainer, - verifiedIdRequester: verifiableCredentialRequester, + verifiedIdRequester: verifiedIdRequester, configuration: configuration) } - private func handlePresentationRequest(from requestContent: VerifiedIdRequestContent) throws -> any VerifiedIdPresentationRequest { - return OpenIdPresentationRequest(content: requestContent, configuration: configuration) + private func handlePresentationRequest(requestContent: PresentationRequestContent, + rawRequest: any OpenIdRawRequest) -> any VerifiedIdPresentationRequest { + return OpenIdPresentationRequest(content: requestContent, + rawRequest: rawRequest, + openIdResponder: openIdResponder, + configuration: configuration) } } diff --git a/WalletLibrary/WalletLibrary/Requests/RequestHandlerFactory.swift b/WalletLibrary/WalletLibrary/Requests/Handlers/RequestHandlerFactory.swift similarity index 100% rename from WalletLibrary/WalletLibrary/Requests/RequestHandlerFactory.swift rename to WalletLibrary/WalletLibrary/Requests/Handlers/RequestHandlerFactory.swift diff --git a/WalletLibrary/WalletLibrary/Requests/VerifiedIdRequestContent.swift b/WalletLibrary/WalletLibrary/Requests/IssuanceRequestContent.swift similarity index 64% rename from WalletLibrary/WalletLibrary/Requests/VerifiedIdRequestContent.swift rename to WalletLibrary/WalletLibrary/Requests/IssuanceRequestContent.swift index d86ad605..9ef459f2 100644 --- a/WalletLibrary/WalletLibrary/Requests/VerifiedIdRequestContent.swift +++ b/WalletLibrary/WalletLibrary/Requests/IssuanceRequestContent.swift @@ -4,12 +4,15 @@ *--------------------------------------------------------------------------------------------*/ /** - * Contents in a Verified Id Request. + * Contents in a Verified Id Issuance Request. * This object is used to map protocol specific requests to common request object. - * TODO: make this object extensible by separating Presentation with Issuance esp. for InjectedIdToken logic. * TODO: add VerifiedIdStyle to Issuance Content. */ -struct VerifiedIdRequestContent { +struct IssuanceRequestContent { + + private struct Constants { + static let IdTokenHintKey = "https://self-issued.me" + } let style: RequesterStyle @@ -17,37 +20,32 @@ struct VerifiedIdRequestContent { let rootOfTrust: RootOfTrust - let injectedIdToken: InjectedIdToken? - - init(style: RequesterStyle, - requirement: Requirement, - rootOfTrust: RootOfTrust, - injectedIdToken: InjectedIdToken? = nil) { - self.style = style - self.requirement = requirement - self.rootOfTrust = rootOfTrust - self.injectedIdToken = injectedIdToken - } - mutating func addRequirement(from injectedIdToken: InjectedIdToken) { switch (requirement) { case var groupRequirement as GroupRequirement: - repopulateGroupRequirementIfInjectedIdTokenExists(injectedIdToken: injectedIdToken, - groupRequirement: &groupRequirement) + repopulate(groupRequirement: groupRequirement, from: injectedIdToken) case let idTokenRequirement as IdTokenRequirement: + add(injectedIdToken: injectedIdToken, + to: idTokenRequirement) + default: + return + } + } + + private mutating func add(injectedIdToken: InjectedIdToken, + to idTokenRequirement: IdTokenRequirement) { + if idTokenRequirement.configuration.absoluteString == Constants.IdTokenHintKey { idTokenRequirement.fulfill(with: injectedIdToken.rawToken) if let pinRequirement = injectedIdToken.pin { requirement = GroupRequirement(required: false, requirements: [idTokenRequirement, pinRequirement], requirementOperator: .ALL) } - default: - return } } - private func repopulateGroupRequirementIfInjectedIdTokenExists(injectedIdToken: InjectedIdToken, - groupRequirement: inout GroupRequirement) { + private func repopulate(groupRequirement: GroupRequirement, + from injectedIdToken: InjectedIdToken) { for requirement in groupRequirement.requirements { if let idTokenRequirement = requirement as? IdTokenRequirement { idTokenRequirement.fulfill(with: injectedIdToken.rawToken) diff --git a/WalletLibrary/WalletLibrary/Requests/RequestProtocols/Manifest/ContractIssuanceRequest.swift b/WalletLibrary/WalletLibrary/Requests/Manifest/ContractIssuanceRequest.swift similarity index 97% rename from WalletLibrary/WalletLibrary/Requests/RequestProtocols/Manifest/ContractIssuanceRequest.swift rename to WalletLibrary/WalletLibrary/Requests/Manifest/ContractIssuanceRequest.swift index 11edd9fb..97e6c596 100644 --- a/WalletLibrary/WalletLibrary/Requests/RequestProtocols/Manifest/ContractIssuanceRequest.swift +++ b/WalletLibrary/WalletLibrary/Requests/Manifest/ContractIssuanceRequest.swift @@ -23,7 +23,7 @@ class ContractIssuanceRequest: VerifiedIdIssuanceRequest { private var responseContainer: IssuanceResponseContaining - init(content: VerifiedIdRequestContent, + init(content: IssuanceRequestContent, issuanceResponseContainer: IssuanceResponseContaining, verifiedIdRequester: VerifiedIdRequester, configuration: LibraryConfiguration) { diff --git a/WalletLibrary/WalletLibrary/Requests/RequestProtocols/Manifest/Manifest2022IssuerStyle.swift b/WalletLibrary/WalletLibrary/Requests/Manifest/Manifest2022IssuerStyle.swift similarity index 100% rename from WalletLibrary/WalletLibrary/Requests/RequestProtocols/Manifest/Manifest2022IssuerStyle.swift rename to WalletLibrary/WalletLibrary/Requests/Manifest/Manifest2022IssuerStyle.swift diff --git a/WalletLibrary/WalletLibrary/Requests/RequestProtocols/OpenId/InjectedIdToken.swift b/WalletLibrary/WalletLibrary/Requests/OpenId/InjectedIdToken.swift similarity index 100% rename from WalletLibrary/WalletLibrary/Requests/RequestProtocols/OpenId/InjectedIdToken.swift rename to WalletLibrary/WalletLibrary/Requests/OpenId/InjectedIdToken.swift diff --git a/WalletLibrary/WalletLibrary/Requests/RequestProtocols/OpenId/OpenIdPresentationRequest.swift b/WalletLibrary/WalletLibrary/Requests/OpenId/OpenIdPresentationRequest.swift similarity index 77% rename from WalletLibrary/WalletLibrary/Requests/RequestProtocols/OpenId/OpenIdPresentationRequest.swift rename to WalletLibrary/WalletLibrary/Requests/OpenId/OpenIdPresentationRequest.swift index d5781e56..3acec84b 100644 --- a/WalletLibrary/WalletLibrary/Requests/RequestProtocols/OpenId/OpenIdPresentationRequest.swift +++ b/WalletLibrary/WalletLibrary/Requests/OpenId/OpenIdPresentationRequest.swift @@ -15,12 +15,22 @@ class OpenIdPresentationRequest: VerifiedIdPresentationRequest { let rootOfTrust: RootOfTrust + private let rawRequest: any OpenIdRawRequest + + private let responder: OpenIdResponder + private let configuration: LibraryConfiguration - init(content: VerifiedIdRequestContent, configuration: LibraryConfiguration) { + init(content: PresentationRequestContent, + rawRequest: any OpenIdRawRequest, + openIdResponder: OpenIdResponder, + configuration: LibraryConfiguration) { + self.style = content.style self.requirement = content.requirement self.rootOfTrust = content.rootOfTrust + self.rawRequest = rawRequest + self.responder = openIdResponder self.configuration = configuration } diff --git a/WalletLibrary/WalletLibrary/Requests/RequestProtocols/OpenId/OpenIdVerifierStyle.swift b/WalletLibrary/WalletLibrary/Requests/OpenId/OpenIdVerifierStyle.swift similarity index 100% rename from WalletLibrary/WalletLibrary/Requests/RequestProtocols/OpenId/OpenIdVerifierStyle.swift rename to WalletLibrary/WalletLibrary/Requests/OpenId/OpenIdVerifierStyle.swift diff --git a/WalletLibrary/WalletLibrary/Requests/PresentationRequestContent.swift b/WalletLibrary/WalletLibrary/Requests/PresentationRequestContent.swift new file mode 100644 index 00000000..ee220218 --- /dev/null +++ b/WalletLibrary/WalletLibrary/Requests/PresentationRequestContent.swift @@ -0,0 +1,29 @@ +/*--------------------------------------------------------------------------------------------- +* Copyright (c) Microsoft Corporation. All rights reserved. +* Licensed under the MIT License. See License.txt in the project root for license information. +*--------------------------------------------------------------------------------------------*/ + +/** + * Contents in a Verified Id Presentation Request. + * This object is used to map protocol specific requests to common request object. + */ +struct PresentationRequestContent { + + let style: RequesterStyle + + var requirement: Requirement + + let rootOfTrust: RootOfTrust + + let injectedIdToken: InjectedIdToken? + + init(style: RequesterStyle, + requirement: Requirement, + rootOfTrust: RootOfTrust, + injectedIdToken: InjectedIdToken? = nil) { + self.style = style + self.requirement = requirement + self.rootOfTrust = rootOfTrust + self.injectedIdToken = injectedIdToken + } +} diff --git a/WalletLibrary/WalletLibrary/Requests/RequestResolverFactory.swift b/WalletLibrary/WalletLibrary/Requests/Resolvers/RequestResolverFactory.swift similarity index 100% rename from WalletLibrary/WalletLibrary/Requests/RequestResolverFactory.swift rename to WalletLibrary/WalletLibrary/Requests/Resolvers/RequestResolverFactory.swift diff --git a/WalletLibrary/WalletLibrary/VerifiedIdClientBuilder.swift b/WalletLibrary/WalletLibrary/VerifiedIdClientBuilder.swift index 369d8d2e..a13fb912 100644 --- a/WalletLibrary/WalletLibrary/VerifiedIdClientBuilder.swift +++ b/WalletLibrary/WalletLibrary/VerifiedIdClientBuilder.swift @@ -51,7 +51,9 @@ public class VerifiedIdClientBuilder { private func registerSupportedRequestHandlers(with configuration: LibraryConfiguration) { let issuanceService = IssuanceService() + let presentationService = PresentationService() let openIdHandler = OpenIdRequestHandler(configuration: configuration, + openIdResponder: presentationService, manifestResolver: issuanceService, verifiableCredentialRequester: issuanceService) requestHandlers.append(openIdHandler) diff --git a/WalletLibrary/WalletLibraryTests/Extensions/Entities/PresentationResponseContainerExtensionTests.swift b/WalletLibrary/WalletLibraryTests/Extensions/Entities/PresentationResponseContainerExtensionTests.swift new file mode 100644 index 00000000..379ad6c5 --- /dev/null +++ b/WalletLibrary/WalletLibraryTests/Extensions/Entities/PresentationResponseContainerExtensionTests.swift @@ -0,0 +1,89 @@ +/*--------------------------------------------------------------------------------------------- +* Copyright (c) Microsoft Corporation. All rights reserved. +* Licensed under the MIT License. See License.txt in the project root for license information. +*--------------------------------------------------------------------------------------------*/ + +import XCTest +import VCEntities +import VCToken +@testable import WalletLibrary + +class PresentationResponseContainerExtensionTests: XCTestCase { + + enum MockError: Error { + case expectedInvalidRequirement + case secondExpectedInvalidRequirement + case thirdExpectedInvalidRequirement + } + + func testInit_WithInvalidOpenIdRawRequest_ThrowsError() throws { + + // Arrange + let mockRawRequest = MockOpenIdRawRequest(raw: nil) + + // Act + XCTAssertThrowsError(try PresentationResponseContainer(rawRequest: mockRawRequest)) { error in + // Assert + XCTAssert(error is PresentationResponseError) + XCTAssertEqual(error as? PresentationResponseError, + PresentationResponseError.unableToCastVCSDKPresentationRequestFromRawRequestOfType("MockOpenIdRawRequest")) + } + } + + func testInit_WithValidInput_ReturnPresentationResponseContainer() throws { + // Arrange + let rawPresentationRequest = createPresentationRequest() + + // Act + let result = try PresentationResponseContainer(rawRequest: rawPresentationRequest) + + // Assert + XCTAssertEqual(result.audienceDid, "expectedAudienceDid") + XCTAssertEqual(result.audienceUrl, "expectedAudienceUrl") + XCTAssertEqual(result.nonce, "expectedNonce") + XCTAssert(result.requestVCMap.isEmpty) + } + + func testAddRequirement_WithInvalidRequirementType_ThrowsError() async throws { + // Arrange + let mockPresentationRequest = createPresentationRequest() + let invalidRequirement = MockRequirement(id: "mockRequirement") + var presentationResponse = try PresentationResponseContainer(rawRequest: mockPresentationRequest) + + // Act + XCTAssertThrowsError(try presentationResponse.add(requirement: invalidRequirement)) { error in + // Assert + XCTAssert(error is PresentationResponseError) + XCTAssertEqual(error as? PresentationResponseError, + PresentationResponseError.unsupportedRequirementOfType("MockRequirement")) + } + } + + func testAddRequirement_WithVerifiedIdRequirement_AddsVCToMap() async throws { + // TODO + } + + func testAddRequirement_WithMultipleVerifiedIdRequirements_AddsVCsToMap() async throws { + // TODO + } + + private func createPresentationRequest() -> PresentationRequest { + let mockClaims = PresentationRequestClaims(jti: "", + clientID: "expectedAudienceDid", + redirectURI: "expectedAudienceUrl", + responseMode: "", + responseType: "", + claims: nil, + state: "", + nonce: "expectedNonce", + scope: "", + prompt: "", + registration: nil, + iat: nil, + exp: nil, + pin: nil) + let mockToken = PresentationRequestToken(headers: Header(), content: mockClaims)! + let rawPresentationRequest = PresentationRequest(from: mockToken, linkedDomainResult: LinkedDomainResult.linkedDomainMissing) + return rawPresentationRequest + } +} diff --git a/WalletLibrary/WalletLibraryTests/Mocks/Requests/Manifest/MockRawManifest.swift b/WalletLibrary/WalletLibraryTests/Mocks/Requests/Manifest/MockRawManifest.swift index 6f29330f..fd3fa948 100644 --- a/WalletLibrary/WalletLibraryTests/Mocks/Requests/Manifest/MockRawManifest.swift +++ b/WalletLibrary/WalletLibraryTests/Mocks/Requests/Manifest/MockRawManifest.swift @@ -13,7 +13,7 @@ struct MockRawManifest: RawManifest, Equatable { self.id = id } - func map(using mapper: Mapping) throws -> VerifiedIdRequestContent { + func map(using mapper: Mapping) throws -> IssuanceRequestContent { throw VerifiedIdClientError.TODO(message: "implement") } } diff --git a/WalletLibrary/WalletLibraryTests/Mocks/Requests/MockPresentationResponder.swift b/WalletLibrary/WalletLibraryTests/Mocks/Requests/MockPresentationResponder.swift new file mode 100644 index 00000000..7949e1ad --- /dev/null +++ b/WalletLibrary/WalletLibraryTests/Mocks/Requests/MockPresentationResponder.swift @@ -0,0 +1,11 @@ +/*--------------------------------------------------------------------------------------------- +* Copyright (c) Microsoft Corporation. All rights reserved. +* Licensed under the MIT License. See License.txt in the project root for license information. +*--------------------------------------------------------------------------------------------*/ + +@testable import WalletLibrary + +class MockPresentationResponder: OpenIdResponder { + + func send(response: PresentationResponse) async throws { } +} diff --git a/WalletLibrary/WalletLibraryTests/Mocks/Requests/OpenIdForVC/MockOpenIdRawRequest.swift b/WalletLibrary/WalletLibraryTests/Mocks/Requests/OpenIdForVC/MockOpenIdRawRequest.swift index 25a4e26b..b922d100 100644 --- a/WalletLibrary/WalletLibraryTests/Mocks/Requests/OpenIdForVC/MockOpenIdRawRequest.swift +++ b/WalletLibrary/WalletLibraryTests/Mocks/Requests/OpenIdForVC/MockOpenIdRawRequest.swift @@ -16,7 +16,7 @@ struct MockOpenIdRawRequest: OpenIdRawRequest, Equatable { self.type = type } - func map(using mapper: Mapping) throws -> VerifiedIdRequestContent { + func map(using mapper: Mapping) throws -> PresentationRequestContent { throw VerifiedIdClientError.TODO(message: "not implemented") } } diff --git a/WalletLibrary/WalletLibraryTests/Requests/Handlers/OpenIdRequestHandlerTests.swift b/WalletLibrary/WalletLibraryTests/Requests/Handlers/OpenIdRequestHandlerTests.swift index e4759e92..66267dc3 100644 --- a/WalletLibrary/WalletLibraryTests/Requests/Handlers/OpenIdRequestHandlerTests.swift +++ b/WalletLibrary/WalletLibraryTests/Requests/Handlers/OpenIdRequestHandlerTests.swift @@ -22,9 +22,9 @@ class OpenIdRequestHandlerTests: XCTestCase { let expectedStyle = MockRequesterStyle(requester: "mock requester") let expectedRequirement = MockRequirement(id: "mockRequirement324") let expectedRootOfTrust = RootOfTrust(verified: true, source: "mock source") - let expectedContent = VerifiedIdRequestContent(style: expectedStyle, - requirement: expectedRequirement, - rootOfTrust: expectedRootOfTrust) + let expectedContent = PresentationRequestContent(style: expectedStyle, + requirement: expectedRequirement, + rootOfTrust: expectedRootOfTrust) func mockResults(objectToBeMapped: Any) throws -> Any? { if objectToBeMapped is MockOpenIdRawRequest { @@ -38,6 +38,7 @@ class OpenIdRequestHandlerTests: XCTestCase { let mockRawRequest = MockOpenIdRawRequest(raw: Data()) let configuration = LibraryConfiguration(logger: WalletLibraryLogger(), mapper: mockMapper) let handler = OpenIdRequestHandler(configuration: configuration, + openIdResponder: MockPresentationResponder(), manifestResolver: MockManifestResolver(), verifiableCredentialRequester: MockVerifiedIdRequester()) @@ -67,6 +68,7 @@ class OpenIdRequestHandlerTests: XCTestCase { let mockRawRequest = MockOpenIdRawRequest(raw: Data()) let configuration = LibraryConfiguration(logger: WalletLibraryLogger(), mapper: mockMapper) let handler = OpenIdRequestHandler(configuration: configuration, + openIdResponder: MockPresentationResponder(), manifestResolver: MockManifestResolver(), verifiableCredentialRequester: MockVerifiedIdRequester()) @@ -87,9 +89,9 @@ class OpenIdRequestHandlerTests: XCTestCase { let expectedStyle = MockRequesterStyle(requester: "mock requester") let expectedRequirement = MockRequirement(id: "test") let expectedRootOfTrust = RootOfTrust(verified: true, source: "mock source") - let expectedContent = VerifiedIdRequestContent(style: expectedStyle, - requirement: expectedRequirement, - rootOfTrust: expectedRootOfTrust) + let expectedContent = PresentationRequestContent(style: expectedStyle, + requirement: expectedRequirement, + rootOfTrust: expectedRootOfTrust) func mockResults(objectToBeMapped: Any) throws -> Any? { if objectToBeMapped is MockOpenIdRawRequest { @@ -103,6 +105,7 @@ class OpenIdRequestHandlerTests: XCTestCase { let mockRawRequest = MockOpenIdRawRequest(raw: Data(), type: .Issuance) let configuration = LibraryConfiguration(logger: WalletLibraryLogger(), mapper: mockMapper) let handler = OpenIdRequestHandler(configuration: configuration, + openIdResponder: MockPresentationResponder(), manifestResolver: MockManifestResolver(), verifiableCredentialRequester: MockVerifiedIdRequester()) @@ -127,9 +130,9 @@ class OpenIdRequestHandlerTests: XCTestCase { purpose: nil, issuanceOptions: []) let expectedRootOfTrust = RootOfTrust(verified: true, source: "mock source") - let expectedContent = VerifiedIdRequestContent(style: expectedStyle, - requirement: expectedRequirement, - rootOfTrust: expectedRootOfTrust) + let expectedContent = PresentationRequestContent(style: expectedStyle, + requirement: expectedRequirement, + rootOfTrust: expectedRootOfTrust) func mockResults(objectToBeMapped: Any) throws -> Any? { if objectToBeMapped is MockOpenIdRawRequest { @@ -143,6 +146,7 @@ class OpenIdRequestHandlerTests: XCTestCase { let mockRawRequest = MockOpenIdRawRequest(raw: Data(), type: .Issuance) let configuration = LibraryConfiguration(logger: WalletLibraryLogger(), mapper: mockMapper) let handler = OpenIdRequestHandler(configuration: configuration, + openIdResponder: MockPresentationResponder(), manifestResolver: MockManifestResolver(), verifiableCredentialRequester: MockVerifiedIdRequester()) @@ -167,9 +171,9 @@ class OpenIdRequestHandlerTests: XCTestCase { purpose: nil, issuanceOptions: [MockInput(mockData: "")]) let expectedRootOfTrust = RootOfTrust(verified: true, source: "mock source") - let expectedContent = VerifiedIdRequestContent(style: expectedStyle, - requirement: expectedRequirement, - rootOfTrust: expectedRootOfTrust) + let expectedContent = PresentationRequestContent(style: expectedStyle, + requirement: expectedRequirement, + rootOfTrust: expectedRootOfTrust) func mockResults(objectToBeMapped: Any) throws -> Any? { if objectToBeMapped is MockOpenIdRawRequest { @@ -183,6 +187,7 @@ class OpenIdRequestHandlerTests: XCTestCase { let mockRawRequest = MockOpenIdRawRequest(raw: Data(), type: .Issuance) let configuration = LibraryConfiguration(logger: WalletLibraryLogger(), mapper: mockMapper) let handler = OpenIdRequestHandler(configuration: configuration, + openIdResponder: MockPresentationResponder(), manifestResolver: MockManifestResolver(), verifiableCredentialRequester: MockVerifiedIdRequester()) @@ -208,9 +213,9 @@ class OpenIdRequestHandlerTests: XCTestCase { purpose: nil, issuanceOptions: [VerifiedIdRequestURL(url: issuanceOptionURL)]) let expectedRootOfTrust = RootOfTrust(verified: true, source: "mock source") - let expectedContent = VerifiedIdRequestContent(style: expectedStyle, - requirement: expectedRequirement, - rootOfTrust: expectedRootOfTrust) + let expectedContent = PresentationRequestContent(style: expectedStyle, + requirement: expectedRequirement, + rootOfTrust: expectedRootOfTrust) func mockResults(objectToBeMapped: Any) throws -> Any? { if objectToBeMapped is MockOpenIdRawRequest { @@ -228,6 +233,7 @@ class OpenIdRequestHandlerTests: XCTestCase { let mockRawRequest = MockOpenIdRawRequest(raw: Data(), type: .Issuance) let configuration = LibraryConfiguration(logger: WalletLibraryLogger(), mapper: mockMapper) let handler = OpenIdRequestHandler(configuration: configuration, + openIdResponder: MockPresentationResponder(), manifestResolver: MockManifestResolver(mockGetRequestCallback: mockResolveContract), verifiableCredentialRequester: MockVerifiedIdRequester()) @@ -253,9 +259,9 @@ class OpenIdRequestHandlerTests: XCTestCase { purpose: nil, issuanceOptions: [VerifiedIdRequestURL(url: issuanceOptionURL)]) let expectedRootOfTrust = RootOfTrust(verified: true, source: "mock source") - let expectedContent = VerifiedIdRequestContent(style: expectedStyle, - requirement: expectedRequirement, - rootOfTrust: expectedRootOfTrust) + let expectedContent = PresentationRequestContent(style: expectedStyle, + requirement: expectedRequirement, + rootOfTrust: expectedRootOfTrust) func mockResults(objectToBeMapped: Any) throws -> Any? { if objectToBeMapped is MockOpenIdRawRequest { @@ -277,6 +283,7 @@ class OpenIdRequestHandlerTests: XCTestCase { let mockRawRequest = MockOpenIdRawRequest(raw: Data(), type: .Issuance) let configuration = LibraryConfiguration(logger: WalletLibraryLogger(), mapper: mockMapper) let handler = OpenIdRequestHandler(configuration: configuration, + openIdResponder: MockPresentationResponder(), manifestResolver: MockManifestResolver(mockGetRequestCallback: mockResolveContract), verifiableCredentialRequester: MockVerifiedIdRequester()) @@ -302,16 +309,16 @@ class OpenIdRequestHandlerTests: XCTestCase { purpose: nil, issuanceOptions: [VerifiedIdRequestURL(url: issuanceOptionURL)]) let expectedPresentationRootOfTrust = RootOfTrust(verified: true, source: "mock source") - let expectedPresentationContent = VerifiedIdRequestContent(style: expectedPresentationStyle, - requirement: expectedPresentationRequirement, - rootOfTrust: expectedPresentationRootOfTrust) + let expectedPresentationContent = PresentationRequestContent(style: expectedPresentationStyle, + requirement: expectedPresentationRequirement, + rootOfTrust: expectedPresentationRootOfTrust) let expectedIssuanceStyle = MockRequesterStyle(requester: "mock issuer") let expectedIssuanceRequirement = MockRequirement(id: "mockRequirement23535") let expectedIssuanceRootOfTrust = RootOfTrust(verified: true, source: "mock issuer source") - let expectedIssuanceContent = VerifiedIdRequestContent(style: expectedIssuanceStyle, - requirement: expectedIssuanceRequirement, - rootOfTrust: expectedIssuanceRootOfTrust) + let expectedIssuanceContent = IssuanceRequestContent(style: expectedIssuanceStyle, + requirement: expectedIssuanceRequirement, + rootOfTrust: expectedIssuanceRootOfTrust) func mockResults(objectToBeMapped: Any) throws -> Any? { if objectToBeMapped is MockOpenIdRawRequest { @@ -333,6 +340,7 @@ class OpenIdRequestHandlerTests: XCTestCase { let mockRawRequest = MockOpenIdRawRequest(raw: Data(), type: .Issuance) let configuration = LibraryConfiguration(logger: WalletLibraryLogger(), mapper: mockMapper) let handler = OpenIdRequestHandler(configuration: configuration, + openIdResponder: MockPresentationResponder(), manifestResolver: MockManifestResolver(mockGetRequestCallback: mockResolveContract), verifiableCredentialRequester: MockVerifiedIdRequester()) @@ -359,17 +367,17 @@ class OpenIdRequestHandlerTests: XCTestCase { issuanceOptions: [VerifiedIdRequestURL(url: issuanceOptionURL)]) let expectedPresentationRootOfTrust = RootOfTrust(verified: true, source: "mock source") let expectedInjectedIdToken = InjectedIdToken(rawToken: "mock idToken hint", pin: nil) - let expectedPresentationContent = VerifiedIdRequestContent(style: expectedPresentationStyle, - requirement: expectedPresentationRequirement, - rootOfTrust: expectedPresentationRootOfTrust, - injectedIdToken: expectedInjectedIdToken) + let expectedPresentationContent = PresentationRequestContent(style: expectedPresentationStyle, + requirement: expectedPresentationRequirement, + rootOfTrust: expectedPresentationRootOfTrust, + injectedIdToken: expectedInjectedIdToken) let expectedIssuanceStyle = MockRequesterStyle(requester: "mock issuer") let expectedIssuanceRequirement = MockRequirement(id: "mockRequirement23535") let expectedIssuanceRootOfTrust = RootOfTrust(verified: true, source: "mock issuer source") - let expectedIssuanceContent = VerifiedIdRequestContent(style: expectedIssuanceStyle, - requirement: expectedIssuanceRequirement, - rootOfTrust: expectedIssuanceRootOfTrust) + let expectedIssuanceContent = IssuanceRequestContent(style: expectedIssuanceStyle, + requirement: expectedIssuanceRequirement, + rootOfTrust: expectedIssuanceRootOfTrust) func mockResults(objectToBeMapped: Any) throws -> Any? { if objectToBeMapped is MockOpenIdRawRequest { @@ -391,6 +399,7 @@ class OpenIdRequestHandlerTests: XCTestCase { let mockRawRequest = MockOpenIdRawRequest(raw: Data(), type: .Issuance) let configuration = LibraryConfiguration(logger: WalletLibraryLogger(), mapper: mockMapper) let handler = OpenIdRequestHandler(configuration: configuration, + openIdResponder: MockPresentationResponder(), manifestResolver: MockManifestResolver(mockGetRequestCallback: mockResolveContract), verifiableCredentialRequester: MockVerifiedIdRequester()) @@ -426,7 +435,7 @@ class OpenIdRequestHandlerTests: XCTestCase { let mockContract = Contract(id: "mockContract", display: mockDisplayDescriptor, input: mockContractInputDescriptor) - + let mockSignedContract = SignedContract(headers: Header(), content: mockContract)! return IssuanceRequest(from: mockSignedContract, linkedDomainResult: .linkedDomainMissing) } diff --git a/WalletLibrary/WalletLibraryTests/Requests/IssuanceRequestContentTests.swift b/WalletLibrary/WalletLibraryTests/Requests/IssuanceRequestContentTests.swift new file mode 100644 index 00000000..f87be8b2 --- /dev/null +++ b/WalletLibrary/WalletLibraryTests/Requests/IssuanceRequestContentTests.swift @@ -0,0 +1,141 @@ +/*--------------------------------------------------------------------------------------------- +* Copyright (c) Microsoft Corporation. All rights reserved. +* Licensed under the MIT License. See License.txt in the project root for license information. +*--------------------------------------------------------------------------------------------*/ + +import XCTest +@testable import WalletLibrary + +class IssuanceRequestContentTests: XCTestCase { + + func testAddInjectedIdToken_WithIdTokenRequirementAndNoPin_AddIdTokenToRequirement() async throws { + + // Arrange + let idTokenRequirement = createIdTokenRequirement() + var issuanceRequestContent = IssuanceRequestContent(style: Manifest2022IssuerStyle(name: "mockIssuerName"), + requirement: idTokenRequirement, + rootOfTrust: RootOfTrust(verified: false, source: nil)) + let injectedIdToken = InjectedIdToken(rawToken: "mockRawToken", pin: nil) + + // Act + issuanceRequestContent.addRequirement(from: injectedIdToken) + + // Assert + XCTAssert(issuanceRequestContent.requirement is IdTokenRequirement) + XCTAssertEqual((issuanceRequestContent.requirement as? IdTokenRequirement)?.idToken, injectedIdToken.rawToken) + + } + + func testAddInjectedIdToken_WithIdTokenRequirementWithInvalidConfigurationValue_DoesNothing() async throws { + + // Arrange + let idTokenRequirement = createIdTokenRequirement(configuration: "https://invalidConfiguration.me") + var issuanceRequestContent = IssuanceRequestContent(style: Manifest2022IssuerStyle(name: "mockIssuerName"), + requirement: idTokenRequirement, + rootOfTrust: RootOfTrust(verified: false, source: nil)) + let injectedIdToken = InjectedIdToken(rawToken: "mockRawToken", pin: nil) + + // Act + issuanceRequestContent.addRequirement(from: injectedIdToken) + + // Assert + XCTAssert(issuanceRequestContent.requirement is IdTokenRequirement) + XCTAssertNil((issuanceRequestContent.requirement as? IdTokenRequirement)?.idToken) + } + + func testAddInjectedIdToken_WithIdTokenRequirementAndPin_CreatesGroupRequirement() async throws { + + // Arrange + let idTokenRequirement = createIdTokenRequirement() + var issuanceRequestContent = IssuanceRequestContent(style: Manifest2022IssuerStyle(name: "mockIssuerName"), + requirement: idTokenRequirement, + rootOfTrust: RootOfTrust(verified: false, source: nil)) + let pinRequirement = PinRequirement(required: false, + length: 4, + type: "numeric", + salt: nil) + let injectedIdToken = InjectedIdToken(rawToken: "mockRawToken", pin: pinRequirement) + + // Act + issuanceRequestContent.addRequirement(from: injectedIdToken) + + // Assert + XCTAssert(issuanceRequestContent.requirement is GroupRequirement) + XCTAssertEqual((issuanceRequestContent.requirement as? GroupRequirement)?.requirements.count, 2) + XCTAssertIdentical((issuanceRequestContent.requirement as? GroupRequirement)?.requirements.first as AnyObject, + idTokenRequirement as AnyObject) + XCTAssertEqual(((issuanceRequestContent.requirement as? GroupRequirement)?.requirements.first as? IdTokenRequirement)?.idToken, + injectedIdToken.rawToken) + XCTAssertIdentical((issuanceRequestContent.requirement as? GroupRequirement)?.requirements[1] as AnyObject, + pinRequirement as AnyObject) + } + + func testAddInjectedIdToken_WithGroupRequirementAndNoPin_AddsIdTokenRequirement() async throws { + + // Arrange + let mockRequirement = MockRequirement(id: "mockRequirement") + let idTokenRequirement = createIdTokenRequirement() + let groupRequirement = GroupRequirement(required: false, + requirements: [mockRequirement, idTokenRequirement], + requirementOperator: .ALL) + var issuanceRequestContent = IssuanceRequestContent(style: Manifest2022IssuerStyle(name: "mockIssuerName"), + requirement: groupRequirement, + rootOfTrust: RootOfTrust(verified: false, source: nil)) + let injectedIdToken = InjectedIdToken(rawToken: "mockRawToken", pin: nil) + + // Act + issuanceRequestContent.addRequirement(from: injectedIdToken) + + // Assert + XCTAssert(issuanceRequestContent.requirement is GroupRequirement) + XCTAssertEqual((issuanceRequestContent.requirement as? GroupRequirement)?.requirements.count, 2) + XCTAssertEqual((issuanceRequestContent.requirement as? GroupRequirement)?.requirements.first as? MockRequirement, + mockRequirement) + XCTAssertIdentical((issuanceRequestContent.requirement as? GroupRequirement)?.requirements[1] as AnyObject, + idTokenRequirement as AnyObject) + XCTAssertEqual(((issuanceRequestContent.requirement as? GroupRequirement)?.requirements[1] as? IdTokenRequirement)?.idToken, + injectedIdToken.rawToken) + } + + func testAddInjectedIdToken_WithGroupRequirementAndPin_AddsIdTokenAndPinRequirement() async throws { + + // Arrange + let mockRequirement = MockRequirement(id: "mockRequirement") + let idTokenRequirement = createIdTokenRequirement() + let groupRequirement = GroupRequirement(required: false, + requirements: [mockRequirement, idTokenRequirement], + requirementOperator: .ALL) + var issuanceRequestContent = IssuanceRequestContent(style: Manifest2022IssuerStyle(name: "mockIssuerName"), + requirement: groupRequirement, + rootOfTrust: RootOfTrust(verified: false, source: nil)) + let pinRequirement = PinRequirement(required: false, + length: 4, + type: "numeric", + salt: nil) + let injectedIdToken = InjectedIdToken(rawToken: "mockRawToken", pin: pinRequirement) + + // Act + issuanceRequestContent.addRequirement(from: injectedIdToken) + + // Assert + XCTAssert(issuanceRequestContent.requirement is GroupRequirement) + XCTAssertEqual((issuanceRequestContent.requirement as? GroupRequirement)?.requirements.count, 3) + XCTAssertEqual((issuanceRequestContent.requirement as? GroupRequirement)?.requirements.first as? MockRequirement, + mockRequirement) + XCTAssertIdentical((issuanceRequestContent.requirement as? GroupRequirement)?.requirements[1] as AnyObject, + idTokenRequirement as AnyObject) + XCTAssertEqual(((issuanceRequestContent.requirement as? GroupRequirement)?.requirements[1] as? IdTokenRequirement)?.idToken, + injectedIdToken.rawToken) + XCTAssertIdentical((issuanceRequestContent.requirement as? GroupRequirement)?.requirements[2] as AnyObject, + pinRequirement as AnyObject) + } + + private func createIdTokenRequirement(configuration: String = "https://self-issued.me") -> IdTokenRequirement { + return IdTokenRequirement(encrypted: false, + required: false, + configuration: URL(string: configuration)!, + clientId: "mockClientId", + redirectUri: "mockRedirectUri", + scope: nil) + } +} diff --git a/WalletLibrary/WalletLibraryTests/Requests/RequestProtocols/Manifest/ContractIssuanceRequestTests.swift b/WalletLibrary/WalletLibraryTests/Requests/RequestProtocols/Manifest/ContractIssuanceRequestTests.swift index 9f337ccc..958059e8 100644 --- a/WalletLibrary/WalletLibraryTests/Requests/RequestProtocols/Manifest/ContractIssuanceRequestTests.swift +++ b/WalletLibrary/WalletLibraryTests/Requests/RequestProtocols/Manifest/ContractIssuanceRequestTests.swift @@ -25,9 +25,9 @@ class ContractIssuanceRequestTests: XCTestCase { let mockRequirement = MockRequirement(id: "mockRequirement324", mockValidateCallback: { throw ExpectedError.expectedToBeThrown }) - let content = VerifiedIdRequestContent(style: mockStyle, - requirement: mockRequirement, - rootOfTrust: mockRootOfTrust) + let content = IssuanceRequestContent(style: mockStyle, + requirement: mockRequirement, + rootOfTrust: mockRootOfTrust) let contractIssuanceRequest = ContractIssuanceRequest(content: content, issuanceResponseContainer: mockIssuanceResponseContainer, @@ -57,11 +57,11 @@ class ContractIssuanceRequestTests: XCTestCase { let mockRequirement = GroupRequirement(required: true, requirements: [firstValidRequirement, invalidRequirement, secondValidRequirement], requirementOperator: .ALL) - - let content = VerifiedIdRequestContent(style: mockStyle, - requirement: mockRequirement, - rootOfTrust: mockRootOfTrust) + + let content = IssuanceRequestContent(style: mockStyle, + requirement: mockRequirement, + rootOfTrust: mockRootOfTrust) let contractIssuanceRequest = ContractIssuanceRequest(content: content, issuanceResponseContainer: mockIssuanceResponseContainer, @@ -85,11 +85,10 @@ class ContractIssuanceRequestTests: XCTestCase { let mockIssuanceResponseContainer = MockIssuanceResponseContainer() let validRequirement = MockRequirement(id: "mockRequirement324") - - let content = VerifiedIdRequestContent(style: mockStyle, - requirement: validRequirement, - rootOfTrust: mockRootOfTrust) + let content = IssuanceRequestContent(style: mockStyle, + requirement: validRequirement, + rootOfTrust: mockRootOfTrust) let contractIssuanceRequest = ContractIssuanceRequest(content: content, issuanceResponseContainer: mockIssuanceResponseContainer, @@ -118,11 +117,10 @@ class ContractIssuanceRequestTests: XCTestCase { let mockRequirement = GroupRequirement(required: true, requirements: [firstValidRequirement, secondValidRequirement, thirdValidRequirement], requirementOperator: .ALL) - - let content = VerifiedIdRequestContent(style: mockStyle, - requirement: mockRequirement, - rootOfTrust: mockRootOfTrust) + let content = IssuanceRequestContent(style: mockStyle, + requirement: mockRequirement, + rootOfTrust: mockRootOfTrust) let contractIssuanceRequest = ContractIssuanceRequest(content: content, issuanceResponseContainer: mockIssuanceResponseContainer, @@ -151,10 +149,10 @@ class ContractIssuanceRequestTests: XCTestCase { } let mockIssuanceResponseContainer = MockIssuanceResponseContainer(mockAddRequirementCallback: mockAddRequirementCallback) - - let content = VerifiedIdRequestContent(style: mockStyle, - requirement: mockRequirement, - rootOfTrust: mockRootOfTrust) + + let content = IssuanceRequestContent(style: mockStyle, + requirement: mockRequirement, + rootOfTrust: mockRootOfTrust) let contractIssuanceRequest = ContractIssuanceRequest(content: content, issuanceResponseContainer: mockIssuanceResponseContainer, @@ -187,10 +185,10 @@ class ContractIssuanceRequestTests: XCTestCase { } let mockIssuanceResponseContainer = MockIssuanceResponseContainer(mockAddRequirementCallback: mockAddRequirementCallback) - - let content = VerifiedIdRequestContent(style: mockStyle, - requirement: mockRequirement, - rootOfTrust: mockRootOfTrust) + + let content = IssuanceRequestContent(style: mockStyle, + requirement: mockRequirement, + rootOfTrust: mockRootOfTrust) let contractIssuanceRequest = ContractIssuanceRequest(content: content, issuanceResponseContainer: mockIssuanceResponseContainer, diff --git a/WalletLibrary/WalletLibraryTests/Requests/Resolvers/OpenIdURLRequestResolverTests.swift b/WalletLibrary/WalletLibraryTests/Requests/Resolvers/OpenIdURLRequestResolverTests.swift index 9964c84c..0bf5514a 100644 --- a/WalletLibrary/WalletLibraryTests/Requests/Resolvers/OpenIdURLRequestResolverTests.swift +++ b/WalletLibrary/WalletLibraryTests/Requests/Resolvers/OpenIdURLRequestResolverTests.swift @@ -114,6 +114,7 @@ class OpenIdURLRequestResolverTests: XCTestCase { // Arrange let configuration = LibraryConfiguration(logger: WalletLibraryLogger(), mapper: Mapper()) let mockHandler = OpenIdRequestHandler(configuration: configuration, + openIdResponder: MockPresentationResponder(), manifestResolver: MockManifestResolver(), verifiableCredentialRequester: MockVerifiedIdRequester()) let resolver = OpenIdURLRequestResolver(openIdResolver: MockOpenIdForVCResolver(), configuration: configuration)