From 3fe5692d9aa65ecf7a86e28c19dddf490d001384 Mon Sep 17 00:00:00 2001 From: Nandan Bhat Date: Fri, 21 Jun 2024 01:20:01 +0530 Subject: [PATCH 1/2] Adding 'is_signup_enabled' support --- src/tools/auth0/handlers/organizations.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/tools/auth0/handlers/organizations.ts b/src/tools/auth0/handlers/organizations.ts index 5418212a7..45afa30d5 100644 --- a/src/tools/auth0/handlers/organizations.ts +++ b/src/tools/auth0/handlers/organizations.ts @@ -21,6 +21,7 @@ export const schema = { connection_id: { type: 'string' }, assign_membership_on_login: { type: 'boolean' }, show_as_button: { type: 'boolean' }, + is_signup_enabled: { type: 'boolean' } }, }, }, @@ -127,8 +128,11 @@ export default class OrganizationsHandler extends DefaultHandler { existingConnections.find( (x) => x.connection_id === c.connection_id && - (x.assign_membership_on_login !== c.assign_membership_on_login || - x.show_as_button !== c.show_as_button) + ( + x.assign_membership_on_login !== c.assign_membership_on_login || + x.show_as_button !== c.show_as_button || + x.is_signup_enabled !== c.is_signup_enabled + ) ) ); @@ -141,6 +145,7 @@ export default class OrganizationsHandler extends DefaultHandler { { assign_membership_on_login: conn.assign_membership_on_login, show_as_button: conn.show_as_button, + is_signup_enabled: conn.is_signup_enabled } ) .catch(() => { From e387dc3cfab2589f5fa7fab78f0ce2c51f8deb74 Mon Sep 17 00:00:00 2001 From: Nandan Bhat Date: Fri, 21 Jun 2024 01:22:08 +0530 Subject: [PATCH 2/2] Adding required test-cases. --- test/context/directory/organizations.test.js | 41 +++++++++++++++++++ test/context/yaml/organizations.test.js | 5 +++ .../auth0/handlers/organizations.tests.js | 7 ++++ 3 files changed, 53 insertions(+) diff --git a/test/context/directory/organizations.test.js b/test/context/directory/organizations.test.js index ac5f67855..367a65dac 100644 --- a/test/context/directory/organizations.test.js +++ b/test/context/directory/organizations.test.js @@ -15,6 +15,8 @@ describe('#directory context organizations', () => { '{ "name": "acme", "display_name": "acme", "branding": { "colors": { "primary": "#3678e2", "page_background": "#9c4949" } }, "connections":[{ "name": "google", "assign_membership_on_login": false, "show_as_button": false }]}', 'contoso.json': '{ "name": "contoso", "display_name": "contoso", "branding": { "colors": { "primary": "#3678e2", "page_background": "#9c4949" } }, "connections":[{ "name": "google", "assign_membership_on_login": false, "show_as_button": false }]}', + 'tast-org.json': + '{ "name": "atko", "display_name": "Atko", "branding": { "colors": { "primary": "#ededed", "page_background": "#191919" } }, "connections":[{ "name": "Username-Password-Authentication", "assign_membership_on_login": true, "show_as_button": true, "is_signup_enabled": true }]}', }, }; @@ -60,6 +62,24 @@ describe('#directory context organizations', () => { }, ], }, + { + name: 'atko', + display_name: 'Atko', + branding: { + colors: { + primary: '#ededed', + page_background: '#191919', + }, + }, + connections: [ + { + name: 'Username-Password-Authentication', + assign_membership_on_login: true, + show_as_button: true, + is_signup_enabled: true, + } + ], + }, ]; expect(context.assets.organizations).to.deep.equal(target); @@ -135,6 +155,24 @@ describe('#directory context organizations', () => { }, ], }, + { + name: 'atko', + display_name: 'Atko', + branding: { + colors: { + primary: '#ededed', + page_background: '#191919', + }, + }, + connections: [ + { + name: 'Username-Password-Authentication', + assign_membership_on_login: true, + show_as_button: true, + is_signup_enabled: true, + }, + ], + }, ]; await handler.dump(context); @@ -145,5 +183,8 @@ describe('#directory context organizations', () => { expect(loadJSON(path.join(organizationsFolder, 'contoso.json'))).to.deep.equal( context.assets.organizations[1] ); + expect(loadJSON(path.join(organizationsFolder, 'atko.json'))).to.deep.equal( + context.assets.organizations[2] + ); }); }); diff --git a/test/context/yaml/organizations.test.js b/test/context/yaml/organizations.test.js index 50da0b742..5a67fa516 100644 --- a/test/context/yaml/organizations.test.js +++ b/test/context/yaml/organizations.test.js @@ -23,6 +23,7 @@ describe('#YAML context organizations', () => { - connection_id: con_123 assign_membership_on_login: false show_as_button: false + is_signup_enabled: false display_name: acme - name: contoso branding: @@ -33,6 +34,7 @@ describe('#YAML context organizations', () => { - connection_id: con_456 assign_membership_on_login: true show_as_button: true + is_signup_enabled: true display_name: contoso `; @@ -51,6 +53,7 @@ describe('#YAML context organizations', () => { connection_id: 'con_123', assign_membership_on_login: false, show_as_button: false, + is_signup_enabled: false }, ], }, @@ -68,6 +71,7 @@ describe('#YAML context organizations', () => { connection_id: 'con_456', assign_membership_on_login: true, show_as_button: true, + is_signup_enabled: true }, ], }, @@ -99,6 +103,7 @@ describe('#YAML context organizations', () => { connection_id: 'con_123', assign_membership_on_login: false, show_as_button: false, + is_signup_enabled: false, connection: { name: 'foo', strategy: 'auth0', diff --git a/test/tools/auth0/handlers/organizations.tests.js b/test/tools/auth0/handlers/organizations.tests.js index a2ed0d010..914026918 100644 --- a/test/tools/auth0/handlers/organizations.tests.js +++ b/test/tools/auth0/handlers/organizations.tests.js @@ -19,6 +19,7 @@ const sampleEnabledConnection = { connection_id: 'con_123', assign_membership_on_login: true, show_as_button: false, + is_signup_enabled: true, connection: { name: 'Username-Password-Login', strategy: 'auth0', @@ -135,6 +136,7 @@ describe('#organizations handler', () => { expect(connection.connection_id).to.equal('con_123'); expect(connection.assign_membership_on_login).to.equal(true); expect(connection.show_as_button).to.equal(false); + expect(connection.is_signup_enabled).to.equal(true); return Promise.resolve(connection); }, }, @@ -169,6 +171,7 @@ describe('#organizations handler', () => { name: 'Username-Password-Login', assign_membership_on_login: true, show_as_button: false, + is_signup_enabled: true }, ], }, @@ -333,6 +336,7 @@ describe('#organizations handler', () => { expect(data).to.be.an('object'); expect(data.assign_membership_on_login).to.equal(false); expect(data.show_as_button).to.equal(true); + expect(data.is_signup_enabled).to.equal(false); } else { expect(params).to.be.an('object'); expect(params.id).to.equal('123'); @@ -377,6 +381,7 @@ describe('#organizations handler', () => { name: 'Username-Password-Login', assign_membership_on_login: false, show_as_button: true, + is_signup_enabled: false }, { name: 'facebook', assign_membership_on_login: true, show_as_button: false }, ], @@ -409,6 +414,7 @@ describe('#organizations handler', () => { expect(data.connection_id).to.equal('con_123'); expect(data.assign_membership_on_login).to.equal(false); expect(data.show_as_button).to.equal(false); + expect(data.is_signup_enabled).to.equal(false); return Promise.resolve(data); }, }, @@ -445,6 +451,7 @@ describe('#organizations handler', () => { name: 'Username-Password-Login', assign_membership_on_login: false, show_as_button: false, + is_signup_enabled: false }, ], },