Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cognito credential provider support #306

Open
wants to merge 112 commits into
base: iot
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
554c9b5
update crt error
xiazhvera Jun 11, 2024
e377204
fix lint
xiazhvera Jun 11, 2024
fdcc698
update error validation
xiazhvera Jun 12, 2024
17022d6
Merge branch 'iot' of https://github.com/awslabs/aws-crt-swift into m…
xiazhvera Jun 12, 2024
312ed71
add swift error space
xiazhvera Jun 19, 2024
c6fb2d1
fix lint
xiazhvera Jun 19, 2024
24e4c21
add ios mqtt sample
xiazhvera Jun 19, 2024
abec93c
update readme
xiazhvera Jun 19, 2024
6a67040
fix lint
xiazhvera Jun 19, 2024
0bd46b9
clean up app
xiazhvera Jun 19, 2024
7d6a6cb
move samples -> test
xiazhvera Jun 24, 2024
5c2dbd3
move project data
xiazhvera Jun 24, 2024
1607745
fix readme and .gitignore
xiazhvera Jul 3, 2024
425260a
Merge branch 'iot' of https://github.com/awslabs/aws-crt-swift into m…
xiazhvera Jul 18, 2024
c0e4aa6
fix merge
xiazhvera Jul 19, 2024
d6a8a13
Merge branch 'iot' into mqtt_test_app
sbSteveK Oct 1, 2024
aad4d76
allow tls
sbSteveK Oct 1, 2024
e7e603d
fix logging in test app due to main merge changes
sbSteveK Oct 1, 2024
8a7f52a
Merge branch 'mqtt_test_app' into secitem_bindings
sbSteveK Oct 1, 2024
f248f53
add setting of secitem options
sbSteveK Oct 2, 2024
0406905
aws-c-io nw_secitem branch
sbSteveK Oct 2, 2024
d261d8a
latest aws-c-io nw_secitem
sbSteveK Oct 2, 2024
08308e8
update aws-c-io
sbSteveK Oct 2, 2024
54ff235
use AWS_USE_SECITEM define
sbSteveK Oct 2, 2024
e19519a
add eventloop types to other platforms
sbSteveK Oct 2, 2024
b338b5d
lint error and differetiate between macOS and iOS/tvOS
sbSteveK Oct 2, 2024
9c2ba7f
add missing endif
sbSteveK Oct 2, 2024
827c071
try excluding dispatch queue related source files
sbSteveK Oct 2, 2024
e0dfcad
CRT changes
sbSteveK Oct 3, 2024
b507465
aws-c-io changes
sbSteveK Oct 3, 2024
a50380c
update aws-c-io changes
sbSteveK Oct 3, 2024
fb1b501
remove test error
sbSteveK Oct 3, 2024
1f3cee0
latest submodules
sbSteveK Oct 3, 2024
81946d3
update aws-c-io
sbSteveK Oct 4, 2024
78e5ac9
use latest aws-c-io
sbSteveK Oct 4, 2024
b9a6ed2
add defines in package.Swift
sbSteveK Oct 4, 2024
b2b21d1
latest aws-c-io
sbSteveK Oct 7, 2024
e6a9506
add defines to test and secitem options test
sbSteveK Oct 7, 2024
610e716
defines for swift test target
sbSteveK Oct 7, 2024
06451a0
add defines to tests in swift
sbSteveK Oct 7, 2024
9b177d2
remove watchOS testing
sbSteveK Oct 7, 2024
97ed422
pull latest aws-c-io changes
sbSteveK Oct 7, 2024
9a50b8d
update aws-c-io again
sbSteveK Oct 7, 2024
5e5bf33
update aws-c-io
sbSteveK Oct 16, 2024
599ce74
Merge branch 'iot' into mqtt_test_app
sbSteveK Oct 31, 2024
0960792
merge latest main
sbSteveK Oct 31, 2024
52a458a
latest wip aws-c-io
sbSteveK Nov 5, 2024
e80b8a4
pull latest changes
sbSteveK Nov 5, 2024
2af72b8
update aws-c-io
sbSteveK Nov 6, 2024
aac5d89
updated submodules
sbSteveK Nov 8, 2024
1baa40b
update submodule
sbSteveK Nov 8, 2024
986c937
pull in latest changes from merged nw_socket
sbSteveK Nov 13, 2024
6e34fc8
latest aws-c-io
sbSteveK Nov 13, 2024
9a55e43
make HostResolver init public
sbSteveK Nov 13, 2024
468d6d6
update HostResolver to make init public
sbSteveK Dec 2, 2024
7e54f81
Merge branch 'iot' into mqtt_test_app
sbSteveK Dec 3, 2024
4539fa3
Merge branch 'iot' into mqtt_test_app
sbSteveK Dec 5, 2024
6c5da21
Merge branch 'mqtt_test_app' into secitem_bindings
sbSteveK Dec 5, 2024
b3be803
add cognito credential provider support
xiazhvera Dec 23, 2024
e9d3149
Merge branch 'iot' of https://github.com/awslabs/aws-crt-swift into s…
xiazhvera Dec 23, 2024
70e4dd6
Merge branch 'secitem_bindings' of https://github.com/awslabs/aws-crt…
xiazhvera Dec 23, 2024
732e885
fix test name
xiazhvera Dec 23, 2024
af00a88
fix shutdown flag
xiazhvera Dec 23, 2024
3e17395
skip the test if env is not set
xiazhvera Dec 24, 2024
d4c6b07
swift lint format
xiazhvera Dec 24, 2024
cddd848
test with new env var
xiazhvera Dec 31, 2024
3ac6ec0
set use xcodebuild
xiazhvera Dec 31, 2024
5b3d2a5
remove cognito test
xiazhvera Dec 31, 2024
5eb25e9
waiting for shutdown credential provider
xiazhvera Dec 31, 2024
eb57164
add scope to make sure the provider released
xiazhvera Dec 31, 2024
d982864
setup ci for xcodebuild
xiazhvera Dec 31, 2024
3b3ded9
Merge branch 'iot_ci_env_var' of https://github.com/awslabs/aws-crt-s…
xiazhvera Dec 31, 2024
95487a4
[WIP]cognito test
xiazhvera Dec 31, 2024
59ac4e4
WIP remove test vars
xiazhvera Dec 31, 2024
4b84fcb
add cognito connecton test
xiazhvera Jan 6, 2025
1895e9a
fix spacing...
xiazhvera Jan 6, 2025
e7612ba
change aws-c-io to nw_secitem_latest_socket
sbSteveK Jan 8, 2025
c66b36d
update aws-c-io
sbSteveK Jan 8, 2025
137ebf0
Separate trust store override into 2 new funcs that take one or the o…
sbSteveK Jan 16, 2025
bd5e186
Add data CA override func
sbSteveK Jan 16, 2025
7771fae
Merge branch 'secitem_bindings' of https://github.com/awslabs/aws-crt…
xiazhvera Mar 3, 2025
7a63d6b
latest submodules and nw_secitem branch of aws-c-io
sbSteveK Mar 6, 2025
2bf67e4
Merge branch 'secitem_bindings' of https://github.com/awslabs/aws-crt…
xiazhvera Mar 6, 2025
1a5b8ed
merge with latest iot
sbSteveK Mar 6, 2025
2632913
latest submodules
sbSteveK Mar 6, 2025
7899729
Merge branch 'secitem_bindings' of https://github.com/awslabs/aws-crt…
xiazhvera Mar 6, 2025
61931eb
revert aws-c-cal to the one being used in main
sbSteveK Mar 6, 2025
62c87aa
Merge branch 'secitem_bindings' of https://github.com/awslabs/aws-crt…
xiazhvera Mar 6, 2025
2986c96
remove test sample app
sbSteveK Mar 6, 2025
cd00d31
Merge branch 'secitem_bindings' of https://github.com/awslabs/aws-crt…
xiazhvera Mar 6, 2025
65cffef
WIP: enable tests on ios and tvos, update cognito credential provider
xiazhvera Mar 7, 2025
35957bc
fulfill the shutdown callback on failed tests
xiazhvera Mar 7, 2025
e2b816a
revert and disable secitem test
xiazhvera Mar 11, 2025
ff5a4de
test against nw_secitem_test
xiazhvera Mar 11, 2025
52a2cc2
fix secitem compile error
xiazhvera Mar 11, 2025
0e39690
test extend the timeout
xiazhvera Mar 11, 2025
2005830
TEST: enable trace log for ios 13
xiazhvera Mar 12, 2025
60bccb8
TEST: more prints
xiazhvera Mar 12, 2025
5052f42
fix spacing
xiazhvera Mar 12, 2025
1cc8aa8
revert spacing with cognito tests
xiazhvera Mar 12, 2025
c641970
more prints
xiazhvera Mar 12, 2025
876b095
update base socket & log level set to error
xiazhvera Mar 12, 2025
8df642b
fix aws-c-io
xiazhvera Mar 12, 2025
95fda11
more prints and nul out the websocket transform?
xiazhvera Mar 13, 2025
76473c6
extend the connection aiting time for ios13
xiazhvera Mar 13, 2025
da595de
Merge branch 'iot' of https://github.com/awslabs/aws-crt-swift into c…
xiazhvera Mar 17, 2025
7f65a04
cleanup
xiazhvera Mar 17, 2025
7ea75fd
remove macos-13 with ios
xiazhvera Mar 17, 2025
5b0866b
remove macos-13 with ios
xiazhvera Mar 17, 2025
6f7479a
remove macos-13 with ios
xiazhvera Mar 17, 2025
327d133
update aws-c-io to nw_secitem
xiazhvera Mar 18, 2025
75e130d
update test timeout time
xiazhvera Mar 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .builder/actions/crt-ci-prep-xcodebuild.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Builder

