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

feat: input validation for resource creation #83

Merged
merged 11 commits into from
Apr 29, 2024

Conversation

caproven
Copy link
Collaborator

@caproven caproven commented Feb 15, 2024

Centralize resource creation logic & add basic input validation.

Issues this PR fixes:

  • inconsistent logging between graph & rest
  • parity between inputs for graph & rest resource creation
    • ex. graph let you specify group enabled/disabled, whereas rest always set as enabled
  • can no longer specify unintended fields in rest such as createdAt or fingerprint
  • receiver creation through graph lacked schema validation
  • string/id fields cannot be blank (including whitespace, inputs trimmed)
  • groups need at least one receiver id

E2e tests are closer to passing, now the only failures should be:

  • TestCreateInvalidGroup/non-existent_receiver - creating group with invalid receiver yields 5xx response instead of 4xx. This happens because there's no code checks, only a failed foreign key constraint from the db layer
  • TestToggleGroup - UpdatedAt field never updated. Gorm should do this automatically but is "broken" by us using types besides time.Time (we use a custom graph scalar)

Closes #70

ninjamast3r
ninjamast3r previously approved these changes Mar 15, 2024
Copy link
Collaborator

@ninjamast3r ninjamast3r left a comment

Choose a reason for hiding this comment

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

Looks ok to me. Might want a second opinion since I've been out of the loop for a while.

@xbcsmith xbcsmith merged commit 61a577b into sassoftware:main Apr 29, 2024
3 checks passed
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.

input validation for resource creation
3 participants