Skip to content

Commit

Permalink
DXCDT-382: Standardizing Auth0 Resource Identifiers (1/x) (#756)
Browse files Browse the repository at this point in the history
* Renaming load to loadAssetsFromLocal

* Renaming load to loadAssetsFromAuth0

* integrating into export process

* Adding config interpreter

* Disabling keyword replacement in certain cases

* Fixing directory load

* More forgiving lookup logic if properties and/or addresses do not exist

* Fixing directory load again

* Adding case that would have previously tripped up process

* Adding e2e tests for keyword preservation

* Removing old tests, updating recordings, removing console. logs

* Commenting-out test to fix later on

* Fixing workdirectory for e2e tests

* Adding eventual cases for auxillary files

* Adding TODO

* Adding preqrequisite checks

* Fixing test

* Standardizing definitions of resource identifiers

* Removing incompatible id from email templates

* Readding identifiers field for resource server

* Fixing email templates identifier field

---------

Co-authored-by: Will Vedder <will.vedder@okta.com>
  • Loading branch information
willvedd and willvedd authored Mar 1, 2023
1 parent ed79f86 commit 4dc4a3c
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 8 deletions.
6 changes: 4 additions & 2 deletions src/tools/auth0/handlers/emailTemplates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class EmailTemplateHandler extends DefaultHandler {
super({
...options,
type: 'emailTemplates',
id: 'template',
identifiers: ['template'],
});
}

Expand All @@ -49,7 +49,9 @@ export default class EmailTemplateHandler extends DefaultHandler {

async updateOrCreate(emailTemplate): Promise<void> {
try {
const params = { name: emailTemplate[this.id] };
const identifierField = this.identifiers[0];

const params = { name: emailTemplate[identifierField] };
const updated = await this.client.emailTemplates.update(params, emailTemplate);
delete updated.body;
this.didUpdate(updated);
Expand Down
3 changes: 1 addition & 2 deletions src/tools/auth0/handlers/organizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export default class OrganizationsHandler extends DefaultHandler {
...config,
type: 'organizations',
id: 'id',
identifiers: ['name'],
});
}

Expand Down Expand Up @@ -253,7 +252,7 @@ export default class OrganizationsHandler extends DefaultHandler {
handler: this,
assets: organizations,
existing,
identifiers: ['id', 'name'],
identifiers: this.identifiers,
allowDelete: !!this.config('AUTH0_ALLOW_DELETE'),
});

Expand Down
1 change: 1 addition & 0 deletions src/tools/auth0/handlers/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export default class PagesHandler extends DefaultHandler {
super({
...options,
type: 'pages',
identifiers: ['name'],
});
}

Expand Down
3 changes: 2 additions & 1 deletion src/tools/auth0/handlers/resourceServers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default class ResourceServersHandler extends DefaultHandler {
super({
...options,
type: 'resourceServers',
identifiers: ['id', 'identifier'],
stripUpdateFields: ['identifier'], // Fields not allowed in updates
});
}
Expand Down Expand Up @@ -90,7 +91,7 @@ export default class ResourceServersHandler extends DefaultHandler {
handler: this,
assets: resourceServers,
existing,
identifiers: ['id', 'identifier'],
identifiers: this.identifiers,
allowDelete: !!this.config('AUTH0_ALLOW_DELETE'),
});
}
Expand Down
3 changes: 1 addition & 2 deletions src/tools/auth0/handlers/roles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export default class RolesHandler extends DefaultHandler {
...config,
type: 'roles',
id: 'id',
identifiers: ['name'],
});
}

Expand Down Expand Up @@ -190,7 +189,7 @@ export default class RolesHandler extends DefaultHandler {
handler: this,
assets: roles,
existing,
identifiers: ['id', 'name'],
identifiers: this.identifiers,
allowDelete: !!this.config('AUTH0_ALLOW_DELETE'),
});
log.debug(
Expand Down
2 changes: 1 addition & 1 deletion src/tools/auth0/handlers/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default class RulesHandler extends DefaultHandler {
handler: this,
assets: rules,
existing,
identifiers: ['id', 'name'],
identifiers: this.identifiers,
allowDelete: !!this.config('AUTH0_ALLOW_DELETE'),
});
// Figure out the rules that need to be re-ordered
Expand Down

0 comments on commit 4dc4a3c

Please sign in to comment.