class CrtCiPrepXCodebuild(Builder.Action):
Copy link
Contributor

@waahm7 waahm7 Jan 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't looked at the PR but can we avoid adding this action in crt-swift? We don't need to test the Cognito credential provider functionality in bindings; we can just create/destroy it for simple binding tests. The MQTT-specific tests should be in the IoT SDK.

This action makes it harder to run these tests locally. I think we will likely need this action for MQTT unit tests but we should try to avoid it if possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This script change is used to allow passing environment variables into xcodebuild tests. Regardless of the Cognito credential provider changes, we still need it for the unit tests that requires environment variables.

def run(self, env):
env.shell.setenv("TEST_RUNNER_AWS_TESTING_STS_ROLE_ARN", env.shell.get_secret("aws-c-auth-testing/sts-role-arn"))
actions = [
Builder.SetupCrossCICrtEnvironment(use_xcodebuild=True)
]
return Builder.Script(actions, name='crt-ci-prep-xcodebuild')
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ on:
- 'main'

env:
BUILDER_VERSION: v0.9.73
BUILDER_SOURCE: releases
BUILDER_VERSION: xcodebuild_setup
BUILDER_SOURCE: channels
BUILDER_HOST: https://d19elf31gohf1l.cloudfront.net
PACKAGE_NAME: aws-crt-swift
RUN: ${{ github.run_id }}-${{ github.run_number }}
Expand Down Expand Up @@ -100,6 +100,10 @@ jobs:
xcode: Xcode_15.2
- runner: macos-13
xcode: Xcode_15.2
- runner: macos-13-xlarge
target: { os: ios, destination: 'iOS Simulator,OS=16.1,name=iPhone 14'}
- runner: macos-13
target: { os: ios, destination: 'iOS Simulator,OS=16.1,name=iPhone 14'}
# Don't run new macOS with old Xcode
- runner: macos-14-large
xcode: Xcode_14.1
Expand Down
1 change: 0 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ packageTargets.append(.target(
.define("S2N_BUILD_RELEASE"),
.define("_FORTIFY_SOURCE", to: "2"),
.define("POSIX_C_SOURCE", to: "200809L"),

]
))
#endif
Expand Down
122 changes: 122 additions & 0 deletions Source/AwsCommonRuntimeKit/auth/credentials/CredentialsProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,68 @@ public protocol CredentialsProviding {
func getCredentials() async throws -> Credentials
}

