Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanbas21 committed Jan 4, 2024
2 parents 71c561d + 4a7b7bc commit 2568fe9
Show file tree
Hide file tree
Showing 56 changed files with 1,212 additions and 373 deletions.
1 change: 0 additions & 1 deletion .github/workflows/commit-check.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: ForgeRock Commit Check

on:
pull_request:
push:
branches-ignore:
# We don't want to check commits on develop or master
Expand Down
42 changes: 0 additions & 42 deletions .github/workflows/destroy_preview.yml

This file was deleted.

58 changes: 0 additions & 58 deletions .github/workflows/preview.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,5 @@ users/*
docs/packages/javascript-sdk
**/playwright-report
**/playwright/.cache

.nx
114 changes: 114 additions & 0 deletions e2e/autoscript-apps/src/authn-otp-reg/autoscript.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/*
* @forgerock/javascript-sdk
*
* autoscript.ts
*
* Copyright (c) 2020 ForgeRock. All rights reserved.
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
// @ts-nocheck
import * as forgerock from '@forgerock/javascript-sdk';
import { delay as rxDelay, map, mergeMap } from 'rxjs/operators';
import { from } from 'rxjs';

function autoscript() {
const delay = 0;

const url = new URL(window.location.href);
const amUrl = url.searchParams.get('amUrl') || 'https://auth.example.com:9443/am';
const realmPath = url.searchParams.get('realmPath') || 'root';
const un = url.searchParams.get('un') || 'sdkuser';
const pw = url.searchParams.get('pw') || 'password';
const tree = url.searchParams.get('tree') || 'QRCodeTest';

console.log('Configure the SDK');
forgerock.Config.set({
realmPath,
tree,
serverConfig: {
baseUrl: amUrl,
},
});

try {
forgerock.SessionManager.logout();
} catch (err) {
// Do nothing
}

console.log('Initiate first step with `undefined`');
// Wrapping in setTimeout to give the test time to bind listener to console.log
setTimeout(function () {
from(forgerock.FRAuth.next())
.pipe(
mergeMap((step) => {
console.log('Set values on auth tree callbacks for submission');
const unCb = step.getCallbackOfType('NameCallback');
unCb.setName(un);

const pwCb = step.getCallbackOfType('PasswordCallback');
pwCb.setPassword(pw);

return forgerock.FRAuth.next(step);
}),
rxDelay(delay),
mergeMap((step) => {
console.log('Register MFA with QR Code');
const isQRCodeStep = forgerock.FRQRCode.isQRCodeStep(step);
if (!isQRCodeStep) {
throw new Error('Did not get expected QR Code step');
}

const { message, use, uri } = forgerock.FRQRCode.getQRCodeData(step);
if (!message && !use && !uri) {
throw new Error('Was unable to retreive message, use or URI from step');
}

console.log(message);
console.log(use);
console.log(uri);

return forgerock.FRAuth.next(step);
}),
map(
(step) => {
if (step.payload.status === 401) {
throw new Error('Auth_Error');
} else if (step.payload.tokenId) {
console.log('Basic login with OTP registration step successful');
document.body.innerHTML = '<p class="Logged_In">Login successful</p>';
} else {
throw new Error('Something went wrong.');
}
},
(step) => step,
),
rxDelay(delay),
mergeMap((step) => {
return forgerock.SessionManager.logout();
}),
map((response) => {
if (response.ok) {
console.log('Logout successful');
document.body.innerHTML = '<p class="Logged_Out">Logout successful</p>';
} else {
throw new Error('Logout_Error');
}
}),
)
.subscribe({
error: (err) => {
console.log(`Error: ${err.message}`);
document.body.innerHTML = `<p class="Test_Complete">${err.message}</p>`;
},
complete: () => {
console.log('Test script complete');
document.body.innerHTML = `<p class="Test_Complete">Test script complete</p>`;
},
});
}, 250);
}

autoscript();
export default autoscript;
33 changes: 33 additions & 0 deletions e2e/autoscript-apps/src/authn-otp-reg/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!DOCTYPE html>
<html>
<head>
<title>E2E Test | ForgeRock JavaScript SDK</title>

<!-- Needed only for automation with mock server -->
<meta name="referrer" content="unsafe-url" />

<link rel="shortcut icon" href="/fr-ico.png" type="image/png" />

<style>
@media (prefers-color-scheme: dark) {
html {
background-color: black;
color: white;
}
a {
color: lightblue;
}
a:visited {
color: lavender;
}
a:hover {
color: lightskyblue;
}
}
</style>
</head>

<body>
<script src="autoscript.js"></script>
</body>
</html>
1 change: 1 addition & 0 deletions e2e/autoscript-apps/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<a href="./authn-webauthn/index.html">AuthN: WebAuthn</a><br />
<a href="./authn-webauthn-device-registration/index.html">AuthN: WebAuthN Device Registration</a
><br />
<a href="./authn-otp-reg/index.html">AuthN: OTP Registration (QR Code)</a><br />
<a href="./authz-token/index.html">AuthZ: Token</a><br />
<a href="./authz-tree-basic-redirect/index.html"
>AuthZ: Tree-based with Basic Login and Redirect response</a
Expand Down
1 change: 1 addition & 0 deletions e2e/autoscript-apps/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const pages = [
'authn-social-login-idm',
'authn-webauthn',
'authn-webauthn-device-registration',
'authn-otp-reg',
'authz-token',
'authz-tree-basic-json',
'authz-tree-basic-redirect',
Expand Down
20 changes: 2 additions & 18 deletions e2e/autoscript-suites/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const config: PlaywrightTestConfig = {
name: 'chromium',
use: {
...devices['Desktop Chrome'],
// ...devices['Desktop Edge'],
...devices['Desktop Edge'],
},
},
{
Expand All @@ -32,23 +32,7 @@ const config: PlaywrightTestConfig = {
},
{
name: 'webkit',
use: { ...devices['Desktop Safari'], ...devices['iPad (gen 7)'] },
},
{
name: 'Android Web',
use: {
...devices['Pixel 4a (5G)'],
...devices['Pixel 5'],
},
},
{
name: 'Apple Mobile',
use: {
...devices['iPhone X'],
...devices['iPhone XR'],
...devices['iPhone SE'],
...devices['iPhone 13 Pro Max'],
},
use: { ...devices['Desktop Safari'] },
},
],
};
Expand Down
31 changes: 31 additions & 0 deletions e2e/autoscript-suites/src/suites/authn-otp-reg.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* @forgerock/javascript-sdk
*
* authn-otp-reg.test.ts
*
* Copyright (c) 2020 ForgeRock. All rights reserved.
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
import { test, expect } from '@playwright/test';
import { setupAndGo } from '../utilities/setup-and-go';

test.describe('Test QR Code flows', () => {
test(`Login and register OTP successfully`, async ({ page, browserName }) => {
const { messageArray } = await setupAndGo(page, browserName, 'authn-otp-reg/');

// Test assertions
expect(
messageArray.includes(
'Scan the QR code image below with the ForgeRock Authenticator app to register your device with your login.',
),
).toBe(true);
expect(messageArray.includes('otp')).toBe(true);
expect(
messageArray.includes(
'otpauth://totp/ForgeRock:jlowery?secret=QITSTC234FRIU8DD987DW3VPICFY======&issuer=ForgeRock&period=30&digits=6&b=032b75',
),
).toBe(true);
expect(messageArray.includes('Basic login with OTP registration step successful')).toBe(true);
});
});
Loading

0 comments on commit 2568fe9

Please sign in to comment.