Skip to content

Commit

Permalink
add defines to test and secitem options test
Browse files Browse the repository at this point in the history
  • Loading branch information
sbSteveK committed Oct 7, 2024
1 parent b2b21d1 commit e6a9506
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,11 @@ packageTargets.append(contentsOf: [
path: "Test/AwsCommonRuntimeKitTests",
resources: [
.process("Resources")
],
cSettings: [
.define("AWS_USE_SECITEM", .when(platforms: [.iOS, .tvOS])),
.define("AWS_USE_DISPATCH_QUEUE", .when(platforms: [.iOS, .tvOS])),
.define("AWS_USE_KQUEUE", .when(platforms: [.macOS]))
]
),
.executableTarget(
Expand Down
17 changes: 17 additions & 0 deletions Test/AwsCommonRuntimeKitTests/io/TLSContextTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,21 @@ class TLSContextTests: XCBaseTestCase {
_ = TLSConnectionOptions(context: context)
}
#endif

#if AWS_USE_SECITEM
func testCreateTlsContextWithSecitemOptions() throws {
let certPath = try getEnvironmentVarOrSkipTest(environmentVarName: "AWS_TEST_MQTT311_IOT_CORE_X509_CERT")
let privateKeyPath = try getEnvironmentVarOrSkipTest(environmentVarName: "AWS_TEST_MQTT311_IOT_CORE_X509_KEY")

let certificateData = try Data(contentsOf: URL(fileURLWithPath: certPath))
let privateKeyData = try Data(contentsOf: URL(fileURLWithPath: privateKeyPath))

let options = try TLSContextOptions.makeMTLS(certificateData: certificateData, privateKeyData: privateKeyData)
try options.setSecitemLabels(certLabel: "TEST_CERT_LABEL", keyLabel: "TEST_KEY_LABEL")

let context = try TLSContext(options:options, mode: .client)
_ = TLSConnectionOptions(context: context)
}

#endif
}

0 comments on commit e6a9506

Please sign in to comment.