/// A pair defining an identity provider and a valid login token sourced from it.
public struct CognitoLoginPair: CStruct {
public var IdentityProviderName: String
public var IdentityProviderToken: String

public init(identityProviderName: String,
identityProviderToken: String) {
self.IdentityProviderName = identityProviderName
self.IdentityProviderToken = identityProviderToken
}

typealias RawType = aws_cognito_identity_provider_token_pair
func withCStruct<Result>(_ body: (aws_cognito_identity_provider_token_pair) -> Result) -> Result {
var token_pair = aws_cognito_identity_provider_token_pair()

return withByteCursorFromStrings(IdentityProviderName,
IdentityProviderToken) { identityProviderNameCursor, IdentityProviderTokenCursor in
token_pair.identity_provider_name = identityProviderNameCursor
token_pair.identity_provider_token = IdentityProviderTokenCursor
return body(token_pair)
}
}
}

extension Array where Element == CognitoLoginPair {
func withCCognitoLoginPair<Result>(_ body: (OpaquePointer) throws -> Result) rethrows -> Result {
let array_list: UnsafeMutablePointer<aws_array_list> = allocator.allocate(capacity: 1)
defer {
aws_array_list_clean_up(array_list)
allocator.release(array_list)
}
guard aws_array_list_init_dynamic(
array_list,
allocator.rawValue,
count,
MemoryLayout<aws_cognito_identity_provider_token_pair>.size) == AWS_OP_SUCCESS else {
fatalError("Unable to initialize array of user properties")
}
forEach {
$0.withCPointer {
// `aws_array_list_push_back` will do a memory copy of $0 into array_list
guard aws_array_list_push_back(array_list, $0) == AWS_OP_SUCCESS else {
fatalError("Unable to add user property")
}
}
}
return try body(OpaquePointer(array_list.pointee.data))
}
}

