diff --git a/AtalaPrismSDK/Pluto/Tests/CDDIDPrivateKeyDAOTests.swift b/AtalaPrismSDK/Pluto/Tests/CDDIDPrivateKeyDAOTests.swift index d6436a1e..a94fb046 100644 --- a/AtalaPrismSDK/Pluto/Tests/CDDIDPrivateKeyDAOTests.swift +++ b/AtalaPrismSDK/Pluto/Tests/CDDIDPrivateKeyDAOTests.swift @@ -32,7 +32,7 @@ final class CDDIDPrivateKeyDAOTestsTests: XCTestCase { alias: nil ).flatMap { dao.getDIDInfo(did: testDID) - }.sink { _ in } receiveValue: { + }.first().sink { _ in } receiveValue: { XCTAssertEqual(testDID, $0?.did) XCTAssertEqual([testPrivateKey], $0?.privateKeys.map { $0 as? MockPrivateKey }) expectation.fulfill() @@ -64,7 +64,9 @@ final class CDDIDPrivateKeyDAOTestsTests: XCTestCase { } .flatMap { dao.getAll() - }.sink { _ in } receiveValue: { + } + .first() + .sink { _ in } receiveValue: { XCTAssertEqual($0.count, 1) expectation.fulfill() } @@ -99,7 +101,9 @@ final class CDDIDPrivateKeyDAOTestsTests: XCTestCase { } .flatMap { dao.getAll() - }.sink { _ in } receiveValue: { + } + .first() + .sink { _ in } receiveValue: { XCTAssertEqual($0.count, 2) expectation.fulfill() } @@ -134,7 +138,9 @@ final class CDDIDPrivateKeyDAOTestsTests: XCTestCase { } .flatMap { dao.getDIDInfo(did: testDID2) - }.sink { _ in } receiveValue: { + } + .first() + .sink { _ in } receiveValue: { XCTAssertEqual(testDID2, $0?.did) XCTAssertEqual([testPrivateKey2], $0?.privateKeys.map { $0 as? MockPrivateKey }) expectation.fulfill() diff --git a/AtalaPrismSDK/PrismAgent/Sources/Protocols/Pickup/PickupRunner.swift b/AtalaPrismSDK/PrismAgent/Sources/Protocols/Pickup/PickupRunner.swift index cd09c294..b209c60c 100644 --- a/AtalaPrismSDK/PrismAgent/Sources/Protocols/Pickup/PickupRunner.swift +++ b/AtalaPrismSDK/PrismAgent/Sources/Protocols/Pickup/PickupRunner.swift @@ -31,7 +31,11 @@ class PickupRunner { return try await message.attachments.compactMap { attachment in switch attachment.data { case let base64 as AttachmentBase64: - return (base64.base64, attachment.id) + guard + let base64Data = Data(base64URLEncoded: base64.base64), + let base64String = String(data: base64Data, encoding: .utf8) + else { return nil } + return (base64String, attachment.id) case let json as AttachmentJsonData: return String(data: json.data, encoding: .utf8).map { ($0, attachment.id) } default: diff --git a/AtalaPrismSDK/PrismAgent/Tests/PickupRunnerTests.swift b/AtalaPrismSDK/PrismAgent/Tests/PickupRunnerTests.swift index 115faea4..32f536f9 100644 --- a/AtalaPrismSDK/PrismAgent/Tests/PickupRunnerTests.swift +++ b/AtalaPrismSDK/PrismAgent/Tests/PickupRunnerTests.swift @@ -1,3 +1,4 @@ +import Core @testable import Domain @testable import PrismAgent import XCTest @@ -19,7 +20,11 @@ final class PickupRunnerTests: XCTestCase { func testWhenReceiveDeliveryMessageThenParseMessages() async throws { attachments = try await messagesExamples.asyncMap { - AttachmentBase64(base64: try await mercury.packMessage(msg: $0)) + try await mercury.packMessage(msg: $0).data(using: .utf8)?.base64UrlEncodedString() + } + .compactMap { $0 } + .map { + AttachmentBase64(base64: $0) } let message = Message( piuri: ProtocolTypes.pickupDelivery.rawValue, @@ -36,7 +41,11 @@ final class PickupRunnerTests: XCTestCase { func testWhenReceiveNotDeliveryMessageThenThrowError() async throws { attachments = try await messagesExamples.asyncMap { - AttachmentBase64(base64: try await mercury.packMessage(msg: $0)) + try await mercury.packMessage(msg: $0).data(using: .utf8)?.base64UrlEncodedString() + } + .compactMap { $0 } + .map { + AttachmentBase64(base64: $0) } let message = Message( piuri: "SomethingElse", diff --git a/Package.swift b/Package.swift index bddea570..f6968eab 100644 --- a/Package.swift +++ b/Package.swift @@ -178,7 +178,7 @@ let package = Package( ), .testTarget( name: "PrismAgentTests", - dependencies: ["PrismAgent"], + dependencies: ["PrismAgent", "Core"], path: "AtalaPrismSDK/PrismAgent/Tests" ), .target(