Skip to content

Commit

Permalink
Release 5.10.0 (#32)
Browse files Browse the repository at this point in the history
- fix some warnings
  • Loading branch information
sigabrtz authored Aug 20, 2024
1 parent a61b610 commit ffbe9cd
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 58 deletions.
20 changes: 14 additions & 6 deletions .github/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
}
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ import Foundation
protocol OutputStreaming {
var hasSpaceAvailable: Bool { get }

func write(_ buffer: UnsafePointer<UInt8>, maxLength len: Int) -> Int
func write(_ buffer: UnsafeRawBufferPointer, maxLength len: Int) -> Int
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,18 @@ 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
}

var hasSpaceAvailable: Bool {
fd != nil
}

func write(_ buffer: UnsafePointer<UInt8>, 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -79,8 +81,10 @@ final class SimulatorCardChannelTest: XCTestCase {
!closedOutputStream
}

func write(_ buffer: UnsafePointer<UInt8>, 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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ final class PublisherIntegrationTest: CardSimulationTerminalTestCase {
// end::createCommandSequence[]

// tag::processExecutionResult[]
readCertificate
_ = readCertificate
.sink(
receiveCompletion: { completion in
switch completion {
Expand All @@ -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.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 3 additions & 9 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion Sources/NFCDemo/Resources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.2.7</string>
<string>1.2.8</string>
<key>CFBundleVersion</key>
<string>$(GEMATIK_BUNDLE_VERSION)</string>
<key>GEMATIKSourceVersion</key>
Expand Down
10 changes: 2 additions & 8 deletions Tests/NFCDemoTests/ReadingResultsViewSnapshotTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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 {
Expand All @@ -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())
}
}

Expand Down
8 changes: 1 addition & 7 deletions Tests/NFCDemoTests/RegisterCANViewSnapshotTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}
8 changes: 1 addition & 7 deletions Tests/NFCDemoTests/RegisterPINViewSnapshotTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}
8 changes: 1 addition & 7 deletions Tests/NFCDemoTests/StartNFCViewSnapshotTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}
9 changes: 8 additions & 1 deletion doc/userguide/OHCKIT_API.adoc
Original file line number Diff line number Diff line change
@@ -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`.

0 comments on commit ffbe9cd

Please sign in to comment.