Skip to content

Conversation

@devin-ai-integration
Copy link

@devin-ai-integration devin-ai-integration bot commented Dec 2, 2025

Summary

This PR expands authentication test coverage across the API layer by adding 26 new test cases that verify proper 401 responses for missing/invalid tokens and login failure scenarios.

Changes by file:

  • UsersApiTest.java: Added 5 login failure tests (non-existent email, empty email/password, missing fields)
  • ArticleApiTest.java: Added 4 tests for update/delete article without token or with invalid token
  • ArticlesApiTest.java: Added 2 tests for creating article without token or with invalid token
  • CommentsApiTest.java: Added 4 tests for create/delete comment without token or with invalid token
  • ArticleFavoriteApiTest.java: Added 4 tests for favorite/unfavorite without token or with invalid token
  • ProfileApiTest.java: Added 4 tests for follow/unfollow without token or with invalid token
  • CurrentUserApiTest.java: Added 3 token validation edge case tests (empty token, malformed header, token for deleted user)

All 94 tests pass locally. The CI build failure is due to a pre-existing issue with deprecated actions/cache: v2 in the GitHub Actions workflow, unrelated to these changes.

Review & Testing Checklist for Human

  • Verify the new tests follow the existing BDD-style patterns (given-when-then with RestAssuredMockMvc)
  • Confirm 401 is the correct expected status code for all authentication failure scenarios
  • Run ./gradlew test -x spotlessJava locally to verify all tests pass

Recommended test plan: Run the full test suite locally and verify the 26 new tests are included in the test count (should be 94 total tests).

Notes

- Add login failure scenario tests to UsersApiTest:
  - Test login with non-existent email
  - Test login with empty email/password
  - Test login with missing email/password fields

- Add authentication tests to ArticlesApiTest:
  - Test creating article without token (401)
  - Test creating article with invalid token (401)

- Add authentication tests to ArticleApiTest:
  - Test updating article without token (401)
  - Test updating article with invalid token (401)
  - Test deleting article without token (401)
  - Test deleting article with invalid token (401)

- Add authentication tests to CommentsApiTest:
  - Test creating comment without token (401)
  - Test creating comment with invalid token (401)
  - Test deleting comment without token (401)
  - Test deleting comment with invalid token (401)

- Add authentication tests to ArticleFavoriteApiTest:
  - Test favoriting article without token (401)
  - Test favoriting article with invalid token (401)
  - Test unfavoriting article without token (401)
  - Test unfavoriting article with invalid token (401)

- Add authentication tests to ProfileApiTest:
  - Test following user without token (401)
  - Test following user with invalid token (401)
  - Test unfollowing user without token (401)
  - Test unfollowing user with invalid token (401)

- Add token validation edge case tests to CurrentUserApiTest:
  - Test empty token string (401)
  - Test authorization header without space (401)
  - Test token referring to non-existent user (401)

Co-Authored-By: Roshan  Fernando <roshan.fernando@cognition.ai>
@devin-ai-integration
Copy link
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

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.

1 participant