Skip to content

Commit 3da55f8

Browse files
committed
fix: never allow integ tests to hit actual login endpoint as races happen
1 parent c9bcf5a commit 3da55f8

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/services/login-browser.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ define(function (require, exports, module) {
113113
return {err: ERR_RETRY_LATER};
114114
}
115115
try {
116+
if(Phoenix.isTestWindow && fetchFn === fetch){
117+
// so we never allow tests to hit the actual login service.
118+
return {err: ERR_NOT_LOGGED_IN};
119+
}
116120
const response = await fetchFn(resolveURL, {
117121
method: 'GET',
118122
credentials: 'include', // Include cookies
@@ -333,6 +337,10 @@ define(function (require, exports, module) {
333337
async function signOutBrowser() {
334338
const logoutURL = `${_getAccountBaseURL()}/signOut`;
335339
try {
340+
if(Phoenix.isTestWindow && fetchFn === fetch){
341+
// so we never allow tests to hit the actual login service.
342+
return;
343+
}
336344
const response = await fetchFn(logoutURL, {
337345
method: 'POST',
338346
credentials: 'include', // Include cookies

src/services/login-desktop.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ define(function (require, exports, module) {
101101
return {err: ERR_RETRY_LATER};
102102
}
103103
try {
104+
if(Phoenix.isTestWindow && fetchFn === fetch){
105+
// so we never allow tests to hit the actual login service.
106+
return {err: ERR_INVALID};
107+
}
104108
const response = await fetchFn(resolveURL);
105109
if (response.status === 400 || response.status === 404) {
106110
// 404 api key not found and 400 Bad Request, eg: verification code mismatch
@@ -195,6 +199,10 @@ define(function (require, exports, module) {
195199
const resolveURL = `${Phoenix.config.account_url}getAppAuthSession?autoAuthPort=${authPortURL}&appName=${appName}`;
196200
// {"isSuccess":true,"appSessionID":"a uuid...","validationCode":"SWXP07"}
197201
try {
202+
if(Phoenix.isTestWindow && fetchFn === fetch){
203+
// so we never allow tests to hit the actual login service.
204+
return null;
205+
}
198206
const response = await fetchFn(resolveURL);
199207
if (response.ok) {
200208
const {appSessionID, validationCode} = await response.json();
@@ -348,6 +356,10 @@ define(function (require, exports, module) {
348356
appSessionID: userProfile.apiKey
349357
};
350358

359+
if(Phoenix.isTestWindow && fetchFn === fetch){
360+
// so we never allow tests to hit the actual login service.
361+
return;
362+
}
351363
const response = await fetchFn(resolveURL, {
352364
method: 'POST',
353365
headers: {

0 commit comments

Comments
 (0)