Skip to content

Test/auth signup validation#16

Closed
RahulHarihar wants to merge 4 commits into
code-a2z:masterfrom
RahulHarihar:test/auth-signup-validation
Closed

Test/auth signup validation#16
RahulHarihar wants to merge 4 commits into
code-a2z:masterfrom
RahulHarihar:test/auth-signup-validation

Conversation

@RahulHarihar
Copy link
Copy Markdown
Contributor

Description

Added tests to handle edge cases in user signup. Specifically:

  • Reject signup attempts with an existing email.
  • Reject signup when email or password is missing.
  • Updated validateRegistration middleware to check for empty fields first.

All signup validation tests now pass, while production email, domain, and password validations remain intact.

Related Issue

Fixes #7

Motivation and Context

To prevent duplicate user accounts and ensure robust input validation during registration. These tests improve security, data integrity, and alignment between backend behaviour and test expectations.

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Enhancement (improvement to an existing feature)
  • Test (adds or updates tests only)
  • Documentation (non-code change)

How Has This Been Tested?

  • Ran all authentication tests (auth.test.js) locally.
  • Verified that:
    • Duplicate email returns "User already exists".
    • Missing email/password returns "Please enter all fields".
    • New valid user signup still succeeds.

Screenshots (if applicable):

N/A

Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have added tests to cover my changes
  • All new and existing tests passed

@archa8
Copy link
Copy Markdown
Member

archa8 commented Sep 29, 2025

Hi @RahulHarihar ,
Thanks for your work on this.
I've looked at the pull request, and the changes you made in __tests__/auth.test.js, config/db.js and middleware/validationMiddleware.js look great! However, I'm seeing things like tab spaces being adjusted and single quotes in imports being changed to double quotes in many files, including the three mentioned before. This adds a lot of noise to the PR which makes it difficult review the actual test.
Could you please submit a new pull request that contains only the essential code changes?

@archa8 archa8 closed this Sep 29, 2025
@RahulHarihar
Copy link
Copy Markdown
Contributor Author

Hey @archa8,
Thanks for taking the time to review my PR! I see what you mean about the formatting changes creating extra noise. I’ll clean it up and submit a new PR with just the essential code changes.

Really appreciate your feedback!

@RahulHarihar RahulHarihar mentioned this pull request Oct 1, 2025
11 tasks
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.

test: User signup with an existing email

2 participants