/// Helper function to convert Swift [CognitoLoginPair]? into a native aws_cognito_identity_provider_token_pair pointer
func withOptionalCognitoLoginPair<Result>(
of array: Array<CognitoLoginPair>?,
_ body: (OpaquePointer?) throws -> Result) rethrows -> Result {
guard let _array = array else {
return try body(nil)
}
return try _array.withCCognitoLoginPair { opaquePointer in
return try body(opaquePointer)
}
}

public class CredentialsProvider: CredentialsProviding {

let rawValue: UnsafeMutablePointer<aws_credentials_provider>
Expand Down Expand Up @@ -561,6 +623,66 @@ extension CredentialsProvider.Source {
return provider
}
}

/// Credential Provider that sources credentials from Cognito Identity service
/// - Parameters:
/// - bootstrap: Connection bootstrap to use for any network connections made while sourcing credentials
/// - tlsContext: TLS configuration for secure socket connections.
/// - endpoint: Cognito service regional endpoint to source credentials from.
/// - identity: Cognito identity to fetch credentials relative to.
/// - logins: (Optional) set of identity provider token pairs to allow for authenticated identity access.
/// - customRoleArn: (Optional) ARN of the role to be assumed when multiple roles were received in the token from the identity provider.
/// - proxyOptions: (Optional) Http proxy configuration for the http request that fetches credentials
/// - shutdownCallback: (Optional) shutdown callback
/// - Returns: `CredentialsProvider`
/// - Throws: CommonRuntimeError.crtError
public static func `cognito`(bootstrap: ClientBootstrap,
tlsContext: TLSContext,
endpoint: String,
identity: String,
logins: [CognitoLoginPair]? = nil,
customRoleArn: String? = nil,
proxyOptions: HTTPProxyOptions? = nil,
shutdownCallback: ShutdownCallback? = nil) -> Self {
Self {
var cognitoOptions = aws_credentials_provider_cognito_options()
cognitoOptions.bootstrap = bootstrap.rawValue
cognitoOptions.tls_ctx = tlsContext.rawValue
let shutdownCallbackCore = ShutdownCallbackCore(shutdownCallback)
cognitoOptions.shutdown_options = shutdownCallbackCore.getRetainedCredentialProviderShutdownOptions()

guard let provider: UnsafeMutablePointer<aws_credentials_provider> = (withByteCursorFromStrings(
endpoint,
identity) { endpointCursor, identityCursor in

cognitoOptions.endpoint = endpointCursor
cognitoOptions.identity = identityCursor

return withOptionalCStructPointer(to: proxyOptions) { proxyOptionsPointer in
cognitoOptions.http_proxy_options = proxyOptionsPointer

return withOptionalCognitoLoginPair(of: logins, { loginArrayPointer in
if let loginArrayPointer, let loginCount = logins?.count {
cognitoOptions.logins = UnsafeMutablePointer<aws_cognito_identity_provider_token_pair>(loginArrayPointer)
cognitoOptions.login_count = loginCount
}

return withOptionalByteCursorPointerFromString(customRoleArn, { customRoleArnCursor in
if let customRoleArnCursor {
cognitoOptions.custom_role_arn = UnsafeMutablePointer<aws_byte_cursor>(mutating: customRoleArnCursor)
}
return aws_credentials_provider_new_cognito_caching(allocator.rawValue, &cognitoOptions)
})
})
}
})
else {
shutdownCallbackCore.release()
throw CommonRunTimeError.crtError(CRTError.makeFromLastError())
}
return provider
}
}
}

