|
36 | 36 | #import "NSDictionary+MSIDTestUtil.h" |
37 | 37 | #import "MSIDAuthenticationSchemePop.h" |
38 | 38 | #import "MSIDAuthenticationSchemeSshCert.h" |
| 39 | +#import "MSIDBartFeatureUtil.h" |
39 | 40 | @interface MSIDBrokerTokenRequestTests : XCTestCase |
40 | 41 |
|
41 | 42 | @end |
42 | 43 |
|
43 | 44 | @implementation MSIDBrokerTokenRequestTests |
44 | 45 |
|
| 46 | +- (void)setUp |
| 47 | +{ |
| 48 | + [self setBoundAppRefreshTokenFlight]; |
| 49 | +} |
| 50 | + |
45 | 51 | - (void)tearDown |
46 | 52 | { |
47 | 53 | [MSIDIntuneEnrollmentIdsCache setSharedCache:[[MSIDIntuneEnrollmentIdsCache alloc] initWithDataSource:[[MSIDIntuneInMemoryCacheDataSource alloc] initWithCache:[MSIDCache new]]]]; |
48 | 54 | [MSIDIntuneMAMResourcesCache setSharedCache:[[MSIDIntuneMAMResourcesCache alloc] initWithDataSource:[[MSIDIntuneInMemoryCacheDataSource alloc] initWithCache:[MSIDCache new]]]]; |
49 | | - |
| 55 | + [[MSIDBartFeatureUtil sharedInstance] setBartSupportInAppCache:NO]; |
50 | 56 | [super tearDown]; |
51 | 57 | } |
52 | 58 |
|
@@ -191,6 +197,7 @@ - (void)testInitBrokerRequest_whenValidParameters_shouldReturnValidPayload |
191 | 197 | @"client_app_version": @"1.0", |
192 | 198 | @"broker_nonce" : [MSIDTestIgnoreSentinel sentinel], |
193 | 199 | @"application_token" : @"brokerApplicationToken", |
| 200 | + MSID_BOUND_RT_REDEEM : @"1", |
194 | 201 | @"client_sku" : [self clientSku], |
195 | 202 | @"skip_validate_result_account" : @"NO" |
196 | 203 | }; |
@@ -238,6 +245,7 @@ - (void)testInitBrokerRequest_whenValidParameters_shouldReturnValidPayload_ATPop |
238 | 245 | @"application_token" : @"brokerApplicationToken", |
239 | 246 | @"req_cnf" : @"eyJraWQiOiJlQWkyNE9leml1czc5VlRadDhsZlhldFJTejdsR2thSmloWEJFWkIwMnV3In0", |
240 | 247 | @"token_type" : @"Pop", |
| 248 | + MSID_BOUND_RT_REDEEM : @"1", |
241 | 249 | @"client_sku" : [self clientSku], |
242 | 250 | @"skip_validate_result_account" : @"NO" |
243 | 251 | }; |
@@ -290,6 +298,7 @@ - (void)testInitBrokerRequest_whenValidParameters_shouldReturnValidPayload_SshCe |
290 | 298 | @"key_id":@"key_id_value", |
291 | 299 | @"req_cnf" : [NSString stringWithFormat:@"{\"kty\":\"RSA\",\"n\":\"%@\",\"e\":\"%@\"}", modulus, exponent], |
292 | 300 | @"token_type" : @"ssh-cert", |
| 301 | + MSID_BOUND_RT_REDEEM : @"1", |
293 | 302 | @"client_sku" : [self clientSku], |
294 | 303 | @"skip_validate_result_account" : @"NO" |
295 | 304 | }; |
@@ -339,6 +348,7 @@ - (void)testInitBrokerRequest_whenValidParameters_andUniversalLinkRequest_should |
339 | 348 | @"client_app_version": @"1.0", |
340 | 349 | @"broker_nonce" : [MSIDTestIgnoreSentinel sentinel], |
341 | 350 | @"application_token" : @"brokerApplicationToken", |
| 351 | + MSID_BOUND_RT_REDEEM : @"1", |
342 | 352 | @"client_sku" : [self clientSku], |
343 | 353 | @"skip_validate_result_account" : @"NO" |
344 | 354 | }; |
@@ -376,6 +386,7 @@ - (void)testInitBrokerRequest_whenParametersWithOptionalParameters_shouldReturnV |
376 | 386 | @"client_app_version": @"1.0", |
377 | 387 | @"broker_nonce" : [MSIDTestIgnoreSentinel sentinel], |
378 | 388 | @"application_token" : @"brokerApplicationToken", |
| 389 | + MSID_BOUND_RT_REDEEM : @"1", |
379 | 390 | @"client_sku" : [self clientSku], |
380 | 391 | @"skip_validate_result_account" : @"NO" |
381 | 392 | }; |
@@ -422,6 +433,7 @@ - (void)testInitBrokerRequest_whenValidParameters_andSDKCapabilities_shouldRetur |
422 | 433 | @"broker_nonce" : [MSIDTestIgnoreSentinel sentinel], |
423 | 434 | @"application_token" : @"brokerApplicationToken", |
424 | 435 | @"sdk_broker_capabilities": @"capability1,capability2", |
| 436 | + MSID_BOUND_RT_REDEEM : @"1", |
425 | 437 | @"client_sku" : [self clientSku], |
426 | 438 | @"skip_validate_result_account" : @"NO" |
427 | 439 | }; |
@@ -505,6 +517,7 @@ - (void)testInitBrokerRequest_whenParametersWithIntuneItems_shouldReturnValidPay |
505 | 517 | @"client_app_version": @"1.0", |
506 | 518 | @"broker_nonce" : [MSIDTestIgnoreSentinel sentinel], |
507 | 519 | @"application_token" : @"brokerApplicationToken", |
| 520 | + MSID_BOUND_RT_REDEEM : @"1", |
508 | 521 | @"client_sku" : [self clientSku], |
509 | 522 | @"skip_validate_result_account" : @"NO" |
510 | 523 | }; |
@@ -592,6 +605,7 @@ - (void)testInitBrokerRequest_whenParametersWithNestedAuthItems_shouldReturnVali |
592 | 605 | @"application_token" : @"brokerApplicationToken", |
593 | 606 | @"brk_client_id" : @"123-456-7890-123", |
594 | 607 | @"brk_redirect_uri" : @"msauth.com.app.id://auth", |
| 608 | + MSID_BOUND_RT_REDEEM : @"1", |
595 | 609 | @"client_sku" : [self clientSku], |
596 | 610 | @"skip_validate_result_account" : @"NO" |
597 | 611 | }; |
@@ -620,4 +634,42 @@ - (void)testInitBrokerRequest_whenParametersWithNestedAuthItems_shouldReturnVali |
620 | 634 | XCTAssertEqualObjects(expectedResumeDictionary, request.resumeDictionary); |
621 | 635 | } |
622 | 636 |
|
| 637 | +- (void)testInitBrokerRequest_whenValidParameters_andBoundRefreshTokenExchangeNotRequestedWhenFlightEnabledButCacheNotEnabled |
| 638 | +{ |
| 639 | + MSIDInteractiveTokenRequestParameters *parameters = [self defaultTestParameters]; |
| 640 | + [[MSIDBartFeatureUtil sharedInstance] setBartSupportInAppCache:NO]; |
| 641 | + XCTAssertFalse([[MSIDBartFeatureUtil sharedInstance] isBartFeatureEnabled]); |
| 642 | + |
| 643 | + NSError *error = nil; |
| 644 | + MSIDBrokerTokenRequest *request = [[MSIDBrokerTokenRequest alloc] initWithRequestParameters:parameters brokerKey:@"brokerKey" brokerApplicationToken:@"brokerApplicationToken" sdkCapabilities:@[@"capability1", @"capability2"] error:&error]; |
| 645 | + XCTAssertNotNil(request); |
| 646 | + XCTAssertNil(error); |
| 647 | + |
| 648 | + NSDictionary *expectedRequest = @{@"authority": @"https://login.microsoftonline.com/contoso.com", |
| 649 | + @"client_id": @"my_client_id", |
| 650 | + @"correlation_id": [parameters.correlationId UUIDString], |
| 651 | + @"redirect_uri": @"my-redirect://com.microsoft.test", |
| 652 | + @"broker_key": @"brokerKey", |
| 653 | + @"client_version": [MSIDVersion sdkVersion], |
| 654 | + @"client_app_name": @"MSIDTestsHostApp", |
| 655 | + @"client_app_version": @"1.0", |
| 656 | + @"broker_nonce" : [MSIDTestIgnoreSentinel sentinel], |
| 657 | + @"application_token" : @"brokerApplicationToken", |
| 658 | + @"sdk_broker_capabilities": @"capability1,capability2", |
| 659 | + @"client_sku" : [self clientSku], |
| 660 | + @"skip_validate_result_account" : @"NO" |
| 661 | + }; |
| 662 | + |
| 663 | + NSURL *actualURL = request.brokerRequestURL; |
| 664 | + |
| 665 | + NSString *expectedUrlString = [NSString stringWithFormat:@"msauthv2://broker?%@", [expectedRequest msidURLEncode]]; |
| 666 | + NSURL *expectedURL = [NSURL URLWithString:expectedUrlString]; |
| 667 | + XCTAssertTrue([expectedURL matchesURL:actualURL]); |
| 668 | +} |
| 669 | + |
| 670 | +- (void)setBoundAppRefreshTokenFlight |
| 671 | +{ |
| 672 | + [[MSIDBartFeatureUtil sharedInstance] setBartSupportInAppCache:YES]; |
| 673 | +} |
| 674 | + |
623 | 675 | @end |
0 commit comments