Skip to content

Commit

Permalink
Merge pull request #1413 from AzureAD/mipetriu/visionOS_final_testing
Browse files Browse the repository at this point in the history
visionOS unit testing and PR validation pipeline
  • Loading branch information
mipetriu authored Sep 4, 2024
2 parents d1c29ff + 01a369b commit ab42695
Show file tree
Hide file tree
Showing 11 changed files with 84 additions and 21 deletions.
16 changes: 14 additions & 2 deletions IdentityCore/IdentityCore.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8083,10 +8083,11 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos xrsimulator xros";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TARGETED_DEVICE_FAMILY = "1,2,7";
};
name = Debug;
};
Expand Down Expand Up @@ -8143,9 +8144,10 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos xrsimulator xros";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TARGETED_DEVICE_FAMILY = "1,2,7";
VALIDATE_PRODUCT = YES;
};
name = Release;
Expand Down Expand Up @@ -8203,6 +8205,8 @@
PRODUCT_BUNDLE_IDENTIFIER = com.microsoft.MSIDTestsHostApp;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
TARGETED_DEVICE_FAMILY = "1,2,7";
};
name = Debug;
};
Expand Down Expand Up @@ -8252,6 +8256,8 @@
PRODUCT_BUNDLE_IDENTIFIER = com.microsoft.MSIDTestsHostApp;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
TARGETED_DEVICE_FAMILY = "1,2,7";
VALIDATE_PRODUCT = YES;
};
name = Release;
Expand Down Expand Up @@ -8776,9 +8782,11 @@
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PROVISIONING_PROFILE_SPECIFIER = "";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
SWIFT_OBJC_BRIDGING_HEADER = "tests/IdentityCoreTests iOS-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2,7";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/MSIDTestsHostApp.app/MSIDTestsHostApp";
};
name = Debug;
Expand All @@ -8796,8 +8804,10 @@
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PROVISIONING_PROFILE_SPECIFIER = "";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
SWIFT_OBJC_BRIDGING_HEADER = "tests/IdentityCoreTests iOS-Bridging-Header.h";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2,7";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/MSIDTestsHostApp.app/MSIDTestsHostApp";
};
name = Release;
Expand Down Expand Up @@ -8867,6 +8877,7 @@
GCC_OPTIMIZATION_LEVEL = 0;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos xros xrsimulator";
TARGETED_DEVICE_FAMILY = "1,2,7";
};
name = Debug;
};
Expand All @@ -8877,6 +8888,7 @@
ENABLE_BITCODE = NO;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos xros xrsimulator";
TARGETED_DEVICE_FAMILY = "1,2,7";
};
name = Release;
};
Expand Down
2 changes: 1 addition & 1 deletion IdentityCore/tests/MSIDAccountCredentialsCacheTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ - (void)setUp
{
id<MSIDExtendedTokenCacheDataSource> dataSource = nil;

#if TARGET_OS_IOS
#if !TARGET_OS_OSX
dataSource = [[MSIDKeychainTokenCache alloc] initWithGroup:nil error:nil];
#else
// TODO: this should be replaced with a real macOS datasource instead
Expand Down
3 changes: 2 additions & 1 deletion IdentityCore/tests/MSIDAccountMetadataCacheAccessorTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -599,9 +599,10 @@ - (void)testRemoveAccountMetadataForHomeAccountId_whenHomeAccountNotNil_shouldRe
XCTAssertNil(error);
XCTAssertEqual(accountMetadataItems.count, 2);

MSIDAccountMetadataCacheItem *firstItem = accountMetadataItems[0];
MSIDAccountMetadataCacheItem *cacheItem1;
MSIDAccountMetadataCacheItem *cacheItem2;
if ([[accountMetadataItems[0] clientId] isEqualToString:@"my-client-id-1"])
if ([[firstItem clientId] isEqualToString:@"my-client-id-1"])
{
cacheItem1 = accountMetadataItems[0];
cacheItem2 = accountMetadataItems[1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ - (void)testAcquireToken_whenBrokerInstallPrompt_andSuccessfulResponse_shouldRet
[expectation fulfill];
}];

[self waitForExpectationsWithTimeout:3.0 handler:nil];
[self waitForExpectationsWithTimeout:7.0 handler:nil];
}

- (void)testAcquireToken_whenWPJRequest_shouldReturnWorkplaceJoinRequiredError
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1982,17 +1982,18 @@ - (void)testClearCacheForAccount_whenTokensInCacheInMultipleAccessors_shouldRemo
XCTAssertEqual([remainingAccessTokens count], 1);
MSIDLegacyAccessToken *remainingAccessToken = remainingAccessTokens[0];
XCTAssertEqualObjects(remainingAccessToken.accountIdentifier.displayableId, @"upn@test.com");
XCTAssertEqualObjects([remainingAccessTokens[0] clientId], @"test_client_id2");
XCTAssertEqualObjects([remainingAccessToken clientId], @"test_client_id2");

