Skip to content
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

Allow dashes in user urn #1564

Merged
merged 3 commits into from
Feb 21, 2020
Merged

Allow dashes in user urn #1564

merged 3 commits into from
Feb 21, 2020

Conversation

ben5448
Copy link
Contributor

@ben5448 ben5448 commented Feb 18, 2020

fix: allow dashes in user urn

Dashes are accepted in user urns for the CorpUserInfo documents. In the MAE
consumer for ownership facets, the owner urn is validated using a regex that
only accepts alphanumeric characters and underscores. If the owner's urn
contains a dash, that update triggers an error.

This fix: relax regex validation to allow a dash as a valid character in the urn.
Unit tests changes match verify the new filter and verify the filter allows
multiple dashes or underscores. No attempt is made for force the first or
last characters to be alphanumeric or to allow other characters.

CLOSES: User urn does not handle dashes consistently #1554

BREAKING CHANGES: None. This change relaxes a constraint so all existing
code should continue to work the same.

ben5448 and others added 2 commits February 18, 2020 09:16
Update to lateest version of DataHub
CorpUserInfo urns containing dashes are valid entries. When adding that user as an
owner, the mae job validates the owner's urn using a regex filter that only accepts
alphanumeric characters and underscore (\w). That means any ownership changes where
the user urn contains an underscore are rejected.

This change extends the regex filter to allow dashes in the name. It includes unit
tests that verify the change works for multiple dashes and underscores.

There are other cases to consider:

1. Should any other characters be allowed?
2. Should the filter check the urn starts and ends with alphanumeric characters?

CLOSES: User urn does not handle dashes consistently #1554

BREAKING CHANGE: None. This change relaxes a restriction so existing code is ok.
@@ -24,9 +24,11 @@ public void testGetCorpUserOwners() {
Owner owner1 = new Owner().setOwner(new CorpuserUrn("t1"));
Owner owner2 = new Owner().setOwner(new CorpuserUrn("t2"));
Owner owner3 = new Owner().setOwner(new CorpGroupUrn("t3"));
List<Owner> owners = Arrays.asList(owner1, owner2, owner3);
Owner owner4 = new Owner().setOwner(new CorpGroupUrn("t-4-t"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe change this to CorpuserUrn to test both urn types?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added tests or urn and groups. Adjusted the results to match what should be the correct values. These tests do not appear to run when building the project though. All the unit tests report success regardless of the data entered here. The tests are built, just not run.

ownership.setOwners(new OwnerArray(owners));
assertEquals(BuilderUtils.getCorpUserOwners(ownership), Arrays.asList("t1", "t2"));
assertEquals(BuilderUtils.getCorpUserOwners(ownership), Arrays.asList("t1", "t2", "t3", "t-4-t", "t_5_t"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getCorpUserOwners should only return owners which are users not groups. I'm really curious how this test passed 😮

Copy link
Contributor Author

@ben5448 ben5448 Feb 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking through the logs, I can't tell that these tests are getting executed. I see lots of other tests being executed, but this assertion does not fire no matter what values are in the list.

The problem with the test not running seems like a different issue. I corrected the test results, but not sure what triggers the test execution or why this test is not firing.

@keremsahin1
Copy link
Contributor

@ben5448 Thanks for this PR. It helped me figure out an underlying issue with some modules not being tested at all. I'll push the fix soon. I will just accept this now.

@keremsahin1 keremsahin1 merged commit d09cedc into datahub-project:master Feb 21, 2020
@ben5448 ben5448 deleted the allow-dashes-in-user-urn branch March 2, 2020 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants