Skip to content

Commit 611f60c

Browse files
committed
Update test tid
1 parent b20a745 commit 611f60c

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

IdentityCore/tests/MSIDWorkPlaceJoinUtilTests.m

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
@interface MSIDWorkPlaceJoinUtilTests : XCTestCase
3838
@property (nonatomic) MSIDTestSecureEnclaveKeyPairGenerator *eccKeyGenerator;
3939
@property (nonatomic) BOOL useIosStyleKeychain;
40+
@property (atomic) MSIDTestSecureEnclaveKeyPairGenerator *stkEccKeyGenerator;
4041
@end
4142

4243
NSString * const dummyKeyIdendetifier = @"com.microsoft.workplacejoin.dummyKeyIdentifier";
@@ -133,8 +134,8 @@ - (void)testGetWPJKeysWithTenantId_whenWPJInDefaultWithSameTenant_EccBasedRegNoS
133134

134135
- (void)testGetWPJKeysWithTenantId_whenWPJInDefaultWithSameTenant_EccBasedRegUsingSecureEnclave_shouldReturnDefault
135136
{
136-
[self insertDummyEccRegistrationForTenantIdentifier:@"tenantId" certIdentifier:kDummyTenant1CertIdentifier useSecureEnclave:YES];
137-
MSIDWPJKeyPairWithCert *result = [MSIDWorkPlaceJoinUtil getWPJKeysWithTenantId:@"tenantId" context:nil];
137+
[self insertDummyEccRegistrationForTenantIdentifier:@"tenantId-some-tid" certIdentifier:kDummyTenant1CertIdentifier useSecureEnclave:YES];
138+
MSIDWPJKeyPairWithCert *result = [MSIDWorkPlaceJoinUtil getWPJKeysWithTenantId:@"tenantId-some-tid" context:nil];
138139
XCTAssertNotNil(result);
139140
XCTAssertEqual(result.keyChainVersion, MSIDWPJKeychainAccessGroupV2);
140141
CFStringRef cName = NULL;
@@ -770,8 +771,34 @@ - (OSStatus)addPrimaryEccDefaultRegistrationForTenantId:(NSString *)tenantId
770771

771772
@end
772773

774+
#if TARGET_OS_IOS
775+
@interface MSIDWorkPlaceJoinUtilTests (TransportKeyTests)
776+
-(void)insertEccStkKeyForTenantIdentifier:(NSString *)tenantIdentifier keychainGroup:(NSString *)keychainGroup;
777+
@end
773778

774-
@implementation MSIDWorkPlaceJoinUtilTests (TransportKey)
779+
@implementation MSIDWorkPlaceJoinUtilTests (TransportKeyTests)
775780

781+
- (void)insertEccStkKeyForTenantIdentifier:(NSString *)tenantIdentifier keychainGroup:(NSString *)keychainGroup
782+
{
783+
NSString *stkTag = [NSString stringWithFormat:@"%@#%@%@", kMSIDPrivateTransportKeyIdentifier, tenantIdentifier, @"-EC"];
784+
SecKeyRef transportKeyRef = [self createAndGetdummyEccPrivateKey:YES privateKeyTag:stkTag];
785+
XCTAssertTrue(transportKeyRef != NULL);
786+
[self insertKeyIntoKeychain:transportKeyRef
787+
privateKeyTag:stkTag
788+
accessGroup:keychainGroup];
789+
}
790+
791+
- (void)testGetWPJKeysWithTenantId_whenEccRegistrationWithTransportKey_shouldReturnBothKeys
792+
{
793+
[self insertDummyEccRegistrationForTenantIdentifier:@"tenantId" certIdentifier:kDummyTenant1CertIdentifier useSecureEnclave:YES];
794+
[self insertEccStkKeyForTenantIdentifier:@"tenantId" keychainGroup:[self keychainGroup:NO]];
795+
MSIDWPJKeyPairWithCert *result = [MSIDWorkPlaceJoinUtil getWPJKeysWithTenantId:@"tenantId" context:nil];
796+
797+
XCTAssertNotNil(result);
798+
XCTAssertEqual(result.keyChainVersion, MSIDWPJKeychainAccessGroupV2);
799+
XCTAssertTrue(result.privateKeyRef != NULL);
800+
XCTAssertTrue(result.privateTransportKeyRef != NULL);
801+
}
776802

777803
@end
804+
#endif

0 commit comments

Comments
 (0)