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

MG-2296 - Domain creation allowed with nil alias #2297

Merged
merged 7 commits into from
Jun 20, 2024

Conversation

JeffMboya
Copy link
Contributor

@JeffMboya JeffMboya commented Jun 18, 2024

What type of PR is this?

This is a bug fix

What does this do?

This PR modifies the alias field in the auth table to be NOT NULL and/or empty and UNIQUE. This prevents the creation of a domain with a NULL or empty alias, which was previously allowed.

Which issue(s) does this PR fix/relate to?

Have you included tests for your changes?

Yes, I have included tests for my changes.

Did you document any new/modified feature?

Notes

Signed-off-by: JeffMboya <jangina.mboya@gmail.com>
Signed-off-by: JeffMboya <jangina.mboya@gmail.com>
@JeffMboya JeffMboya marked this pull request as ready for review June 18, 2024 17:45
auth/postgres/init.go Outdated Show resolved Hide resolved
@JeffMboya JeffMboya changed the title fix: add NOT NULL constraint to alias field in auth table MG-2296 - Domain Creation Allowed with NULL Alias Jun 18, 2024
Signed-off-by: JeffMboya <jangina.mboya@gmail.com>
Signed-off-by: JeffMboya <jangina.mboya@gmail.com>
@dborovcanin dborovcanin changed the title MG-2296 - Domain Creation Allowed with NULL Alias MG-2296 - Domain Creation Allowed with nil Alias Jun 18, 2024
@dborovcanin dborovcanin changed the title MG-2296 - Domain Creation Allowed with nil Alias MG-2296 - Domain creation allowed with nil alias Jun 18, 2024
Up: []string{
`ALTER TABLE domains
ALTER COLUMN alias SET NOT NULL,
ADD CONSTRAINT alias_not_empty CHECK (alias <> '');`,
Copy link
Collaborator

@dborovcanin dborovcanin Jun 18, 2024

Choose a reason for hiding this comment

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

There is a need for this constraint. It makes sense, but for consistency with the rest of the codebase, let's have this check on API or svc layers.

Copy link
Contributor

Choose a reason for hiding this comment

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

Additonal to this constraint, we can add the this check in API Layer, where we do data validation.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Since you have added API validation, please remove it from the DB for the sake of consistency with the rest of the codebase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay

Up: []string{
`ALTER TABLE domains
ALTER COLUMN alias SET NOT NULL,
ADD CONSTRAINT alias_not_empty CHECK (alias <> '');`,
Copy link
Contributor

Choose a reason for hiding this comment

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

Additonal to this constraint, we can add the this check in API Layer, where we do data validation.

Signed-off-by: JeffMboya <jangina.mboya@gmail.com>
Signed-off-by: JeffMboya <jangina.mboya@gmail.com>
Signed-off-by: JeffMboya <jangina.mboya@gmail.com>
@dborovcanin dborovcanin merged commit ef1322b into absmach:main Jun 20, 2024
6 checks passed
andychao217 pushed a commit to andychao217/magistrala that referenced this pull request Sep 23, 2024
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.

Bug: domain creation allowed with nil alias
4 participants