Add null check before plain text password assertion bcrypt test#52
Open
TwoLettuce wants to merge 1 commit into
Open
Add null check before plain text password assertion bcrypt test#52TwoLettuce wants to merge 1 commit into
TwoLettuce wants to merge 1 commit into
Conversation
## 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.
mewilker
approved these changes
Jul 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.