Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#11878] Get by account request ID in SQL injection tests #12956

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 6 additions & 22 deletions src/it/java/teammates/it/storage/sqlapi/AccountRequestsDbIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void testSqlInjectionInCreateAccountRequestEmailField() throws Exception

// The system should treat the input as a plain text string
accountRequestDb.createAccountRequest(accountRequest);
AccountRequest actual = accountRequestDb.getAccountRequest(accountRequest.getEmail(), accountRequest.getInstitute());
AccountRequest actual = accountRequestDb.getAccountRequest(accountRequest.getId());
assertEquals(email, actual.getEmail());
}

Expand All @@ -138,7 +138,7 @@ public void testSqlInjectionInCreateAccountRequestNameField() throws Exception {

// The system should treat the input as a plain text string
accountRequestDb.createAccountRequest(accountRequest);
AccountRequest actual = accountRequestDb.getAccountRequest(accountRequest.getEmail(), accountRequest.getInstitute());
AccountRequest actual = accountRequestDb.getAccountRequest(accountRequest.getId());
assertEquals(name, actual.getName());
}

Expand All @@ -153,26 +153,10 @@ public void testSqlInjectionInCreateAccountRequestInstituteField() throws Except

// The system should treat the input as a plain text string
accountRequestDb.createAccountRequest(accountRequest);
AccountRequest actual = accountRequestDb.getAccountRequest(accountRequest.getEmail(), institute);
AccountRequest actual = accountRequestDb.getAccountRequest(accountRequest.getId());
assertEquals(institute, actual.getInstitute());
}

@Test
public void testSqlInjectionInGetAccountRequest() throws Exception {
______TS("SQL Injection test in getAccountRequest");

AccountRequest accountRequest =
new AccountRequest("[email protected]", "name", "institute", AccountRequestStatus.PENDING, "comments");
accountRequestDb.createAccountRequest(accountRequest);

String instituteInjection = "institute'; DROP TABLE account_requests; --";
AccountRequest actualInjection = accountRequestDb.getAccountRequest(accountRequest.getEmail(), instituteInjection);
assertNull(actualInjection);

AccountRequest actual = accountRequestDb.getAccountRequest(accountRequest.getEmail(), accountRequest.getInstitute());
assertEquals(accountRequest, actual);
}

@Test
public void testSqlInjectionInGetAccountRequestByRegistrationKey() throws Exception {
______TS("SQL Injection test in getAccountRequestByRegistrationKey");
Expand Down Expand Up @@ -201,7 +185,7 @@ public void testSqlInjectionInUpdateAccountRequest() throws Exception {
accountRequest.setName(nameInjection);
accountRequestDb.updateAccountRequest(accountRequest);

AccountRequest actual = accountRequestDb.getAccountRequest(accountRequest.getEmail(), accountRequest.getInstitute());
AccountRequest actual = accountRequestDb.getAccountRequest(accountRequest.getId());
assertEquals(accountRequest, actual);
}

Expand All @@ -220,7 +204,7 @@ public void testSqlInjectionInDeleteAccountRequest() throws Exception {
AccountRequestStatus.PENDING, "comments");
accountRequestDb.deleteAccountRequest(accountRequestInjection);

AccountRequest actual = accountRequestDb.getAccountRequest(accountRequest.getEmail(), accountRequest.getInstitute());
AccountRequest actual = accountRequestDb.getAccountRequest(accountRequest.getId());
assertEquals(accountRequest, actual);
}

Expand All @@ -236,7 +220,7 @@ public void testSqlInjectionSearchAccountRequestsInWholeSystem() throws Exceptio
List<AccountRequest> actualInjection = accountRequestDb.searchAccountRequestsInWholeSystem(searchInjection);
assertEquals(0, actualInjection.size());

AccountRequest actual = accountRequestDb.getAccountRequest("[email protected]", "institute");
AccountRequest actual = accountRequestDb.getAccountRequest(accountRequest.getId());
assertEquals(accountRequest, actual);
}
}
Loading