NSArray *remaininRefreshTokens = [MSIDTestCacheAccessorHelper getAllLegacyRefreshTokens:_legacyAccessor];
XCTAssertEqual([remaininRefreshTokens count], 1);
MSIDLegacyRefreshToken *remainingRefreshToken = remaininRefreshTokens[0];
XCTAssertEqualObjects(remainingRefreshToken.accountIdentifier.displayableId, @"upn@test.com");
XCTAssertEqualObjects([remaininRefreshTokens[0] clientId], @"test_client_id2");
XCTAssertEqualObjects([remainingRefreshToken clientId], @"test_client_id2");

NSArray *otherRemainingRefreshTokens = [MSIDTestCacheAccessorHelper getAllDefaultRefreshTokens:_otherAccessor];
XCTAssertEqual([otherRemainingRefreshTokens count], 1);
XCTAssertEqualObjects([otherRemainingRefreshTokens[0] clientId], @"test_client_id2");
MSIDLegacyRefreshToken *otherRemainingToken = otherRemainingRefreshTokens[0];
XCTAssertEqualObjects([otherRemainingToken clientId], @"test_client_id2");
}

- (void)testClearCacheForAccountAndClientId_whenTokensInCache_shouldRemoveCorrectTokens
Expand Down Expand Up @@ -2038,11 +2039,13 @@ - (void)testClearCacheForAccountAndClientId_whenTokensInCache_shouldRemoveCorrec

NSArray *remainingAccessTokens = [MSIDTestCacheAccessorHelper getAllLegacyAccessTokens:_legacyAccessor];
XCTAssertEqual([remainingAccessTokens count], 1);
XCTAssertEqualObjects([remainingAccessTokens[0] clientId], @"test_client_id2");
MSIDLegacyAccessToken *remainingAccessToken = remainingAccessTokens[0];
XCTAssertEqualObjects([remainingAccessToken clientId], @"test_client_id2");

NSArray *remaininRefreshTokens = [MSIDTestCacheAccessorHelper getAllLegacyRefreshTokens:_legacyAccessor];
XCTAssertEqual([remaininRefreshTokens count], 1);
XCTAssertEqualObjects([remaininRefreshTokens[0] clientId], @"test_client_id2");
NSArray *remainingRefreshTokens = [MSIDTestCacheAccessorHelper getAllLegacyRefreshTokens:_legacyAccessor];
XCTAssertEqual([remainingRefreshTokens count], 1);
MSIDLegacyRefreshToken *remainingRefreshToken = remainingRefreshTokens[0];
XCTAssertEqualObjects([remainingRefreshToken clientId], @"test_client_id2");
}

- (void)testRemoveAccessToken_whenNilTokenProvided_shouldReturnError
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ - (void)testInteractiveRequestFlow_whenNestedAuth_shouldReturnResultWithBrokerPa
[self waitForExpectationsWithTimeout:1 handler:nil];
}

#if TARGET_OS_IPHONE
#if TARGET_OS_IPHONE && !(defined TARGET_OS_VISION && TARGET_OS_VISION)
- (void)testInteractiveRequestFlow_whenOpenBrowserResponse_shouldOpenLink
{
__block NSUUID *correlationId = [NSUUID new];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#import "MSIDTestWebviewInteractingViewController.h"
#import "MSIDWebviewAuthorization.h"

#if TARGET_OS_IPHONE
#if TARGET_OS_IPHONE && !MSID_EXCLUDE_SYSTEMWV
#import "MSIDSystemWebviewController.h"
#endif

Expand Down
3 changes: 2 additions & 1 deletion IdentityCore/xcconfig/identitycore__common__ios.xcconfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
SDKROOT = iphoneos
CODE_SIGN_IDENTITY = "iPhone Developer"
IPHONEOS_DEPLOYMENT_TARGET = 14.0
XROS_DEPLOYMENT_TARGET = 1.0
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"
TARGETED_DEVICE_FAMILY = 1,2
TARGETED_DEVICE_FAMILY = 1,2,7
ENABLE_BITCODE = YES
SKIP_INSTALL = YES
1 change: 1 addition & 0 deletions IdentityCore/xcconfig/identitycore__idlib__ios.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@

// Activate full bitcode on release configuration for real devices.
OTHER_CFLAGS[config=Release][sdk=iphoneos*] = $(OTHER_CFLAGS) -fembed-bitcode
OTHER_CFLAGS[config=Release][sdk=xros*] = $(OTHER_CFLAGS) -fembed-bitcode
20 changes: 20 additions & 0 deletions azure_pipelines/pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ jobs:
target: "ios_library"
MAC_LIB:
target: "mac_library"
VISION_LIB:
target: "vision_library"
displayName: Validate Pull Request
pool:
vmImage: 'macos-14'
Expand Down Expand Up @@ -48,6 +50,24 @@ jobs:
targetType: 'inline'
script: |
find . -name "*.gcda" -print0 | xargs -0 rm
# The following is needed to install the visionOS SDK on macos-14 vm image which
# doesn't have visionOS installed by default.
# TODO: Remove when macos-14-arm64 is supported on ADO.
- task: Bash@3
displayName: download visionOS SDK
inputs:
targetType: 'inline'
script: |
if [ $(target) == 'vision_library' ]; then
echo "Downloading simulator for visionOS"
sudo xcode-select -s /Applications/Xcode_15.4.app/Contents/Developer
defaults write com.apple.dt.Xcode AllowUnsupportedVisionOSHost -bool YES
defaults write com.apple.CoreSimulator AllowUnsupportedVisionOSHost -bool YES
xcodebuild -downloadPlatform visionOS
else
echo "Not visionOS job, no download needed"
fi
failOnStderr: false
- task: Bash@3
displayName: Run CPP script
inputs:
Expand Down
37 changes: 31 additions & 6 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
ios_sim_dest = "-destination 'platform=iOS Simulator,name=" + ios_sim_device + ",OS=17.5'"
ios_sim_flags = "-sdk iphonesimulator CODE_SIGN_IDENTITY=\"\" CODE_SIGNING_REQUIRED=NO"

vision_sim_device = "Apple Vision Pro"
vision_sim_dest = "-destination 'platform=visionOS Simulator,name=" + vision_sim_device + ",OS=1.2'"
vision_sim_flags = "-sdk xrsimulator CODE_SIGN_IDENTITY=\"\" CODE_SIGNING_REQUIRED=NO"

default_workspace = "IdentityCore.xcworkspace"
default_config = "Debug"

Expand Down Expand Up @@ -70,6 +74,14 @@ class ColorValues:
"min_warn_codecov" : 70.0,
"platform" : "Mac"
},
{
"name" : "Vision Library",
"target" : "vision_library",
"scheme" : "IdentityCore iOS",
"operations" : [ "build", "test" ],
"min_warn_codecov" : 70.0,
"platform" : "visionOS"
},
]

def print_operation_start(name, operation) :
Expand Down Expand Up @@ -141,6 +153,9 @@ def xcodebuild_command(self, operation, xcpretty) :
if (self.platform == "iOS") :
command += " " + ios_sim_flags + " " + ios_sim_dest

if (self.platform == "visionOS") :
command += " " + vision_sim_flags + " " + vision_sim_dest

if (xcpretty) :
command += " | xcpretty"
if (xcpretty and operation == "test") :
Expand Down Expand Up @@ -231,8 +246,11 @@ def get_device_guid(self) :

if (self.platform == "Mac") :
return device_guids.get_mac().decode(sys.stdout.encoding)

if (self.platform == "visionOS") :
return device_guids.get_ios(vision_sim_device)

raise Exception("Unsupported platform: \"" + "\", valid platforms are \"iOS\" and \"Mac\"")
raise Exception("Unsupported platform: \"" + "\", valid platforms are \"iOS\", \"visionOS\", and \"Mac\"")

def do_codecov(self) :
"""
Expand Down Expand Up @@ -306,7 +324,7 @@ def do_operation(self, operation) :
return exit_code

def requires_simulator(self) :
if self.platform != "iOS" :
if self.platform == "Mac" :
return False
if "test" in self.operations :
return True
Expand All @@ -318,9 +336,16 @@ def requires_simulator(targets) :
return True
return False

def launch_simulator() :
print("Booting simulator...")
command = "xcrun simctl boot " + device_guids.get_ios(ios_sim_device)
def launch_simulator(targets) :
for target in targets :
if target.platform == "iOS" :
print("Booting iOS simulator...")
command = "xcrun simctl boot " + device_guids.get_ios(ios_sim_device)
break
else :
print("Booting visionOS simulator...")
command = "xcrun simctl boot " + device_guids.get_ios(vision_sim_device)
break
print(command)

# This spawns a new process without us having to wait for it
Expand Down Expand Up @@ -349,7 +374,7 @@ def launch_simulator() :
targets.append(BuildTarget(spec))

if requires_simulator(targets) :
launch_simulator()
launch_simulator(targets)

# start by cleaning up any derived data that might be lying around
if (clean) :
Expand Down

0 comments on commit ab42695

Please sign in to comment.