-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -155,6 +155,21 @@ public void testSqlInjectionInCreateAccountRequestInstituteField() throws Except | |
assertEquals(institute, actual.getInstitute()); | ||
} | ||
|
||
@Test | ||
public void testSqlInjectionInCreateAccountRequestCommentsField() throws Exception { | ||
______TS("SQL Injection test in comments field"); | ||
|
||
// Attempt to use SQL commands in comments field | ||
String comments = "comment'; DROP TABLE account_requests; --"; | ||
AccountRequest accountRequest = | ||
new AccountRequest("[email protected]", "name", "institute", AccountRequestStatus.PENDING, comments); | ||
|
||
// The system should treat the input as a plain text string | ||
accountRequestDb.createAccountRequest(accountRequest); | ||
AccountRequest actual = accountRequestDb.getAccountRequest(accountRequest.getId()); | ||
assertEquals(comments, actual.getComments()); | ||
} | ||
|
||
@Test | ||
public void testSqlInjectionInGetAccountRequestByRegistrationKey() throws Exception { | ||
______TS("SQL Injection test in getAccountRequestByRegistrationKey"); | ||
|
@@ -171,6 +186,22 @@ public void testSqlInjectionInGetAccountRequestByRegistrationKey() throws Except | |
assertEquals(accountRequest, actual); | ||
} | ||
|
||
@Test | ||
public void testSqlInjectionInGetApprovedAccountRequestsForEmail() throws Exception { | ||
______TS("SQL Injection test in getApprovedAccountRequestsForEmail"); | ||
|
||
String email = "[email protected]"; | ||
AccountRequest accountRequest = | ||
new AccountRequest(email, "name", "institute", AccountRequestStatus.APPROVED, "comments"); | ||
accountRequestDb.createAccountRequest(accountRequest); | ||
|
||
// Attempt to use SQL commands in email field | ||
String emailInjection = "email'/**/OR/**/1=1/**/@gmail.com"; | ||
List<AccountRequest> actualInjection = accountRequestDb.getApprovedAccountRequestsForEmail(emailInjection); | ||
// The system should treat the input as a plain text string | ||
assertEquals(0, actualInjection.size()); | ||
} | ||
|
||
@Test | ||
public void testSqlInjectionInUpdateAccountRequest() throws Exception { | ||
______TS("SQL Injection test in updateAccountRequest"); | ||
|