Database System 0.1.0
Advanced C++20 Database System with Multi-Backend Support
Loading...
Searching...
No Matches
SQLInjectionTest Class Reference

Test fixture for SQL injection prevention tests. More...

Inheritance diagram for SQLInjectionTest:
Inheritance graph
Collaboration diagram for SQLInjectionTest:
Collaboration graph

Protected Member Functions

void SetUp () override
 
void TearDown () override
 

Protected Attributes

std::unique_ptr< sqlite_backenddb_
 

Detailed Description

Test fixture for SQL injection prevention tests.

Definition at line 31 of file sql_injection_test.cpp.

Member Function Documentation

◆ SetUp()

void SQLInjectionTest::SetUp ( )
inlineoverrideprotected

Definition at line 35 of file sql_injection_test.cpp.

35 {
36 db_ = std::make_unique<sqlite_backend>();
37#ifdef USE_SQLITE
38 connection_config config;
39 config.database = ":memory:";
40 ASSERT_TRUE(db_->initialize(config).is_ok());
41 ASSERT_TRUE(db_->execute_query("CREATE TABLE users ("
42 " id INTEGER PRIMARY KEY,"
43 " name TEXT,"
44 " email TEXT,"
45 " password_hash TEXT"
46 ")").is_ok());
47 // Insert test data
48 auto r1 = db_->execute_query(
49 "INSERT INTO users (id, name, email, password_hash) "
50 "VALUES (1, 'Alice', 'alice@test.com', 'hash123')"
51 );
52 ASSERT_TRUE(r1.is_ok());
53 auto r2 = db_->execute_query(
54 "INSERT INTO users (id, name, email, password_hash) "
55 "VALUES (2, 'Bob', 'bob@test.com', 'hash456')"
56 );
57 ASSERT_TRUE(r2.is_ok());
58#else
59 GTEST_SKIP() << "SQLite not available";
60#endif
61 }
std::unique_ptr< sqlite_backend > db_
Configuration for database connection.
#define ASSERT_TRUE(condition, message)

References ASSERT_TRUE, database::core::connection_config::database, and db_.

◆ TearDown()

void SQLInjectionTest::TearDown ( )
inlineoverrideprotected

Definition at line 63 of file sql_injection_test.cpp.

63 {
64 if (db_ && db_->is_initialized()) {
65 db_->shutdown();
66 }
67 }

References db_.

Member Data Documentation

◆ db_

std::unique_ptr<sqlite_backend> SQLInjectionTest::db_
protected

Definition at line 33 of file sql_injection_test.cpp.

Referenced by SetUp(), and TearDown().


The documentation for this class was generated from the following file: