Skip to content

Commit 88b4040

Browse files
chore: fix aswebauthenticationsession issue for automated tests
1 parent 86bdfd3 commit 88b4040

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

Source/Immutable/Private/Immutable/Mac/ImmutableMac.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#include "ImmutableMac.h"
2+
3+
#include "Engine/GameEngine.h"
4+
25
#include "Immutable/ImmutablePassport.h"
36
#include "Immutable/ImmutableSubsystem.h"
4-
#include "Engine/GameEngine.h"
57

68
#if WITH_EDITOR
79
#include "Editor.h"
@@ -67,6 +69,13 @@ ASWebAuthenticationSession *_authSession;
6769
}
6870

6971
- (void)launchUrl:(const char *)url forRedirectUri:(const char *)redirectUri {
72+
// For automation, use the browser-based method
73+
if (GIsAutomationTesting) {
74+
NSLog(@"Using automation mode for authentication (GIsAutomationTesting is true)");
75+
[self launchUrlInBrowser:url];
76+
return;
77+
}
78+
7079
if (@available(macOS 10.15, *)) {
7180
NSURL *URL =
7281
[NSURL URLWithString:[[NSString alloc] initWithUTF8String:url]];
@@ -104,6 +113,20 @@ ASWebAuthenticationSession *_authSession;
104113
}
105114
}
106115

116+
- (void)launchUrlInBrowser:(const char *)url {
117+
// Add redundant check to ensure this only runs for automated testing
118+
if (!GIsAutomationTesting) {
119+
return;
120+
}
121+
122+
// Create URL object
123+
NSURL *URL = [NSURL URLWithString:[[NSString alloc] initWithUTF8String:url]];
124+
125+
// Open URL in default browser
126+
[[NSWorkspace sharedWorkspace] openURL:URL];
127+
NSLog(@"Opened URL in browser for automation: %@", URL);
128+
}
129+
107130
- (ASPresentationAnchor)presentationAnchorForWebAuthenticationSession:
108131
(ASWebAuthenticationSession *)session API_AVAILABLE(macos(10.15)) {
109132
return [[[NSApplication sharedApplication] windows] firstObject];

Source/Immutable/Private/Immutable/Mac/ImmutableMac.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@
77
: NSObject <ASWebAuthenticationPresentationContextProviding>
88
+ (ImmutableMac *)instance;
99
- (void)launchUrl:(const char *)url forRedirectUri:(const char *)redirectUri;
10+
- (void)launchUrlInBrowser:(const char *)url;
1011
@end

0 commit comments

Comments
 (0)