Skip to content

Commit 305e4a1

Browse files
committed
Added amr claim type along with unit tests
1 parent 913b400 commit 305e4a1

4 files changed

Lines changed: 52 additions & 0 deletions

File tree

GoogleSignIn/Sources/GIDClaim.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDClaim.h"
1818

1919
NSString * const kAuthTimeClaimName = @"auth_time";
20+
NSString * const kAMRClaimName = @"amr";
2021

2122
// Private interface to declare the internal initializer
2223
@interface GIDClaim ()
@@ -48,6 +49,14 @@ + (instancetype)essentialAuthTimeClaim {
4849
return [[self alloc] initWithName:kAuthTimeClaimName essential:YES];
4950
}
5051

52+
+ (instancetype)amrClaim {
53+
return [[self alloc] initWithName:kAMRClaimName essential:NO];
54+
}
55+
56+
+ (instancetype)essentialAMRClaim {
57+
return [[self alloc] initWithName:kAMRClaimName essential:YES];
58+
}
59+
5160
#pragma mark - NSObject
5261

5362
- (BOOL)isEqual:(id)object {

GoogleSignIn/Sources/Public/GoogleSignIn/GIDClaim.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
NS_ASSUME_NONNULL_BEGIN
2020

2121
extern NSString *const kAuthTimeClaimName;
22+
extern NSString *const kAMRClaimName;
2223

2324
/**
2425
* An object representing a single OIDC claim to be requested for an ID token.
@@ -42,6 +43,12 @@ extern NSString *const kAuthTimeClaimName;
4243
/// Creates an *essential* "auth_time" claim object.
4344
+ (instancetype)essentialAuthTimeClaim;
4445

46+
/// Creates a *non-essential* (voluntary) "amr" claim object.
47+
+ (instancetype)amrClaim;
48+
49+
/// Creates an *essential* "amr" claim object.
50+
+ (instancetype)essentialAMRClaim;
51+
4552
@end
4653

4754
NS_ASSUME_NONNULL_END

GoogleSignIn/Tests/Unit/GIDClaimTest.m

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@ - (void)testEssentialAuthTimeClaim_PropertiesAreCorrect {
3333
XCTAssertTrue(claim.isEssential);
3434
}
3535

36+
- (void)testAMRClaim_PropertiesAreCorrect {
37+
GIDClaim *claim = [GIDClaim amrClaim];
38+
XCTAssertEqualObjects(claim.name, kAMRClaimName);
39+
XCTAssertFalse(claim.isEssential);
40+
}
41+
42+
- (void)testEssentialAMRClaim_PropertiesAreCorrect {
43+
GIDClaim *claim = [GIDClaim essentialAMRClaim];
44+
XCTAssertEqualObjects(claim.name, kAMRClaimName);
45+
XCTAssertTrue(claim.isEssential);
46+
}
47+
3648
- (void)testEquality_WithEqualClaims {
3749
GIDClaim *claim1 = [GIDClaim authTimeClaim];
3850
GIDClaim *claim2 = [GIDClaim authTimeClaim];
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"configurations" : [
3+
{
4+
"id" : "E1592086-F47A-47B0-89F5-A5A3C3FBEF58",
5+
"name" : "Test Scheme Action",
6+
"options" : {
7+
8+
}
9+
}
10+
],
11+
"defaultOptions" : {
12+
13+
},
14+
"testTargets" : [
15+
{
16+
"target" : {
17+
"containerPath" : "container:",
18+
"identifier" : "GoogleSignIn-UnitTests",
19+
"name" : "GoogleSignIn-UnitTests"
20+
}
21+
}
22+
],
23+
"version" : 1
24+
}

0 commit comments

Comments
 (0)