Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/wild-gifts-move.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@forgerock/javascript-sdk': patch
---

Add support for KBA `allowUserDefinedQuestions` flag
14 changes: 11 additions & 3 deletions e2e/autoscript-apps/src/register-basic/autoscript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,19 @@ function autoscript() {
console.log(`Predefined Question1: ${pdq1}`);
console.log(`Predefined Question 2: ${pdq2}`);

kbCb1.setQuestion('What is your favorite color?');
const isAllowedUserDefinedQuestions1 = kbCb1.isAllowedUserDefinedQuestions();
const isAllowedUserDefinedQuestions2 = kbCb2.isAllowedUserDefinedQuestions();
console.log(`kbCb1 is allowed user defined questions: ${isAllowedUserDefinedQuestions1}`);
console.log(`kbCb2 is allowed user defined questions: ${isAllowedUserDefinedQuestions2}`);

kbCb1.setQuestion(pdq1);
kbCb1.setAnswer('Red');

kbCb2.setQuestion('Who was your first employer?');
kbCb2.setAnswer('AAA Engineering');
kbCb2.setQuestion('Who was your first pet?');
kbCb2.setAnswer('Fluffy');

const customQuestion = kbCb2.getInputValue();
console.log(`Custom Question from kbCb2: ${customQuestion}`);

console.log('Handle TermsAndConditionsCallback');
const tcCb = step.getCallbackOfType('TermsAndConditionsCallback');
Expand Down
4 changes: 3 additions & 1 deletion e2e/autoscript-suites/src/suites/register-basic.lc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ test.describe('Test basic registration flow', () => {
const un = v4();
const email = `${un}@me.com`;

test(`should register user successfully and then log ou`, async ({ page, browserName }) => {
test(`should register user successfully and then log out`, async ({ page, browserName }) => {
const { messageArray } = await setupAndGo(page, browserName, 'register-basic/', {
un,
email,
Expand All @@ -33,6 +33,8 @@ test.describe('Test basic registration flow', () => {
// expect(messageArray.includes('Prompt 6: Age')).toBe(true);
expect(messageArray.includes('Prompt 7: Select a security question')).toBe(true);
expect(messageArray.includes(`Predefined Question1: What's your favorite color?`)).toBe(true);
expect(messageArray.includes(`kbCb2 is allowed user defined questions: true`)).toBe(true);
expect(messageArray.includes(`Custom Question from kbCb2: Who was your first pet?`)).toBe(true);
expect(messageArray.includes('Terms version: 0.0')).toBe(true);
expect(
messageArray.includes(
Expand Down
8 changes: 8 additions & 0 deletions e2e/mock-api/src/app/response.registration.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ export default {
name: 'predefinedQuestions',
value: [`What's your favorite color?`, 'Who was your first employer?'],
},
{
name: 'allowUserDefinedQuestions',
value: true,
},
],
input: [
{ name: 'IDToken8question', value: '' },
Expand All @@ -196,6 +200,10 @@ export default {
name: 'predefinedQuestions',
value: [`What's your favorite color?`, 'Who was your first employer?'],
},
{
name: 'allowUserDefinedQuestions',
value: true,
},
],
input: [
{ name: 'IDToken9question', value: '' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ class KbaCreateCallback extends FRCallback {
return this.getOutputByName<string[]>('predefinedQuestions', []);
}

/**
* Gets whether the user can define questions.
*/
public isAllowedUserDefinedQuestions(): boolean {
return this.getOutputByName<boolean>('allowUserDefinedQuestions', false);
}

/**
* Sets the callback's security question.
*/
Expand Down
Loading