Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
73847e4e
Commit
73847e4e
authored
Mar 24, 2022
by
Paul Gascou-Vaillancourt
Committed by
Paul Gascou-Vaillancourt
Mar 25, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initialize the challenge if the username check fails
parent
ba4e9659
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
5 deletions
+35
-5
ee/app/assets/javascripts/arkose_labs/components/sign_in_arkose_app.vue
...javascripts/arkose_labs/components/sign_in_arkose_app.vue
+8
-3
ee/spec/frontend/arkose_labs/components/sign_in_arkose_app_spec.js
...rontend/arkose_labs/components/sign_in_arkose_app_spec.js
+27
-2
No files found.
ee/app/assets/javascripts/arkose_labs/components/sign_in_arkose_app.vue
View file @
73847e4e
...
...
@@ -112,9 +112,14 @@ export default {
await
this
.
initArkoseLabs
();
}
}
catch
(
e
)
{
// If the requests fails with a 404 code, we can fail silently.
// We show a generic error message for any other failure.
if
(
e
.
response
?.
status
!==
404
)
{
if
(
e
.
response
?.
status
===
404
)
{
// We ignore 404 errors as it just means the username does not exist.
}
else
if
(
e
.
response
?.
status
)
{
// If the request failed with any other error code, we initialize the challenge to make
// sure it isn't being bypassed by purposefully making the endpoint fail.
this
.
initArkoseLabs
();
}
else
{
// For any other failure, we show the initialization error message.
this
.
handleArkoseLabsFailure
(
e
);
}
}
finally
{
...
...
ee/spec/frontend/arkose_labs/components/sign_in_arkose_app_spec.js
View file @
73847e4e
...
...
@@ -214,16 +214,41 @@ describe('SignInArkoseApp', () => {
});
});
describe
(
'
when the
REST endpoint
fails
'
,
()
=>
{
describe
(
'
when the
username check
fails
'
,
()
=>
{
beforeEach
(
async
()
=>
{
jest
.
spyOn
(
console
,
'
error
'
).
mockImplementation
(()
=>
{});
});
it
(
'
with a 404, nothing happens
'
,
async
()
=>
{
axiosMock
.
onGet
().
reply
(
404
);
initArkoseLabs
(
MOCK_USERNAME
);
await
waitForPromises
();
expect
(
initArkoseLabsScript
).
not
.
toHaveBeenCalled
();
expectHiddenArkoseLabsError
();
});
it
(
'
with some other HTTP error, the challenge is initialized
'
,
async
()
=>
{
axiosMock
.
onGet
().
reply
(
500
);
initArkoseLabs
(
MOCK_USERNAME
);
await
waitForPromises
();
expect
(
initArkoseLabsScript
).
toHaveBeenCalled
();
expectHiddenArkoseLabsError
();
});
it
(
'
shows initialization error
'
,
()
=>
{
it
(
'
due to the script inclusion, an error is shown
'
,
async
()
=>
{
const
error
=
new
Error
();
initArkoseLabsScript
.
mockImplementation
(()
=>
{
throw
new
Error
();
});
axiosMock
.
onGet
().
reply
(
200
,
{
result
:
true
});
initArkoseLabs
(
MOCK_USERNAME
);
await
waitForPromises
();
expectArkoseLabsInitError
();
// eslint-disable-next-line no-console
expect
(
console
.
error
).
toHaveBeenCalledWith
(
'
ArkoseLabs initialization error
'
,
error
);
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment