diff --git a/.github/README.adoc b/.github/README.adoc index 8e4560d..8baabc1 100644 --- a/.github/README.adoc +++ b/.github/README.adoc @@ -24,7 +24,14 @@ This document describes the functionalitiy and structure of OpenHealthCardKit. == API Documentation -Generated API docs are available at https://gematik.github.io/ref-OpenHealthCardKit. +Generated API docs are available at https://swiftpackageindex.com/gematik/ref-OpenHealthCardKit[Swift Package Index]: + +* HealthCardControl (tbd) +* https://swiftpackageindex.com/gematik/ref-OpenHealthCardKit/main/documentation/healthcardaccess[HealthCardAccess] +* https://swiftpackageindex.com/gematik/ref-OpenHealthCardKit/main/documentation/nfccardreaderprovider[NFCCardReaderProvider] +* https://swiftpackageindex.com/gematik/ref-OpenHealthCardKit/main/documentation/cardreaderproviderapi[CardReaderProviderApi] + +NOTE: As of now the automatic API doc generation for `HealthCardControl` is broken. It's possible to generate it manually via Xcode: Select the target `HealthCardControl` and select `Product -> Build Documentation`. == Getting Started @@ -184,19 +191,20 @@ convenience publisher is useful. [source,swift] ---- -readCertificate +_ = readCertificate .sink( receiveCompletion: { completion in switch completion { case .finished: - DLog("Completed") + Logger.integrationTest.debug("Completed") case let .failure(error): - DLog("Error: \(error)") + Logger.integrationTest.debug("Error: \(error)") } }, receiveValue: { healthCardResponse in - DLog("Got a certifcate") + Logger.integrationTest.debug("Got a certifcate") let certificate = healthCardResponse.data! + Logger.integrationTest.debug("Certificate: \(certificate.hexString())") // proceed with certificate data here // use swiftUI to a show success message on screen etc. } @@ -237,7 +245,7 @@ steps for establishing a secure channel with the Health Card and expose only a s [source,swift] ---- -let secureMessaging = try await KeyAgreement.Algorithm.idPaceEcdhGmAesCbcCmac128.negotiateSessionKey( +let secureMessaging = try await KeyAgreement.Algorithm.idPaceEcdhGmAesCbcCmac128.negotiateSessionKeyAsync( card: CardSimulationTerminalTestCase.healthCard, can: can, writeTimeout: 0, diff --git a/CardSimulationTestKit/Sources/CardSimulationCardReaderProvider/Card/SimulatorCardChannel.swift b/CardSimulationTestKit/Sources/CardSimulationCardReaderProvider/Card/SimulatorCardChannel.swift index ad88570..17bcb6d 100644 --- a/CardSimulationTestKit/Sources/CardSimulationCardReaderProvider/Card/SimulatorCardChannel.swift +++ b/CardSimulationTestKit/Sources/CardSimulationCardReaderProvider/Card/SimulatorCardChannel.swift @@ -100,8 +100,8 @@ public class SimulatorCardChannel: CardChannelType { let message = try command.bytes.berTlvEncoded() Logger.cardSimulationCardReaderProvider .debug("SEND: \(message.map { String(format: "%02hhX", $0) }.joined())") - _ = message.withUnsafeBytes { - outputStream.write($0, maxLength: message.count) + _ = message.withUnsafeBytes { (ptr: UnsafeRawBufferPointer) in + outputStream.write(ptr, maxLength: message.count) } var buffer = [UInt8](repeating: 0x0, count: maxResponseLength) diff --git a/CardSimulationTestKit/Sources/CardSimulationCardReaderProvider/internal/OutputStreaming.swift b/CardSimulationTestKit/Sources/CardSimulationCardReaderProvider/internal/OutputStreaming.swift index 327d70b..0484abc 100644 --- a/CardSimulationTestKit/Sources/CardSimulationCardReaderProvider/internal/OutputStreaming.swift +++ b/CardSimulationTestKit/Sources/CardSimulationCardReaderProvider/internal/OutputStreaming.swift @@ -19,5 +19,5 @@ import Foundation protocol OutputStreaming { var hasSpaceAvailable: Bool { get } - func write(_ buffer: UnsafePointer, maxLength len: Int) -> Int + func write(_ buffer: UnsafeRawBufferPointer, maxLength len: Int) -> Int } diff --git a/CardSimulationTestKit/Sources/CardSimulationCardReaderProvider/internal/TCPClient+Streaming.swift b/CardSimulationTestKit/Sources/CardSimulationCardReaderProvider/internal/TCPClient+Streaming.swift index 92a04b6..48cfdb2 100644 --- a/CardSimulationTestKit/Sources/CardSimulationCardReaderProvider/internal/TCPClient+Streaming.swift +++ b/CardSimulationTestKit/Sources/CardSimulationCardReaderProvider/internal/TCPClient+Streaming.swift @@ -36,7 +36,7 @@ extension TCPClient: TCPClientType { Logger.cardSimulationCardReaderProvider.fault("Read error") return -1 } - buffer.assign(from: bytes, count: bytes.count) + buffer.update(from: bytes, count: bytes.count) return bytes.count } @@ -44,8 +44,10 @@ extension TCPClient: TCPClientType { fd != nil } - func write(_ buffer: UnsafePointer, maxLength len: Int) -> Int { - let data = Data(bytes: buffer, count: len) + func write(_ buffer: UnsafeRawBufferPointer, maxLength len: Int) -> Int { + // swiftlint:disable:next force_unwrapping + let rawPtr = buffer.baseAddress! + let data = Data(bytes: rawPtr, count: len) switch send(data: data) { case .failure: return -1 case .success: return data.count diff --git a/CardSimulationTestKit/Tests/CardSimulationCardReaderProviderTests/Card/SimulatorCardChannelTest.swift b/CardSimulationTestKit/Tests/CardSimulationCardReaderProviderTests/Card/SimulatorCardChannelTest.swift index 124a792..ddb55e4 100644 --- a/CardSimulationTestKit/Tests/CardSimulationCardReaderProviderTests/Card/SimulatorCardChannelTest.swift +++ b/CardSimulationTestKit/Tests/CardSimulationCardReaderProviderTests/Card/SimulatorCardChannelTest.swift @@ -68,8 +68,10 @@ final class SimulatorCardChannelTest: XCTestCase { } let count = Swift.min(bytes.count, len) - bytes.withUnsafeBytes { - buffer.assign(from: $0, count: count) + bytes.withUnsafeBytes { (ptr: UnsafeRawBufferPointer) in + // swiftlint:disable:next force_unwrapping + let rawPtr = ptr.baseAddress!.assumingMemoryBound(to: UInt8.self) + buffer.update(from: rawPtr, count: count) } availableBytes?.removeFirst(count) return count @@ -79,8 +81,10 @@ final class SimulatorCardChannelTest: XCTestCase { !closedOutputStream } - func write(_ buffer: UnsafePointer, maxLength len: Int) -> Int { - let data = Data(bytes: buffer, count: len) + func write(_ buffer: UnsafeRawBufferPointer, maxLength len: Int) -> Int { + // swiftlint:disable:next force_unwrapping + let rawPtr = buffer.baseAddress! + let data = Data(bytes: rawPtr, count: len) bytesWritten.append(data) return data.count } diff --git a/IntegrationTests/HealthCardAccess/PublisherIntegrationTest.swift b/IntegrationTests/HealthCardAccess/PublisherIntegrationTest.swift index 45ddd20..c6775d9 100644 --- a/IntegrationTests/HealthCardAccess/PublisherIntegrationTest.swift +++ b/IntegrationTests/HealthCardAccess/PublisherIntegrationTest.swift @@ -104,7 +104,7 @@ final class PublisherIntegrationTest: CardSimulationTerminalTestCase { // end::createCommandSequence[] // tag::processExecutionResult[] - readCertificate + _ = readCertificate .sink( receiveCompletion: { completion in switch completion { @@ -117,6 +117,7 @@ final class PublisherIntegrationTest: CardSimulationTerminalTestCase { receiveValue: { healthCardResponse in Logger.integrationTest.debug("Got a certifcate") let certificate = healthCardResponse.data! + Logger.integrationTest.debug("Certificate: \(certificate.hexString())") // proceed with certificate data here // use swiftUI to a show success message on screen etc. } diff --git a/IntegrationTests/HealthCardControl/KeyAgreementIntegrationTest.swift b/IntegrationTests/HealthCardControl/KeyAgreementIntegrationTest.swift index f291e3a..aa59aee 100644 --- a/IntegrationTests/HealthCardControl/KeyAgreementIntegrationTest.swift +++ b/IntegrationTests/HealthCardControl/KeyAgreementIntegrationTest.swift @@ -43,7 +43,7 @@ final class KeyAgreementIntegrationTest: CardSimulationTerminalTestCase { func testNegotiatePaceEcdhGmAesCbcCmac128() async throws { let can = try! CAN.from(Data("123123".utf8)) // swiftlint:disable:this force_try // tag::negotiateSessionKey[] - let secureMessaging = try await KeyAgreement.Algorithm.idPaceEcdhGmAesCbcCmac128.negotiateSessionKey( + let secureMessaging = try await KeyAgreement.Algorithm.idPaceEcdhGmAesCbcCmac128.negotiateSessionKeyAsync( card: CardSimulationTerminalTestCase.healthCard, can: can, writeTimeout: 0, diff --git a/ReleaseNotes.md b/ReleaseNotes.md index cde7c5a..64e07fa 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -1,14 +1,8 @@ # 5.10.0 -## Added - -- Add public initializer for HealthCardResponse -- Add public initializer for AutCertificateResponse - -## Removed - -- Remove dependency on GemCommonsKit -- Remove dependency on DataKit +- Add public initializers for `HealthCardResponse` and `AutCertificateResponse` +- Remove dependency on `GemCommonsKit` +- Remove dependency on `DataKit` # 5.9.0 diff --git a/Sources/NFCDemo/Resources/Info.plist b/Sources/NFCDemo/Resources/Info.plist index 26f2d26..fddffd4 100644 --- a/Sources/NFCDemo/Resources/Info.plist +++ b/Sources/NFCDemo/Resources/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType $(PRODUCT_BUNDLE_PACKAGE_TYPE) CFBundleShortVersionString - 1.2.7 + 1.2.8 CFBundleVersion $(GEMATIK_BUNDLE_VERSION) GEMATIKSourceVersion diff --git a/Tests/NFCDemoTests/ReadingResultsViewSnapshotTests.swift b/Tests/NFCDemoTests/ReadingResultsViewSnapshotTests.swift index 229c10b..f860c4b 100644 --- a/Tests/NFCDemoTests/ReadingResultsViewSnapshotTests.swift +++ b/Tests/NFCDemoTests/ReadingResultsViewSnapshotTests.swift @@ -22,12 +22,6 @@ import XCTest // swiftlint:disable force_unwrapping class ReadingResultsViewSnapshotTests: XCTestCase { - override func setUp() { - super.setUp() - - diffTool = "open" - } - func testReadingResultsViewSnapshotTests() throws { let sut = NavigationView { ReadingResultsView( @@ -49,7 +43,7 @@ class ReadingResultsViewSnapshotTests: XCTestCase { ) } .frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height) - assertSnapshots(matching: sut, as: snapshotModi()) + assertSnapshots(of: sut, as: snapshotModi()) } func testReadingResultsDetailViewSnapshotTests() throws { @@ -72,7 +66,7 @@ class ReadingResultsViewSnapshotTests: XCTestCase { ) } .frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height) - assertSnapshots(matching: sut, as: snapshotModi()) + assertSnapshots(of: sut, as: snapshotModi()) } } diff --git a/Tests/NFCDemoTests/RegisterCANViewSnapshotTests.swift b/Tests/NFCDemoTests/RegisterCANViewSnapshotTests.swift index bf8fad3..31d0c69 100644 --- a/Tests/NFCDemoTests/RegisterCANViewSnapshotTests.swift +++ b/Tests/NFCDemoTests/RegisterCANViewSnapshotTests.swift @@ -20,15 +20,9 @@ import SwiftUI import XCTest class RegisterCANViewSnapshotTests: XCTestCase { - override func setUp() { - super.setUp() - - diffTool = "open" - } - func testRegisterCANViewSnapshotTests() throws { let sut = RegisterCANView() .frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height) - assertSnapshots(matching: sut, as: snapshotModi()) + assertSnapshots(of: sut, as: snapshotModi()) } } diff --git a/Tests/NFCDemoTests/RegisterPINViewSnapshotTests.swift b/Tests/NFCDemoTests/RegisterPINViewSnapshotTests.swift index 4eb0b6a..93c2623 100644 --- a/Tests/NFCDemoTests/RegisterPINViewSnapshotTests.swift +++ b/Tests/NFCDemoTests/RegisterPINViewSnapshotTests.swift @@ -20,15 +20,9 @@ import SwiftUI import XCTest class RegisterPINViewSnapshotTests: XCTestCase { - override func setUp() { - super.setUp() - - diffTool = "open" - } - func testRegisterPINViewSnapshotTests() throws { let sut = NavigationView { RegisterPINView(can: "123456") } .frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height) - assertSnapshots(matching: sut, as: snapshotModi()) + assertSnapshots(of: sut, as: snapshotModi()) } } diff --git a/Tests/NFCDemoTests/StartNFCViewSnapshotTests.swift b/Tests/NFCDemoTests/StartNFCViewSnapshotTests.swift index e30caa9..c934d81 100644 --- a/Tests/NFCDemoTests/StartNFCViewSnapshotTests.swift +++ b/Tests/NFCDemoTests/StartNFCViewSnapshotTests.swift @@ -20,17 +20,11 @@ import SwiftUI import XCTest class StartNFCViewSnapshotTests: XCTestCase { - override func setUp() { - super.setUp() - - diffTool = "open" - } - func testStartNFCViewSnapshotTests() throws { let sut = NavigationView { StartNFCView(can: "123456", puk: "12345678", oldPin: "123456", pin: "654321", useCase: .login) } .frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height) - assertSnapshots(matching: sut, as: snapshotModi()) + assertSnapshots(of: sut, as: snapshotModi()) } } diff --git a/doc/userguide/OHCKIT_API.adoc b/doc/userguide/OHCKIT_API.adoc index d076035..c751388 100644 --- a/doc/userguide/OHCKIT_API.adoc +++ b/doc/userguide/OHCKIT_API.adoc @@ -1,3 +1,10 @@ == API Documentation -Generated API docs are available at https://gematik.github.io/ref-OpenHealthCardKit. +Generated API docs are available at https://swiftpackageindex.com/gematik/ref-OpenHealthCardKit[Swift Package Index]: + +* HealthCardControl (tbd) +* https://swiftpackageindex.com/gematik/ref-OpenHealthCardKit/main/documentation/healthcardaccess[HealthCardAccess] +* https://swiftpackageindex.com/gematik/ref-OpenHealthCardKit/main/documentation/nfccardreaderprovider[NFCCardReaderProvider] +* https://swiftpackageindex.com/gematik/ref-OpenHealthCardKit/main/documentation/cardreaderproviderapi[CardReaderProviderApi] + +NOTE: As of now the automatic API doc generation for `HealthCardControl` is broken. It's possible to generate it manually via Xcode: Select the target `HealthCardControl` and select `Product -> Build Documentation`.