|
Database System 0.1.0
Advanced C++20 Database System with Multi-Backend Support
|
#include <gtest/gtest.h>#include <memory>#include <string>#include <vector>#include "database/query_builder.h"#include "database/backends/sqlite_backend.h"#include "database/core/database_backend.h"
Go to the source code of this file.
Classes | |
| class | SQLInjectionTest |
| Test fixture for SQL injection prevention tests. More... | |
Functions | |
| TEST_F (SQLInjectionTest, BasicInjectionAttempt) | |
| Tests that basic OR injection is properly escaped. | |
| TEST_F (SQLInjectionTest, CommentInjectionAttempt) | |
| Tests that comment-based injection is handled. | |
| TEST_F (SQLInjectionTest, BatchStatementInjectionAttempt) | |
| Tests that batch statement injection is prevented. | |
| TEST_F (SQLInjectionTest, UnionInjectionAttempt) | |
| Tests that UNION-based injection is prevented. | |
| TEST_F (SQLInjectionTest, ApostropheInValueSafe) | |
| Tests that apostrophes in values are properly handled. | |
| TEST_F (SQLInjectionTest, SpecialCharactersInValue) | |
| Tests handling of various special characters. | |
| TEST_F (SQLInjectionTest, NumericValueInjection) | |
| Tests that numeric value fields handle string injection. | |
| TEST_F (SQLInjectionTest, BooleanValueHandling) | |
| Tests that boolean values are handled safely. | |
| TEST_F (SQLInjectionTest, PreparedSelectReturnsCorrectResults) | |
| Tests that prepared SELECT queries bind parameters correctly. | |
| TEST_F (SQLInjectionTest, PreparedSelectBlocksInjection) | |
| Tests that prepared statements prevent SQL injection at wire level. | |
| TEST_F (SQLInjectionTest, PreparedExecuteWithTypedParams) | |
| Tests that execute_prepared handles typed parameters. | |
| TEST_F (SQLInjectionTest, PreparedBatchStatementInjectionBlocked) | |
| Tests that prepared statements block batch statement injection. | |
| TEST_F (SQLInjectionTest, PreparedNullParameterHandling) | |
| Tests that NULL parameters bind correctly in prepared statements. | |
| TEST_F (SQLInjectionTest, ResetPreventsDataLeakage) | |
| Tests that reset() properly clears all builder state. | |
| TEST_F (SQLInjectionTest, UnicodeBypassAttempt) | |
| Tests handling of Unicode characters that might bypass filters. | |
| TEST_F | ( | SQLInjectionTest | , |
| ApostropheInValueSafe | ) |
Tests that apostrophes in values are properly handled.
Input: O'Brien (legitimate name) Expected: Query executes safely with escaped apostrophe
Definition at line 227 of file sql_injection_test.cpp.
References database::query_builder::build(), database::query_builder::select(), and database::query_builder::where().

| TEST_F | ( | SQLInjectionTest | , |
| BasicInjectionAttempt | ) |
Tests that basic OR injection is properly escaped.
Attack: ' OR '1'='1 Expected: Query treats input as literal string, returns 0 rows
Definition at line 81 of file sql_injection_test.cpp.
References database::query_builder::build(), database::query_builder::select(), and database::query_builder::where().

| TEST_F | ( | SQLInjectionTest | , |
| BatchStatementInjectionAttempt | ) |
Tests that batch statement injection is prevented.
Attack: '; DROP TABLE users; – Expected: Table should still exist after query
Definition at line 141 of file sql_injection_test.cpp.
References database::query_builder::build(), database::query_builder::select(), and database::query_builder::where().

| TEST_F | ( | SQLInjectionTest | , |
| BooleanValueHandling | ) |
Tests that boolean values are handled safely.
Definition at line 330 of file sql_injection_test.cpp.
References database::query_builder::build(), database::query_builder::select(), and database::query_builder::where().

| TEST_F | ( | SQLInjectionTest | , |
| CommentInjectionAttempt | ) |
Tests that comment-based injection is handled.
Attack: admin'– Expected: Query treats input as literal string
Definition at line 112 of file sql_injection_test.cpp.
References database::query_builder::build(), database::query_builder::select(), and database::query_builder::where().

| TEST_F | ( | SQLInjectionTest | , |
| NumericValueInjection | ) |
Tests that numeric value fields handle string injection.
Definition at line 305 of file sql_injection_test.cpp.
References database::query_builder::build(), database::query_builder::select(), and database::query_builder::where().

| TEST_F | ( | SQLInjectionTest | , |
| PreparedBatchStatementInjectionBlocked | ) |
Tests that prepared statements block batch statement injection.
Definition at line 428 of file sql_injection_test.cpp.
References ASSERT_TRUE.
| TEST_F | ( | SQLInjectionTest | , |
| PreparedExecuteWithTypedParams | ) |
Tests that execute_prepared handles typed parameters.
Definition at line 399 of file sql_injection_test.cpp.
References ASSERT_EQ, and ASSERT_TRUE.
| TEST_F | ( | SQLInjectionTest | , |
| PreparedNullParameterHandling | ) |
Tests that NULL parameters bind correctly in prepared statements.
Definition at line 448 of file sql_injection_test.cpp.
References ASSERT_TRUE.
| TEST_F | ( | SQLInjectionTest | , |
| PreparedSelectBlocksInjection | ) |
Tests that prepared statements prevent SQL injection at wire level.
Definition at line 380 of file sql_injection_test.cpp.
References ASSERT_TRUE.
| TEST_F | ( | SQLInjectionTest | , |
| PreparedSelectReturnsCorrectResults | ) |
Tests that prepared SELECT queries bind parameters correctly.
Definition at line 358 of file sql_injection_test.cpp.
References ASSERT_EQ, and ASSERT_TRUE.
| TEST_F | ( | SQLInjectionTest | , |
| ResetPreventsDataLeakage | ) |
Tests that reset() properly clears all builder state.
Definition at line 470 of file sql_injection_test.cpp.
References database::query_builder::build(), database::query_builder::reset(), database::query_builder::select(), and database::query_builder::where().

| TEST_F | ( | SQLInjectionTest | , |
| SpecialCharactersInValue | ) |
Tests handling of various special characters.
Definition at line 263 of file sql_injection_test.cpp.
References database::query_builder::build(), database::query_builder::select(), and database::query_builder::where().

| TEST_F | ( | SQLInjectionTest | , |
| UnicodeBypassAttempt | ) |
Tests handling of Unicode characters that might bypass filters.
Definition at line 501 of file sql_injection_test.cpp.
References database::query_builder::build(), database::query_builder::select(), and database::query_builder::where().

| TEST_F | ( | SQLInjectionTest | , |
| UnionInjectionAttempt | ) |
Tests that UNION-based injection is prevented.
Attack: ' UNION SELECT * FROM sensitive_data – Expected: Query should not execute UNION
Definition at line 175 of file sql_injection_test.cpp.
References database::query_builder::build(), database::query_builder::select(), and database::query_builder::where().
