Skip to content

Commit

Permalink
Add more test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
srijonsaha committed Oct 5, 2023
1 parent 7e82a73 commit 0eaa213
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 11 deletions.
5 changes: 3 additions & 2 deletions dist/auth0.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* auth0-js v9.22.1
* Author: Auth0
* Date: 2023-10-04
* Date: 2023-10-05
* License: MIT
*/

Expand Down Expand Up @@ -7572,7 +7572,6 @@
var AUTH0_PROVIDER = 'auth0';
var TIMEOUT_MS = 500;
var MAX_RETRY = 3;
var retryCount = 0;

var defaults$2 = {
lang: 'en',
Expand Down Expand Up @@ -7722,6 +7721,7 @@
opts.siteKey
);
if (opts.provider === ARKOSE_PROVIDER) {
var retryCount = 0;
attributes['data-callback'] = callbackName;
attributes['onerror'] = function () {
if (retryCount < MAX_RETRY) {
Expand Down Expand Up @@ -7811,6 +7811,7 @@
function (arkose) {
var global = globalForCaptchaProvider(challenge.provider);
if (challenge.provider === ARKOSE_PROVIDER) {
var retryCount = 0;
arkose.setConfig({
onReady: function () {
if (arkoseConfig && arkoseConfig.onReady) {
Expand Down
4 changes: 2 additions & 2 deletions dist/auth0.min.esm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/auth0.min.esm.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/auth0.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/auth0.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/cordova-auth0-plugin.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* auth0-js v9.22.1
* Author: Auth0
* Date: 2023-10-04
* Date: 2023-10-05
* License: MIT
*/

Expand Down
2 changes: 1 addition & 1 deletion dist/cordova-auth0-plugin.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/web-auth/captcha.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ var ARKOSE_PROVIDER = 'arkose';
var AUTH0_PROVIDER = 'auth0';
var TIMEOUT_MS = 500;
var MAX_RETRY = 3;
var retryCount = 0;

var defaults = {
lang: 'en',
Expand Down Expand Up @@ -162,6 +161,7 @@ function injectCaptchaScript(element, opts, callback, setValue) {
opts.siteKey
);
if (opts.provider === ARKOSE_PROVIDER) {
var retryCount = 0;
attributes['data-callback'] = callbackName;
attributes['onerror'] = function () {
if (retryCount < MAX_RETRY) {
Expand Down Expand Up @@ -251,6 +251,7 @@ function handleCaptchaProvider(element, options, challenge, arkoseConfig) {
function (arkose) {
var global = globalForCaptchaProvider(challenge.provider);
if (challenge.provider === ARKOSE_PROVIDER) {
var retryCount = 0;
arkose.setConfig({
onReady: function () {
if (arkoseConfig && arkoseConfig.onReady) {
Expand Down
17 changes: 17 additions & 0 deletions test/web-auth/captcha.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,7 @@ describe('passwordless captcha rendering', function () {
let c,
captchaScript,
arkoseCallback,
scriptErrorCallback,
arkose,
arkoseConfig,
element,
Expand Down Expand Up @@ -973,6 +974,7 @@ describe('passwordless captcha rendering', function () {
s.src.match('arkoselabs.com')

Check failure

Code scanning / CodeQL

Missing regular expression anchor High test

When this is used as a regular expression on a URL, it may match anywhere, and arbitrary hosts may come before or after it.
);
arkoseCallback = window[captchaScript.getAttribute('data-callback')];
scriptErrorCallback = captchaScript.onerror;
});

afterEach(function () {
Expand All @@ -991,6 +993,21 @@ describe('passwordless captcha rendering', function () {
expect(arkoseCallback).to.be.a('function');
});

it('should reinject the captcha script on error', function () {
expect(scriptErrorCallback).to.be.a('function');
scriptErrorCallback();
captchaScript = [...window.document.querySelectorAll('script')].find(s =>
s.src.match('arkoselabs.com')

Check failure

Code scanning / CodeQL

Missing regular expression anchor High test

When this is used as a regular expression on a URL, it may match anywhere, and arbitrary hosts may come before or after it.
);
const scriptUrl = url.parse(captchaScript.src, true);
expect(scriptUrl.hostname).to.equal(
`${challenge.clientSubdomain}.${'arkoselabs.com'}`
);
expect(scriptUrl.pathname).to.equal(
`/${'v2'}/${challenge.siteKey}/${'api.js'}`
);
});

describe('after captcha is loaded', function () {
let configOptions, setConfigSpy, runSpy, resetSpy;
this.beforeEach(function () {
Expand Down

0 comments on commit 0eaa213

Please sign in to comment.