File tree 6 files changed +369
-257
lines changed
6 files changed +369
-257
lines changed Original file line number Diff line number Diff line change
1
+ import DefaultHandler from './default' ;
2
+
3
+ export const schema = { type : 'object' } ;
4
+
5
+ export default class BrandingHandler extends DefaultHandler {
6
+ constructor ( options ) {
7
+ super ( {
8
+ ...options ,
9
+ type : 'branding'
10
+ } ) ;
11
+ }
12
+
13
+ async getType ( ) {
14
+ try {
15
+ return await this . client . branding . getSettings ( ) ;
16
+ } catch ( err ) {
17
+ if ( err . statusCode === 404 ) return { } ;
18
+ throw err ;
19
+ }
20
+ }
21
+
22
+ async processChanges ( assets ) {
23
+ const { branding } = assets ;
24
+
25
+ // Do nothing if not set
26
+ if ( ! branding ) return ;
27
+
28
+ await this . client . branding . updateSettings ( branding ) ;
29
+ this . updated += 1 ;
30
+ this . didUpdate ( branding ) ;
31
+ }
32
+ }
Original file line number Diff line number Diff line change @@ -13,6 +13,8 @@ import * as guardianFactors from './guardianFactors';
13
13
import * as guardianFactorProviders from './guardianFactorProviders' ;
14
14
import * as guardianFactorTemplates from './guardianFactorTemplates' ;
15
15
import * as roles from './roles' ;
16
+ import * as branding from './branding' ;
17
+ import * as prompts from './prompts' ;
16
18
17
19
export {
18
20
rules ,
@@ -29,5 +31,7 @@ export {
29
31
guardianFactors ,
30
32
guardianFactorProviders ,
31
33
guardianFactorTemplates ,
32
- roles
34
+ roles ,
35
+ branding ,
36
+ prompts
33
37
} ;
Original file line number Diff line number Diff line change
1
+ import DefaultHandler from './default' ;
2
+
3
+ export const schema = { type : 'object' } ;
4
+
5
+ export default class PromptsHandler extends DefaultHandler {
6
+ constructor ( options ) {
7
+ super ( {
8
+ ...options ,
9
+ type : 'prompts'
10
+ } ) ;
11
+ }
12
+
13
+ async getType ( ) {
14
+ try {
15
+ return await this . client . prompts . getSettings ( ) ;
16
+ } catch ( err ) {
17
+ if ( err . statusCode === 404 ) return { } ;
18
+ throw err ;
19
+ }
20
+ }
21
+
22
+ async processChanges ( assets ) {
23
+ const { prompts } = assets ;
24
+
25
+ // Do nothing if not set
26
+ if ( ! prompts ) return ;
27
+
28
+ await this . client . prompts . updateSettings ( prompts ) ;
29
+ this . updated += 1 ;
30
+ this . didUpdate ( prompts ) ;
31
+ }
32
+ }
Original file line number Diff line number Diff line change
1
+ const { expect } = require ( 'chai' ) ;
2
+ const branding = require ( '../../../src/auth0/handlers/branding' ) ;
3
+
4
+ describe ( '#branding handler' , ( ) => {
5
+ describe ( '#branding process' , ( ) => {
6
+ it ( 'should get branding' , async ( ) => {
7
+ const auth0 = {
8
+ branding : {
9
+ getSettings : ( ) => ( {
10
+ logo_url : 'https://example.com/logo.png'
11
+ } )
12
+ }
13
+ } ;
14
+
15
+ const handler = new branding . default ( { client : auth0 } ) ;
16
+ const data = await handler . getType ( ) ;
17
+ expect ( data ) . to . deep . equal ( {
18
+ logo_url : 'https://example.com/logo.png'
19
+ } ) ;
20
+ } ) ;
21
+
22
+ it ( 'should update branding settings' , async ( ) => {
23
+ const auth0 = {
24
+ branding : {
25
+ updateSettings : ( data ) => {
26
+ expect ( data ) . to . be . an ( 'object' ) ;
27
+ expect ( data . logo_url ) . to . equal ( 'https://example.com/logo.png' ) ;
28
+ return Promise . resolve ( data ) ;
29
+ }
30
+ }
31
+ } ;
32
+
33
+ const handler = new branding . default ( { client : auth0 } ) ;
34
+ const stageFn = Object . getPrototypeOf ( handler ) . processChanges ;
35
+
36
+ await stageFn . apply ( handler , [
37
+ { branding : { logo_url : 'https://example.com/logo.png' } }
38
+ ] ) ;
39
+ } ) ;
40
+ } ) ;
41
+ } ) ;
Original file line number Diff line number Diff line change
1
+ const { expect } = require ( 'chai' ) ;
2
+ const prompts = require ( '../../../src/auth0/handlers/prompts' ) ;
3
+
4
+ describe ( '#prompts handler' , ( ) => {
5
+ describe ( '#prompts process' , ( ) => {
6
+ it ( 'should get prompts' , async ( ) => {
7
+ const auth0 = {
8
+ prompts : {
9
+ getSettings : ( ) => ( {
10
+ universal_login_experience : 'new'
11
+ } )
12
+ }
13
+ } ;
14
+
15
+ const handler = new prompts . default ( { client : auth0 } ) ;
16
+ const data = await handler . getType ( ) ;
17
+ expect ( data ) . to . deep . equal ( {
18
+ universal_login_experience : 'new'
19
+ } ) ;
20
+ } ) ;
21
+
22
+ it ( 'should update prompts settings' , async ( ) => {
23
+ const auth0 = {
24
+ prompts : {
25
+ updateSettings : ( data ) => {
26
+ expect ( data ) . to . be . an ( 'object' ) ;
27
+ expect ( data . universal_login_experience ) . to . equal ( 'new' ) ;
28
+ return Promise . resolve ( data ) ;
29
+ }
30
+ }
31
+ } ;
32
+
33
+ const handler = new prompts . default ( { client : auth0 } ) ;
34
+ const stageFn = Object . getPrototypeOf ( handler ) . processChanges ;
35
+
36
+ await stageFn . apply ( handler , [
37
+ { prompts : { universal_login_experience : 'new' } }
38
+ ] ) ;
39
+ } ) ;
40
+ } ) ;
41
+ } ) ;
You can’t perform that action at this time.
0 commit comments