|
37 | 37 | @interface MSIDWorkPlaceJoinUtilTests : XCTestCase |
38 | 38 | @property (nonatomic) MSIDTestSecureEnclaveKeyPairGenerator *eccKeyGenerator; |
39 | 39 | @property (nonatomic) BOOL useIosStyleKeychain; |
| 40 | +@property (atomic) MSIDTestSecureEnclaveKeyPairGenerator *stkEccKeyGenerator; |
40 | 41 | @end |
41 | 42 |
|
42 | 43 | NSString * const dummyKeyIdendetifier = @"com.microsoft.workplacejoin.dummyKeyIdentifier"; |
@@ -133,8 +134,8 @@ - (void)testGetWPJKeysWithTenantId_whenWPJInDefaultWithSameTenant_EccBasedRegNoS |
133 | 134 |
|
134 | 135 | - (void)testGetWPJKeysWithTenantId_whenWPJInDefaultWithSameTenant_EccBasedRegUsingSecureEnclave_shouldReturnDefault |
135 | 136 | { |
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]; |
138 | 139 | XCTAssertNotNil(result); |
139 | 140 | XCTAssertEqual(result.keyChainVersion, MSIDWPJKeychainAccessGroupV2); |
140 | 141 | CFStringRef cName = NULL; |
@@ -770,8 +771,34 @@ - (OSStatus)addPrimaryEccDefaultRegistrationForTenantId:(NSString *)tenantId |
770 | 771 |
|
771 | 772 | @end |
772 | 773 |
|
| 774 | +#if TARGET_OS_IOS |
| 775 | +@interface MSIDWorkPlaceJoinUtilTests (TransportKeyTests) |
| 776 | + -(void)insertEccStkKeyForTenantIdentifier:(NSString *)tenantIdentifier keychainGroup:(NSString *)keychainGroup; |
| 777 | +@end |
773 | 778 |
|
774 | | -@implementation MSIDWorkPlaceJoinUtilTests (TransportKey) |
| 779 | +@implementation MSIDWorkPlaceJoinUtilTests (TransportKeyTests) |
775 | 780 |
|
| 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 | +} |
776 | 802 |
|
777 | 803 | @end |
| 804 | +#endif |
0 commit comments