5
5
#define CATCH_CONFIG_MAIN
6
6
#include " catch.hpp"
7
7
8
- #include < memory>
8
+ #include < cstdint>
9
+ #include < map>
10
+ #include < optional>
9
11
#include < sstream>
10
12
#include < string>
13
+ #include < vector>
11
14
12
- #include " config.h"
13
15
#include " main.cpp"
14
16
15
17
using namespace std ::literals::string_literals;
@@ -58,7 +60,7 @@ TEST_CASE("Test SCSI inquiry output", "[output]")
58
60
TEST_CASE (" SCSI get device encryption status output 1" , " [output]" )
59
61
{
60
62
std::map<std::uint8_t , std::string> algorithms {
61
- { 1 , " AES-256-GCM-128" s },
63
+ { 1 , " AES-256-GCM-128" s},
62
64
};
63
65
const std::uint8_t page[] {
64
66
0x00 , 0x20 , 0x00 , 0x14 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
@@ -69,14 +71,15 @@ Reading: Not decrypting\n\
69
71
Writing: Not encrypting\n \
70
72
Key instance counter: 0\n " s};
71
73
std::ostringstream oss;
72
- print_device_status (oss, reinterpret_cast <const scsi::page_des&>(page), algorithms);
74
+ print_device_status (oss, reinterpret_cast <const scsi::page_des&>(page),
75
+ algorithms);
73
76
REQUIRE (oss.str () == expected_output);
74
77
}
75
78
76
79
TEST_CASE (" SCSI get device encryption status output 2" , " [output]" )
77
80
{
78
81
std::map<std::uint8_t , std::string> algorithms {
79
- { 1 , " AES-256-GCM-128" s },
82
+ { 1 , " AES-256-GCM-128" s},
80
83
};
81
84
const std::uint8_t page[] {
82
85
0x00 , 0x20 , 0x00 , 0x24 , 0x42 , 0x02 , 0x02 , 0x01 , 0x00 , 0x00 ,
@@ -91,14 +94,15 @@ Writing: Encrypting (AES-256-GCM-128)\n\
91
94
Key instance counter: 1\n \
92
95
Drive key desc. (U-KAD): Hello world!\n " s};
93
96
std::ostringstream oss;
94
- print_device_status (oss, reinterpret_cast <const scsi::page_des&>(page), algorithms);
97
+ print_device_status (oss, reinterpret_cast <const scsi::page_des&>(page),
98
+ algorithms);
95
99
REQUIRE (oss.str () == expected_output);
96
100
}
97
101
98
102
TEST_CASE (" Test SCSI get next block encryption status output 1" , " [output]" )
99
103
{
100
104
std::map<std::uint8_t , std::string> algorithms {
101
- { 1 , " AES-256-GCM-128" s },
105
+ { 1 , " AES-256-GCM-128" s},
102
106
};
103
107
const std::uint8_t page[] {
104
108
0x00 , 0x21 , 0x00 , 0x0c , 0x00 , 0x00 , 0x00 , 0x00 ,
@@ -107,14 +111,15 @@ TEST_CASE("Test SCSI get next block encryption status output 1", "[output]")
107
111
const std::string expected_output {" \
108
112
Current block status: Not encrypted\n " s};
109
113
std::ostringstream oss;
110
- print_block_status (oss, reinterpret_cast <const scsi::page_nbes&>(page), algorithms);
114
+ print_block_status (oss, reinterpret_cast <const scsi::page_nbes&>(page),
115
+ algorithms);
111
116
REQUIRE (oss.str () == expected_output);
112
117
}
113
118
114
119
TEST_CASE (" Test SCSI get next block encryption status output 2" , " [output]" )
115
120
{
116
121
std::map<std::uint8_t , std::string> algorithms {
117
- { 1 , " AES-256-GCM-128" s },
122
+ { 1 , " AES-256-GCM-128" s},
118
123
};
119
124
const std::uint8_t page[] {
120
125
0x00 , 0x21 , 0x00 , 0x1c , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
@@ -124,14 +129,15 @@ TEST_CASE("Test SCSI get next block encryption status output 2", "[output]")
124
129
const std::string expected_output {" \
125
130
Current block status: Encrypted and able to decrypt (AES-256-GCM-128)\n " s};
126
131
std::ostringstream oss;
127
- print_block_status (oss, reinterpret_cast <const scsi::page_nbes&>(page), algorithms);
132
+ print_block_status (oss, reinterpret_cast <const scsi::page_nbes&>(page),
133
+ algorithms);
128
134
REQUIRE (oss.str () == expected_output);
129
135
}
130
136
131
137
TEST_CASE (" Test SCSI get next block encryption status output 3" , " [output]" )
132
138
{
133
139
std::map<std::uint8_t , std::string> algorithms {
134
- { 1 , " AES-256-GCM-128" s },
140
+ { 1 , " AES-256-GCM-128" s},
135
141
};
136
142
const std::uint8_t page[] {
137
143
0x00 , 0x21 , 0x00 , 0x1c , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
@@ -142,7 +148,8 @@ TEST_CASE("Test SCSI get next block encryption status output 3", "[output]")
142
148
Current block status: Encrypted, key missing or invalid (AES-256-GCM-128)\n \
143
149
Current block key desc. (U-KAD): Hello world!\n " s};
144
150
std::ostringstream oss;
145
- print_block_status (oss, reinterpret_cast <const scsi::page_nbes&>(page), algorithms);
151
+ print_block_status (oss, reinterpret_cast <const scsi::page_nbes&>(page),
152
+ algorithms);
146
153
REQUIRE (oss.str () == expected_output);
147
154
}
148
155
0 commit comments