@@ -18,6 +18,13 @@ using namespace mozilla::pkix;
1818using namespace mozilla ::pkix::test;
1919using namespace mozilla ::psm;
2020
21+ template <size_t N>
22+ inline Input
23+ LiteralInput (const char (&valueString)[N])
24+ {
25+ return Input (reinterpret_cast <const uint8_t (&)[N - 1 ]>(valueString));
26+ }
27+
2128const int MaxCacheEntries = 1024 ;
2229
2330class OCSPCacheTest : public ::testing::Test
@@ -54,15 +61,15 @@ PutAndGet(OCSPCache& cache, const CertID& certID, Result result,
5461 ASSERT_EQ (time, timeOut);
5562}
5663
57- TestInput fakeIssuer1 (" CN=issuer1" );
58- TestInput fakeKey000 (" key000" );
59- TestInput fakeKey001 (" key001" );
60- TestInput fakeSerial0000 (" 0000" );
64+ Input fakeIssuer1 (LiteralInput( " CN=issuer1" ) );
65+ Input fakeKey000 (LiteralInput( " key000" ) );
66+ Input fakeKey001 (LiteralInput( " key001" ) );
67+ Input fakeSerial0000 (LiteralInput( " 0000" ) );
6168
6269TEST_F (OCSPCacheTest, TestPutAndGet)
6370{
64- TestInput fakeSerial000 (" 000" );
65- TestInput fakeSerial001 (" 001" );
71+ Input fakeSerial000 (LiteralInput ( " 000" ) );
72+ Input fakeSerial001 (LiteralInput ( " 001" ) );
6673
6774 SCOPED_TRACE (" " );
6875 PutAndGet (cache, CertID (fakeIssuer1, fakeKey000, fakeSerial001),
@@ -105,7 +112,7 @@ TEST_F(OCSPCacheTest, TestVariousGets)
105112 Time timeInPlus512 (now);
106113 ASSERT_EQ (Success, timeInPlus512.AddSeconds (512 ));
107114
108- static const TestInput fakeSerial0512 (" 0512" );
115+ static const Input fakeSerial0512 (LiteralInput ( " 0512" ) );
109116 CertID cert0512 (fakeIssuer1, fakeKey000, fakeSerial0512);
110117 ASSERT_TRUE (cache.Get (cert0512, resultOut, timeOut));
111118 ASSERT_EQ (Success, resultOut);
@@ -115,7 +122,7 @@ TEST_F(OCSPCacheTest, TestVariousGets)
115122 ASSERT_EQ (timeInPlus512, timeOut);
116123
117124 // We've never seen this certificate
118- static const TestInput fakeSerial1111 (" 1111" );
125+ static const Input fakeSerial1111 (LiteralInput ( " 1111" ) );
119126 ASSERT_FALSE (cache.Get (CertID (fakeIssuer1, fakeKey000, fakeSerial1111),
120127 resultOut, timeOut));
121128}
@@ -166,7 +173,7 @@ TEST_F(OCSPCacheTest, TestNoEvictionForRevokedResponses)
166173 ASSERT_EQ (Result::ERROR_REVOKED_CERTIFICATE , resultOut);
167174 ASSERT_EQ (timeIn, timeOut);
168175
169- TestInput fakeSerial0001 (" 0001" );
176+ Input fakeSerial0001 (LiteralInput ( " 0001" ) );
170177 CertID evicted (fakeIssuer1, fakeKey000, fakeSerial0001);
171178 ASSERT_FALSE (cache.Get (evicted, resultOut, timeOut));
172179}
@@ -186,7 +193,7 @@ TEST_F(OCSPCacheTest, TestEverythingIsRevoked)
186193 PutAndGet (cache, CertID (fakeIssuer1, fakeKey000, fakeSerial),
187194 Result::ERROR_REVOKED_CERTIFICATE , timeIn);
188195 }
189- static const TestInput fakeSerial1025 (" 1025" );
196+ static const Input fakeSerial1025 (LiteralInput ( " 1025" ) );
190197 CertID good (fakeIssuer1, fakeKey000, fakeSerial1025);
191198 // This will "succeed", allowing verification to continue. However,
192199 // nothing was actually put in the cache.
@@ -201,7 +208,7 @@ TEST_F(OCSPCacheTest, TestEverythingIsRevoked)
201208 Time timeOut (Time::uninitialized);
202209 ASSERT_FALSE (cache.Get (good, resultOut, timeOut));
203210
204- static const TestInput fakeSerial1026 (" 1026" );
211+ static const Input fakeSerial1026 (LiteralInput ( " 1026" ) );
205212 CertID revoked (fakeIssuer1, fakeKey000, fakeSerial1026);
206213 // This will fail, causing verification to fail.
207214 Time timeInPlus1026 (timeIn);
@@ -217,8 +224,8 @@ TEST_F(OCSPCacheTest, VariousIssuers)
217224{
218225 SCOPED_TRACE (" " );
219226 Time timeIn (now);
220- static const TestInput fakeIssuer2 (" CN=issuer2" );
221- static const TestInput fakeSerial001 (" 001" );
227+ static const Input fakeIssuer2 (LiteralInput ( " CN=issuer2" ) );
228+ static const Input fakeSerial001 (LiteralInput ( " 001" ) );
222229 CertID subject (fakeIssuer1, fakeKey000, fakeSerial001);
223230 PutAndGet (cache, subject, Success, now);
224231 Result resultOut;
0 commit comments