-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DXCDT-84: Resource Exclusion #468
Conversation
@@ -78,14 +78,17 @@ export default class DirectoryContext { | |||
// Copy clients to be used by handlers which require converting client_id to the name | |||
// Must copy as the client_id will be stripped if AUTH0_EXPORT_IDENTIFIERS is false | |||
//@ts-ignore because assets haven't been typed yet TODO: type assets | |||
this.assets.clientsOrig = [...this.assets.clients]; | |||
this.assets.clientsOrig = [...this.assets.clients || []]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clients could theoretically be excluded and thus be empty so need to default to empty array.
|
||
// Optionally Strip identifiers | ||
if (!this.config.AUTH0_EXPORT_IDENTIFIERS) { | ||
this.assets = stripIdentifiers(auth0, this.assets); | ||
} | ||
|
||
await Promise.all(Object.entries(handlers).map(async ([name, handler]) => { | ||
await Promise.all(Object.entries(handlers).filter(([handlerName]: [AssetTypes, DirectoryHandler<any>]) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This array filter function is the primary mechanism for exclusion.
✏️ Changes
Introducing the initial implementation for resource exclusion. As proposed in #451 , this provides a mechanism for users to ignore entire resource types (organizations, connections, hooks, etc.). This mechanism functions bi-directionally and will completely omit all resources from being fetched, written to config-as-code and updating.
In practice, users will add a
AUTH0_EXCLUDED
property to their user-defined configuration file and list the resource types they wish to exclude from the purview of the tool.Example:
The approach here is fairly naive but effective. Not all permutations of exclusions have been tested and because of inter-dependencies between resources, exclusions may lead to unexpected behavior. But it's expected to function under the vast majority of use cases.
🔗 References
🎯 Testing
I fought with the existing unit tests and was only able to add a unit test to the Auth0 class side. This test asserts that no excluded resources get fetched or pushed to Auth0. However, I had difficulty implementing
Regardless, this being a fairly wide-reaching concept, it probably isn't appropriate to unit test. Instead, we should have a broader set of integration that can better assert the behavior of this functionality.
Regardless, plenty of manual test were done on this to confirm that this works for both YAML and directory config types, and varying permutations of this configuration.