Skip to content

Add null check before plain text password assertion bcrypt test#52

Open
TwoLettuce wants to merge 1 commit into
mainfrom
bcrypt-test-null-safety
Open

Add null check before plain text password assertion bcrypt test#52
TwoLettuce wants to merge 1 commit into
mainfrom
bcrypt-test-null-safety

Conversation

@TwoLettuce

@TwoLettuce TwoLettuce commented Jul 21, 2026

Copy link
Copy Markdown

Issue

A student was having trouble finding out why his bcrypt test was failing due to a NullPointerException on line 169 of the DatabaseTests.java file for phase 4. After inspecting his tables during execution and finding that the plain-text password was not being stored anywhere in the database, I looked closer at the test code and noticed that the values read from the database were assumed to be non-null.

Under normal conditions, this would not be a problem, since the only data that should exist is the new UserData created by the register endpoint. However, since this student's clearGames function wasn't correctly clearing his games table, there was still a game in the database with null values for whiteUsername and blackUsername. Thus, the ResultSet.getString() method returned null, causing the String.contains method to result in a NullPointerException.

Solution

A simple null-pointer check will help students isolate this error to tests that actually deal with having the games table function correctly. This test will now only fail if there are issues with database setup or if the student is storing plain-text passwords.

## Issue
A student was having trouble finding out why his bcrypt test was failing due to a NullPointerException on line 167 of the DatabaseTests.java file for phase 4. After inspecting his tables during execution and finding that the plain-text password was not being stored anywhere in the database, I looked closer at the test code and noticed that the values read from the database were assumed to be non-null. 

Under normal conditions, this would not be a problem, since the only data that should exist is the new UserData created by the register endpoint. However, since this student's clearGames function wasn't correctly clearing his games table, there was still a game in the database with null values for whiteUsername and blackUsername. Thus, the ResultSet.getString() method returned null, causing the String.contains method to result in a NullPointerException.

## Solution
A simple null-pointer check will help students isolate this error to tests that actually deal with having the games table function correctly. This test will now only fail if there are issues with database setup or if the student is storing plain-text passwords.
@TwoLettuce
TwoLettuce requested a review from Copilot July 21, 2026 22:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@TwoLettuce
TwoLettuce requested a review from a team July 21, 2026 22:19
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.

3 participants