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

Added check for active search service in account request search test #1

Merged
merged 3 commits into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
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
15 changes: 0 additions & 15 deletions src/it/java/teammates/it/storage/sqlapi/AccountRequestsDbIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,19 +237,4 @@ public void testSqlInjectionInDeleteAccountRequest() throws Exception {
assertEquals(accountRequest, actual);
}

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

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

String searchInjection = "institute'; DROP TABLE account_requests; --";
List<AccountRequest> actualInjection = accountRequestDb.searchAccountRequestsInWholeSystem(searchInjection);
assertEquals(0, actualInjection.size());

AccountRequest actual = accountRequestDb.getAccountRequest(accountRequest.getId());
assertEquals(accountRequest, actual);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,25 @@ public void testSearchAccountRequest_noSearchService_shouldThrowException() {
() -> accountRequestsDb.searchAccountRequestsInWholeSystem("anything"));
}

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

if (!TestProperties.isSearchServiceActive()) {
return;
}

AccountRequest accountRequest = new AccountRequest("[email protected]", "name", "institute");
accountRequestsDb.createAccountRequest(accountRequest);

String searchInjection = "institute'; DROP TABLE account_requests; --";
List<AccountRequest> actualInjection = accountRequestsDb.searchAccountRequestsInWholeSystem(searchInjection);
assertEquals(typicalBundle.accountRequests.size(), actualInjection.size());

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

/**
* Verifies that search results match with expected output.
*
Expand Down
Loading