private func onGetCredentials(credentials: OpaquePointer?,
Expand Down
2 changes: 1 addition & 1 deletion Source/AwsCommonRuntimeKit/mqtt/Mqtt5Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ internal func MqttClientWebsocketTransform(
}
let httpRequest = HTTPRequest(nativeHttpMessage: request)
@Sendable func signerTransform(request: HTTPRequestBase, errorCode: Int32) {
complete_fn?(request.rawValue, errorCode, complete_ctx)
complete_fn?(request.rawValue, errorCode, complete_ctx)
}

if clientCore.onWebsocketInterceptor != nil {
Expand Down
1 change: 0 additions & 1 deletion Source/AwsCommonRuntimeKit/mqtt/Mqtt5Options.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import Foundation
import AwsCMqtt
import LibNative

/// Configuration for all client topic aliasing behavior.
public class TopicAliasingOptions: CStruct {
Expand Down Expand Up @@ -152,11 +151,11 @@
_willDelayIntervalSec,
self.receiveMaximum,
self.maximumPacketSize) { sessionExpiryIntervalSecPointer,
requestResponseInformationPointer,

Check warning on line 154 in Source/AwsCommonRuntimeKit/mqtt/Mqtt5Options.swift

View workflow job for this annotation

GitHub Actions / lint

Closure Parameter Position Violation: Closure parameters should be on the same line as opening brace (closure_parameter_position)
requestProblemInformationPointer,

Check warning on line 155 in Source/AwsCommonRuntimeKit/mqtt/Mqtt5Options.swift

View workflow job for this annotation

GitHub Actions / lint

Closure Parameter Position Violation: Closure parameters should be on the same line as opening brace (closure_parameter_position)
willDelayIntervalSecPointer,

Check warning on line 156 in Source/AwsCommonRuntimeKit/mqtt/Mqtt5Options.swift

View workflow job for this annotation

GitHub Actions / lint

Closure Parameter Position Violation: Closure parameters should be on the same line as opening brace (closure_parameter_position)
receiveMaximumPointer,

Check warning on line 157 in Source/AwsCommonRuntimeKit/mqtt/Mqtt5Options.swift

View workflow job for this annotation

GitHub Actions / lint

Closure Parameter Position Violation: Closure parameters should be on the same line as opening brace (closure_parameter_position)
maximumPacketSizePointer in

Check warning on line 158 in Source/AwsCommonRuntimeKit/mqtt/Mqtt5Options.swift

View workflow job for this annotation

GitHub Actions / lint

Closure Parameter Position Violation: Closure parameters should be on the same line as opening brace (closure_parameter_position)

raw_connect_options.session_expiry_interval_seconds = sessionExpiryIntervalSecPointer
raw_connect_options.request_response_information = requestResponseInformationPointer
Expand Down Expand Up @@ -449,7 +448,7 @@
self.httpProxyOptions,
self.topicAliasingOptions,
connnectOptions) { socketOptionsCPointer,
tlsOptionsCPointer,

Check warning on line 451 in Source/AwsCommonRuntimeKit/mqtt/Mqtt5Options.swift

View workflow job for this annotation

GitHub Actions / lint

Closure Parameter Position Violation: Closure parameters should be on the same line as opening brace (closure_parameter_position)
httpProxyOptionsCPointer,
topicAliasingOptionsCPointer,
connectOptionsCPointer in
Expand Down
1 change: 0 additions & 1 deletion Source/AwsCommonRuntimeKit/mqtt/Mqtt5Packets.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import Foundation
import AwsCHttp
import AwsCMqtt
import LibNative

/// Mqtt5 User Property
public class UserProperty: CStruct {
Expand Down
2 changes: 2 additions & 0 deletions Test/AwsCommonRuntimeKitTests/XCBaseTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ extension XCTestCase {
}

func skipIfPlatformDoesntSupportTLS() throws {
// Skipped for secitem support as the unit tests requires enetitlement setup to have acces to
// the data protection keychain.
try skipIfiOS()
try skipIfwatchOS()
try skipIftvOS()
Expand Down
44 changes: 44 additions & 0 deletions Test/AwsCommonRuntimeKitTests/auth/CredentialsProviderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,50 @@ class CredentialsProviderTests: XCBaseTestCase {
wait(for: [shutdownWasCalled], timeout: 15)
}


func testCreateDestroyCognitoCredsProviderWithoutHttpProxy() async throws {
let exceptionWasThrown = XCTestExpectation(description: "Exception was thrown")
do {
let cognitoEndpoint = try getEnvironmentVarOrSkipTest(environmentVarName: "AWS_TEST_MQTT5_COGNITO_ENDPOINT")
let cognitoIdentity = try getEnvironmentVarOrSkipTest(environmentVarName: "AWS_TEST_MQTT5_COGNITO_IDENTITY")


let provider = try CredentialsProvider(source: .cognito(bootstrap: getClientBootstrap(), tlsContext: getTlsContext(), endpoint: cognitoEndpoint, identity: cognitoIdentity, shutdownCallback: getShutdownCallback()))
let credentials = try await provider.getCredentials()
XCTAssertNotNil(credentials)
} catch is XCTSkip{ // skip the test as the environment var is not set
shutdownWasCalled.fulfill()
}catch {
exceptionWasThrown.fulfill()
}
wait(for: [shutdownWasCalled], timeout: 15)
}

// Http proxy related tests could only run behind vpc to access the proxy
func testCreateDestroyCognitoCredsProviderWithHttpProxy() async throws {
let exceptionWasThrown = XCTestExpectation(description: "Exception was thrown")
do {
let cognitoEndpoint = try getEnvironmentVarOrSkipTest(environmentVarName: "AWS_TEST_MQTT5_COGNITO_ENDPOINT")
let cognitoIdentity = try getEnvironmentVarOrSkipTest(environmentVarName: "AWS_TEST_MQTT5_COGNITO_IDENTITY")

let httpproxyHost = try getEnvironmentVarOrSkipTest(environmentVarName: "AWS_TEST_HTTP_PROXY_HOST")
let httpproxyPort = try getEnvironmentVarOrSkipTest(environmentVarName: "AWS_TEST_HTTP_PROXY_PORT")

let httpProxys = HTTPProxyOptions(hostName: httpproxyHost, port: UInt32(httpproxyPort)!, connectionType: .tunnel)

let provider = try CredentialsProvider(source: .cognito(bootstrap: getClientBootstrap(), tlsContext: getTlsContext(), endpoint: cognitoEndpoint, identity: cognitoIdentity, shutdownCallback: getShutdownCallback()))
let credentials = try await provider.getCredentials()
XCTAssertNotNil(credentials)
}
catch is XCTSkip{ // skip the test as the environment var is not set
shutdownWasCalled.fulfill()
}
catch {
exceptionWasThrown.fulfill()
}
wait(for: [shutdownWasCalled], timeout: 15)
}

func testCreateDestroyStsWebIdentityInvalidEnv() async throws {
XCTAssertThrowsError(try CredentialsProvider(source: .stsWebIdentity(
bootstrap: getClientBootstrap(),
Expand Down
1 change: 1 addition & 0 deletions Test/AwsCommonRuntimeKitTests/io/TLSContextTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class TLSContextTests: XCBaseTestCase {

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

Expand Down
Loading
Loading