From b58747ed0875070a61ed90b4cd64559be99f6928 Mon Sep 17 00:00:00 2001 From: dtsiflit Date: Tue, 16 Jul 2024 11:37:13 +0300 Subject: [PATCH] [fix] deferred issuer fixes --- .../CredentialIssuerMetadata.swift | 4 ++-- Sources/Issuers/Issuer.swift | 12 ++++++++++-- Sources/Utilities/Constants.swift | 2 ++ Tests/Issue/IssuanceFlowsTest.swift | 15 +++++++++++++-- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/Sources/Entities/CredentialIssuer/CredentialIssuerMetadata.swift b/Sources/Entities/CredentialIssuer/CredentialIssuerMetadata.swift index f19ce2e..d8bd604 100644 --- a/Sources/Entities/CredentialIssuer/CredentialIssuerMetadata.swift +++ b/Sources/Entities/CredentialIssuer/CredentialIssuerMetadata.swift @@ -79,9 +79,9 @@ public struct CredentialIssuerMetadata: Decodable, Equatable { public init(deferredCredentialEndpoint: CredentialIssuerEndpoint?) throws { try self.init( - credentialIssuerIdentifier: .init(""), + credentialIssuerIdentifier: .init(Constants.url), authorizationServers: [], - credentialEndpoint: .init(string: ""), + credentialEndpoint: .init(string: Constants.url), batchCredentialEndpoint: nil, deferredCredentialEndpoint: deferredCredentialEndpoint, notificationEndpoint: nil, diff --git a/Sources/Issuers/Issuer.swift b/Sources/Issuers/Issuer.swift index 1c7859c..45ea59f 100644 --- a/Sources/Issuers/Issuer.swift +++ b/Sources/Issuers/Issuer.swift @@ -716,8 +716,16 @@ public extension Issuer { config: OpenId4VCIConfig ) throws -> Issuer { try Issuer( - authorizationServerMetadata: .oauth(.init()), - issuerMetadata: .init(deferredCredentialEndpoint: deferredCredentialEndpoint), + authorizationServerMetadata: .oauth( + .init( + authorizationEndpoint: Constants.url, + tokenEndpoint: Constants.url, + pushedAuthorizationRequestEndpoint: Constants.url + ) + ), + issuerMetadata: .init( + deferredCredentialEndpoint: deferredCredentialEndpoint + ), config: config, deferredRequesterPoster: deferredRequesterPoster ) diff --git a/Sources/Utilities/Constants.swift b/Sources/Utilities/Constants.swift index 918194b..c258350 100644 --- a/Sources/Utilities/Constants.swift +++ b/Sources/Utilities/Constants.swift @@ -29,4 +29,6 @@ public struct Constants { public static let OPENID_SCOPE = "openid" public static let TX_CODE_PARAM = "tx_code" + + public static let url = "https://a.bc" } diff --git a/Tests/Issue/IssuanceFlowsTest.swift b/Tests/Issue/IssuanceFlowsTest.swift index dbc9d92..f90e93c 100644 --- a/Tests/Issue/IssuanceFlowsTest.swift +++ b/Tests/Issue/IssuanceFlowsTest.swift @@ -28,7 +28,18 @@ class IssuanceFlowsTest: XCTestCase { super.tearDown() } - func test() throws { - + func testDeferredIssuerConstruction() async throws { + + let issuer = try Issuer.createDeferredIssuer( + deferredCredentialEndpoint: .init(string: "https://www.example.com"), + deferredRequesterPoster: Poster(), + config: .init( + clientId: .init(), + authFlowRedirectionURI: URL(string: "https://www.example.com")! + ) + ) + + let endPoint = await issuer.issuerMetadata.deferredCredentialEndpoint!.url.absoluteString + XCTAssertEqual(endPoint, "https://www.example.com") } }