Skip to content

Commit

Permalink
fix(auth): LoginMap key to use the cognito keyword (aws-amplify#4162)
Browse files Browse the repository at this point in the history
  • Loading branch information
royjit authored and gabek committed Aug 31, 2023
1 parent f9cbf5c commit d7f965e
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 2 deletions.
4 changes: 3 additions & 1 deletion AWSCognitoIdentityProvider/AWSCognitoIdentityUserPool.m
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,9 @@ - (void) clearAll {

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

- (AWSTask<NSString*>*) token {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//
// Copyright 2010-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License").
// You may not use this file except in compliance with the License.
// A copy of the License is located at
//
// http://aws.amazon.com/apache2.0
//
// or in the "license" file accompanying this file. This file is distributed
// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
// express or implied. See the License for the specific language governing
// permissions and limitations under the License.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
#import "AWSTestUtility.h"
#import "AWSCognitoIdentityUserPool.h"

static id mockNetworking = nil;

@interface AWSCognitoIdentityUserPoolTests : XCTestCase

@end

@implementation AWSCognitoIdentityUserPoolTests

- (void)setUp {
[super setUp];
[AWSTestUtility setupFakeCognitoCredentialsProvider];
}

- (void)tearDown {
[super tearDown];
}

- (void)testProviderName {
NSString *key = @"testProviderName";
AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:nil];
AWSCognitoIdentityUserPoolConfiguration *userPoolConfiguration = [[AWSCognitoIdentityUserPoolConfiguration alloc] initWithClientId:@"someclientID" clientSecret:nil poolId:@"somePoolId"];
[AWSCognitoIdentityUserPool registerCognitoIdentityUserPoolWithConfiguration:configuration
userPoolConfiguration:userPoolConfiguration
forKey:key];
AWSCognitoIdentityUserPool *pool = [AWSCognitoIdentityUserPool CognitoIdentityUserPoolForKey:key];
NSString *providerName = [pool identityProviderName];
NSString *expectedValue = @"cognito-idp.us-east-1.amazonaws.com/somePoolId";
XCTAssertEqualObjects(providerName, expectedValue);
[AWSCognitoIdentityUserPool removeCognitoIdentityUserPoolForKey:key];
}

@end
4 changes: 4 additions & 0 deletions AWSiOSSDKv2.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@
B4A4E03522B425C900379396 /* libOCMock.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CEB8EF551C6A6A2E0098B15B /* libOCMock.a */; };
B4B8C4BF25ACC10F0054E723 /* AWSLexConfig.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = B4B8C4BE25ACC10E0054E723 /* AWSLexConfig.xcconfig */; };
B4B8C61325ACC1270054E723 /* AWSLexConfig.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = B4B8C4BE25ACC10E0054E723 /* AWSLexConfig.xcconfig */; };
B4B8C9B62845CAB3009E0865 /* AWSCognitoIdentityUserPoolTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B4B8C9B52845CAB3009E0865 /* AWSCognitoIdentityUserPoolTests.m */; };
B4D61CCC23285D8C007E7A12 /* AWSCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CE0D416D1C6A66E5006B91B5 /* AWSCore.framework */; };
B4D61CD523285DF5007E7A12 /* AWSConnectParticipant.h in Headers */ = {isa = PBXBuildFile; fileRef = B4D61CCD23285DF3007E7A12 /* AWSConnectParticipant.h */; settings = {ATTRIBUTES = (Public, ); }; };
B4D61CD623285DF5007E7A12 /* AWSConnectParticipantService.h in Headers */ = {isa = PBXBuildFile; fileRef = B4D61CCE23285DF4007E7A12 /* AWSConnectParticipantService.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -3154,6 +3155,7 @@
B4A4E02B22B4233B00379396 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
B4A4E03222B423C700379396 /* AWSGeneralSageMakerRuntimeTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AWSGeneralSageMakerRuntimeTests.m; sourceTree = "<group>"; };
B4B8C4BE25ACC10E0054E723 /* AWSLexConfig.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = AWSLexConfig.xcconfig; sourceTree = "<group>"; };
B4B8C9B52845CAB3009E0865 /* AWSCognitoIdentityUserPoolTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AWSCognitoIdentityUserPoolTests.m; sourceTree = "<group>"; };
B4D61CAF23285D16007E7A12 /* AWSConnectParticipant.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = AWSConnectParticipant.framework; sourceTree = BUILT_PRODUCTS_DIR; };
B4D61CCD23285DF3007E7A12 /* AWSConnectParticipant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AWSConnectParticipant.h; sourceTree = "<group>"; };
B4D61CCE23285DF4007E7A12 /* AWSConnectParticipantService.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AWSConnectParticipantService.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -7301,6 +7303,7 @@
FA5A20192539F32A00ED165C /* AWSCognitoIdentityProviderNSSecureCodingTests.m */,
FA4DB84C2199E33C00AE7F20 /* AWSCognitoIdentityProviderSwiftTests.swift */,
FA4DB84B2199E33B00AE7F20 /* AWSCognitoIdentityProviderUnitTests-Bridging-Header.h */,
B4B8C9B52845CAB3009E0865 /* AWSCognitoIdentityUserPoolTests.m */,
CEE5AF311CE126C3008265A3 /* AWSGeneralCognitoIdentityProviderTests.m */,
CEA316C41C93A415002A9F58 /* Info.plist */,
);
Expand Down Expand Up @@ -13230,6 +13233,7 @@
files = (
FA5A201A2539F32B00ED165C /* AWSCognitoIdentityProviderNSSecureCodingTests.m in Sources */,
FA4DB84D2199E33C00AE7F20 /* AWSCognitoIdentityProviderSwiftTests.swift in Sources */,
B4B8C9B62845CAB3009E0865 /* AWSCognitoIdentityUserPoolTests.m in Sources */,
CEA316CC1C93A460002A9F58 /* AWSTestUtility.m in Sources */,
CEE5AF331CE126C3008265A3 /* AWSGeneralCognitoIdentityProviderTests.m in Sources */,
);
Expand Down
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,22 @@

-Features for next release

### Bug Fixes

- **AWSCognito**
- 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))

## 2.27.9

- Features for next release
### Bug Fixes

- **AWSS3**

- fix: adds details to userInfo for NSError for TransferUtility (See [PR #4115](https://github.com/aws-amplify/aws-sdk-ios/pull/4115))
- 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))

### Misc. Updates

- Model updates for the following services
- AWSLocation
- AWSEC2
Expand Down

0 comments on commit d7f965e

Please sign in to comment.