Skip to content

Commit ea2cdeb

Browse files
authored
fix(auth): LoginMap key to use the cognito keyword (#4162)
1 parent 0b1bf25 commit ea2cdeb

File tree

4 files changed

+68
-2
lines changed

4 files changed

+68
-2
lines changed

AWSCognitoIdentityProvider/AWSCognitoIdentityUserPool.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,9 @@ - (void) clearAll {
294294

295295
#pragma mark identity provider
296296
- (NSString *) identityProviderName {
297-
return [NSString stringWithFormat:@"%@/%@", self.client.configuration.endpoint.hostName, self.userPoolConfiguration.poolId];
297+
return [NSString stringWithFormat:@"cognito-idp.%@.amazonaws.com/%@",
298+
[AWSEndpoint regionNameFromType:self.client.configuration.endpoint.regionType],
299+
self.userPoolConfiguration.poolId];
298300
}
299301

300302
- (AWSTask<NSString*>*) token {
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
//
2+
// Copyright 2010-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License").
5+
// You may not use this file except in compliance with the License.
6+
// A copy of the License is located at
7+
//
8+
// http://aws.amazon.com/apache2.0
9+
//
10+
// or in the "license" file accompanying this file. This file is distributed
11+
// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
// express or implied. See the License for the specific language governing
13+
// permissions and limitations under the License.
14+
//
15+
16+
#import <Foundation/Foundation.h>
17+
#import <UIKit/UIKit.h>
18+
#import <XCTest/XCTest.h>
19+
#import "AWSTestUtility.h"
20+
#import "AWSCognitoIdentityUserPool.h"
21+
22+
static id mockNetworking = nil;
23+
24+
@interface AWSCognitoIdentityUserPoolTests : XCTestCase
25+
26+
@end
27+
28+
@implementation AWSCognitoIdentityUserPoolTests
29+
30+
- (void)setUp {
31+
[super setUp];
32+
[AWSTestUtility setupFakeCognitoCredentialsProvider];
33+
}
34+
35+
- (void)tearDown {
36+
[super tearDown];
37+
}
38+
39+
- (void)testProviderName {
40+
NSString *key = @"testProviderName";
41+
AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:nil];
42+
AWSCognitoIdentityUserPoolConfiguration *userPoolConfiguration = [[AWSCognitoIdentityUserPoolConfiguration alloc] initWithClientId:@"someclientID" clientSecret:nil poolId:@"somePoolId"];
43+
[AWSCognitoIdentityUserPool registerCognitoIdentityUserPoolWithConfiguration:configuration
44+
userPoolConfiguration:userPoolConfiguration
45+
forKey:key];
46+
AWSCognitoIdentityUserPool *pool = [AWSCognitoIdentityUserPool CognitoIdentityUserPoolForKey:key];
47+
NSString *providerName = [pool identityProviderName];
48+
NSString *expectedValue = @"cognito-idp.us-east-1.amazonaws.com/somePoolId";
49+
XCTAssertEqualObjects(providerName, expectedValue);
50+
[AWSCognitoIdentityUserPool removeCognitoIdentityUserPoolForKey:key];
51+
}
52+
53+
@end

AWSiOSSDKv2.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,7 @@
627627
B4A4E03522B425C900379396 /* libOCMock.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CEB8EF551C6A6A2E0098B15B /* libOCMock.a */; };
628628
B4B8C4BF25ACC10F0054E723 /* AWSLexConfig.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = B4B8C4BE25ACC10E0054E723 /* AWSLexConfig.xcconfig */; };
629629
B4B8C61325ACC1270054E723 /* AWSLexConfig.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = B4B8C4BE25ACC10E0054E723 /* AWSLexConfig.xcconfig */; };
630+
B4B8C9B62845CAB3009E0865 /* AWSCognitoIdentityUserPoolTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B4B8C9B52845CAB3009E0865 /* AWSCognitoIdentityUserPoolTests.m */; };
630631
B4D61CCC23285D8C007E7A12 /* AWSCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CE0D416D1C6A66E5006B91B5 /* AWSCore.framework */; };
631632
B4D61CD523285DF5007E7A12 /* AWSConnectParticipant.h in Headers */ = {isa = PBXBuildFile; fileRef = B4D61CCD23285DF3007E7A12 /* AWSConnectParticipant.h */; settings = {ATTRIBUTES = (Public, ); }; };
632633
B4D61CD623285DF5007E7A12 /* AWSConnectParticipantService.h in Headers */ = {isa = PBXBuildFile; fileRef = B4D61CCE23285DF4007E7A12 /* AWSConnectParticipantService.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -3154,6 +3155,7 @@
31543155
B4A4E02B22B4233B00379396 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
31553156
B4A4E03222B423C700379396 /* AWSGeneralSageMakerRuntimeTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AWSGeneralSageMakerRuntimeTests.m; sourceTree = "<group>"; };
31563157
B4B8C4BE25ACC10E0054E723 /* AWSLexConfig.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = AWSLexConfig.xcconfig; sourceTree = "<group>"; };
3158+
B4B8C9B52845CAB3009E0865 /* AWSCognitoIdentityUserPoolTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AWSCognitoIdentityUserPoolTests.m; sourceTree = "<group>"; };
31573159
B4D61CAF23285D16007E7A12 /* AWSConnectParticipant.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = AWSConnectParticipant.framework; sourceTree = BUILT_PRODUCTS_DIR; };
31583160
B4D61CCD23285DF3007E7A12 /* AWSConnectParticipant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AWSConnectParticipant.h; sourceTree = "<group>"; };
31593161
B4D61CCE23285DF4007E7A12 /* AWSConnectParticipantService.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AWSConnectParticipantService.h; sourceTree = "<group>"; };
@@ -7301,6 +7303,7 @@
73017303
FA5A20192539F32A00ED165C /* AWSCognitoIdentityProviderNSSecureCodingTests.m */,
73027304
FA4DB84C2199E33C00AE7F20 /* AWSCognitoIdentityProviderSwiftTests.swift */,
73037305
FA4DB84B2199E33B00AE7F20 /* AWSCognitoIdentityProviderUnitTests-Bridging-Header.h */,
7306+
B4B8C9B52845CAB3009E0865 /* AWSCognitoIdentityUserPoolTests.m */,
73047307
CEE5AF311CE126C3008265A3 /* AWSGeneralCognitoIdentityProviderTests.m */,
73057308
CEA316C41C93A415002A9F58 /* Info.plist */,
73067309
);
@@ -13230,6 +13233,7 @@
1323013233
files = (
1323113234
FA5A201A2539F32B00ED165C /* AWSCognitoIdentityProviderNSSecureCodingTests.m in Sources */,
1323213235
FA4DB84D2199E33C00AE7F20 /* AWSCognitoIdentityProviderSwiftTests.swift in Sources */,
13236+
B4B8C9B62845CAB3009E0865 /* AWSCognitoIdentityUserPoolTests.m in Sources */,
1323313237
CEA316CC1C93A460002A9F58 /* AWSTestUtility.m in Sources */,
1323413238
CEE5AF331CE126C3008265A3 /* AWSGeneralCognitoIdentityProviderTests.m in Sources */,
1323513239
);

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,22 @@
44

55
-Features for next release
66

7+
### Bug Fixes
8+
9+
- **AWSCognito**
10+
- Fix the parsing of providerName used in the loginMap to use the right value in case of customer endpoint is configured. (See [PR #4162](https://github.com/aws-amplify/aws-sdk-ios/pull/4162))
11+
712
## 2.27.9
813

9-
- Features for next release
14+
### Bug Fixes
1015

1116
- **AWSS3**
1217

1318
- fix: adds details to userInfo for NSError for TransferUtility (See [PR #4115](https://github.com/aws-amplify/aws-sdk-ios/pull/4115))
1419
- fix: Reduces memory use for multipart uploads with `@autoreleasepool` to prevent excessive memory allocation (See [PR #4129](https://github.com/aws-amplify/aws-sdk-ios/pull/4129))
1520

21+
### Misc. Updates
22+
1623
- Model updates for the following services
1724
- AWSLocation
1825
- AWSEC2

0 commit comments

Comments
 (0)