address comments
Change-Id: Id12b605453752cf947c81b6cdda582d93a4d2bcf
diff --git a/tests/unit-tests/ca-memory.t.cpp b/tests/unit-tests/ca-memory.t.cpp
index 3a69e0b..290e4ca 100644
--- a/tests/unit-tests/ca-memory.t.cpp
+++ b/tests/unit-tests/ca-memory.t.cpp
@@ -39,10 +39,12 @@
auto cert1 = key1.getDefaultCertificate();
// add operation
- RequestId requestId = {{1,2,3,4,5,6,7,8}};
- std::array<uint8_t, 16> aesKey1;
- RequestState request1(Name("/ndn/site1"), requestId, RequestType::NEW,
- Status::BEFORE_CHALLENGE, cert1, std::move(aesKey1));
+ RequestId requestId = {{101}};
+ RequestState request1;
+ request1.caPrefix = Name("/ndn/site1");
+ request1.requestId = requestId;
+ request1.requestType = RequestType::NEW;
+ request1.cert = cert1;
BOOST_CHECK_NO_THROW(storage.addRequest(request1));
// get operation
@@ -53,27 +55,33 @@
BOOST_CHECK_EQUAL_COLLECTIONS(request1.encryptionKey.begin(), request1.encryptionKey.end(),
result.encryptionKey.begin(), result.encryptionKey.end());
- JsonSection json;
- json.put("code", "1234");
-
// update operation
- std::array<uint8_t, 16> aesKey2;
- RequestState request2(Name("/ndn/site1"), requestId, RequestType::NEW, Status::CHALLENGE, cert1,
- "email", "test", time::system_clock::now(), 3, time::seconds(3600),
- std::move(json), std::move(aesKey2), 0);
+ RequestState request2;
+ request2.caPrefix = Name("/ndn/site1");
+ request2.requestId = requestId;
+ request2.requestType = RequestType::NEW;
+ request2.cert = cert1;
+ request2.challengeType = "email";
+ JsonSection secret;
+ secret.add("code", "1234");
+ request2.challengeState = ChallengeState("test", time::system_clock::now(), 3,
+ time::seconds(3600), std::move(secret));
storage.updateRequest(request2);
result = storage.getRequest(requestId);
BOOST_CHECK_EQUAL(request2.cert, result.cert);
BOOST_CHECK(request2.status == result.status);
BOOST_CHECK_EQUAL(request2.caPrefix, result.caPrefix);
+ // another add operation
auto identity2 = addIdentity(Name("/ndn/site2"));
auto key2 = identity2.getDefaultKey();
auto cert2 = key2.getDefaultCertificate();
- RequestId requestId2 = {{8,7,6,5,4,3,2,1}};
- std::array<uint8_t, 16> aesKey3;
- RequestState request3(Name("/ndn/site2"), requestId2, RequestType::NEW, Status::BEFORE_CHALLENGE,
- cert2, std::move(aesKey3));
+ RequestId requestId2 = {{102}};
+ RequestState request3;
+ request3.caPrefix = Name("/ndn/site2");
+ request3.requestId = requestId2;
+ request3.requestType = RequestType::NEW;
+ request3.cert = cert2;
storage.addRequest(request3);
// list operation
diff --git a/tests/unit-tests/ca-module.t.cpp b/tests/unit-tests/ca-module.t.cpp
index b2d3300..a74db0d 100644
--- a/tests/unit-tests/ca-module.t.cpp
+++ b/tests/unit-tests/ca-module.t.cpp
@@ -467,9 +467,13 @@
signatureInfo.setValidityPeriod(security::ValidityPeriod(time::system_clock::now(),
time::system_clock::now() + time::hours(10)));
m_keyChain.sign(clientCert, signingByKey(clientKey.getName()).setSignatureInfo(signatureInfo));
- RequestId requestId = {{1,2,3,4,5,6,7,8}};
- std::array<uint8_t, 16> aesKey;
- RequestState certRequest(Name("/ndn"), requestId, RequestType::NEW, Status::SUCCESS, clientCert, std::move(aesKey));
+ RequestId requestId = {{101}};
+ RequestState certRequest;
+ certRequest.caPrefix = Name("/ndn");
+ certRequest.requestId = requestId;
+ certRequest.requestType = RequestType::NEW;
+ certRequest.status = Status::SUCCESS;
+ certRequest.cert = clientCert;
auto issuedCert = ca.issueCertificate(certRequest);
CaProfile item;
diff --git a/tests/unit-tests/ca-sqlite.t.cpp b/tests/unit-tests/ca-sqlite.t.cpp
index f0383ff..e338b63 100644
--- a/tests/unit-tests/ca-sqlite.t.cpp
+++ b/tests/unit-tests/ca-sqlite.t.cpp
@@ -38,9 +38,12 @@
auto cert1 = key1.getDefaultCertificate();
// add operation
- RequestId requestId = {{1,2,3,4,5,6,7,8}};
- std::array<uint8_t, 16> aesKey1;
- RequestState request1(Name("/ndn/site1"), requestId, RequestType::NEW, Status::BEFORE_CHALLENGE, cert1, std::move(aesKey1));
+ RequestId requestId = {{101}};
+ RequestState request1;
+ request1.caPrefix = Name("/ndn/site1");
+ request1.requestId = requestId;
+ request1.requestType = RequestType::NEW;
+ request1.cert = cert1;
storage.addRequest(request1);
// get operation
@@ -52,25 +55,32 @@
result.encryptionKey.begin(), result.encryptionKey.end());
// update operation
- JsonSection json;
- json.put("test", "4567");
- std::array<uint8_t, 16> aesKey2;
- RequestState request2(Name("/ndn/site1"), requestId, RequestType::NEW, Status::CHALLENGE, cert1,
- "email", "test", time::system_clock::now(), 3, time::seconds(3600),
- std::move(json), std::move(aesKey2), 0);
+ RequestState request2;
+ request2.caPrefix = Name("/ndn/site1");
+ request2.requestId = requestId;
+ request2.requestType = RequestType::NEW;
+ request2.cert = cert1;
+ request2.challengeType = "email";
+ JsonSection secret;
+ secret.add("code", "1234");
+ request2.challengeState = ChallengeState("test", time::system_clock::now(), 3,
+ time::seconds(3600), std::move(secret));
storage.updateRequest(request2);
result = storage.getRequest(requestId);
BOOST_CHECK_EQUAL(request2.cert, result.cert);
BOOST_CHECK(request2.status == result.status);
BOOST_CHECK_EQUAL(request2.caPrefix, result.caPrefix);
+ // another add operation
auto identity2 = addIdentity(Name("/ndn/site2"));
auto key2 = identity2.getDefaultKey();
auto cert2 = key2.getDefaultCertificate();
- RequestId requestId2 = {{8,7,6,5,4,3,2,1}};
- std::array<uint8_t, 16> aesKey3;
- RequestState request3(Name("/ndn/site2"), requestId2, RequestType::NEW,
- Status::BEFORE_CHALLENGE, cert2, std::move(aesKey3));
+ RequestId requestId2 = {{102}};
+ RequestState request3;
+ request3.caPrefix = Name("/ndn/site2");
+ request3.requestId = requestId2;
+ request3.requestType = RequestType::NEW;
+ request3.cert = cert2;
storage.addRequest(request3);
// list operation
@@ -88,20 +98,23 @@
BOOST_AUTO_TEST_CASE(DuplicateAdd)
{
- CaSqlite storage(Name(), dbDir.string() + "/TestCaSqlite_DuplicateAdd.db");
+ CaSqlite storage(Name(), dbDir.string() + "/TestCaSqlite_DuplicateAdd.db");
- auto identity1 = addIdentity(Name("/ndn/site1"));
- auto key1 = identity1.getDefaultKey();
- auto cert1 = key1.getDefaultCertificate();
+ auto identity1 = addIdentity(Name("/ndn/site1"));
+ auto key1 = identity1.getDefaultKey();
+ auto cert1 = key1.getDefaultCertificate();
- // add operation
- RequestId requestId = {{1,2,3,4,5,6,7,8}};
- std::array<uint8_t, 16> aesKey;
- RequestState request1(Name("/ndn/site1"),requestId, RequestType::NEW,
- Status::BEFORE_CHALLENGE, cert1, std::move(aesKey));
- BOOST_CHECK_NO_THROW(storage.addRequest(request1));
- // add again
- BOOST_CHECK_THROW(storage.addRequest(request1), std::runtime_error);
+ // add operation
+ RequestId requestId = {{101}};
+ RequestState request1;
+ request1.caPrefix = Name("/ndn/site1");
+ request1.requestId = requestId;
+ request1.requestType = RequestType::NEW;
+ request1.cert = cert1;
+ BOOST_CHECK_NO_THROW(storage.addRequest(request1));
+
+ // add again
+ BOOST_CHECK_THROW(storage.addRequest(request1), std::runtime_error);
}
BOOST_AUTO_TEST_SUITE_END() // TestCaModule
diff --git a/tests/unit-tests/challenge-credential.t.cpp b/tests/unit-tests/challenge-credential.t.cpp
index 03cf023..31f6b33 100644
--- a/tests/unit-tests/challenge-credential.t.cpp
+++ b/tests/unit-tests/challenge-credential.t.cpp
@@ -53,10 +53,12 @@
auto identityA = addIdentity(Name("/example"));
auto keyA = identityA.getDefaultKey();
auto certA = key.getDefaultCertificate();
- RequestId requestId = {{1,2,3,4,5,6,7,8}};
- std::array<uint8_t, 16> aesKey;
- ca::RequestState state(Name("/example"), requestId, RequestType::NEW,
- Status::BEFORE_CHALLENGE, certA, std::move(aesKey));
+ RequestId requestId = {{101}};
+ ca::RequestState state;
+ state.caPrefix = Name("/example");
+ state.requestId = requestId;
+ state.requestType = RequestType::NEW;
+ state.cert = certA;
// create requester's credential
auto identityB = addIdentity(Name("/trust/cert"));
diff --git a/tests/unit-tests/challenge-email.t.cpp b/tests/unit-tests/challenge-email.t.cpp
index 429e532..8ee9be9 100644
--- a/tests/unit-tests/challenge-email.t.cpp
+++ b/tests/unit-tests/challenge-email.t.cpp
@@ -45,9 +45,12 @@
auto identity = addIdentity(Name("/ndn/site1"));
auto key = identity.getDefaultKey();
auto cert = key.getDefaultCertificate();
- RequestId requestId = {{1,2,3,4,5,6,7,8}};
- std::array<uint8_t, 16> aesKey;
- ca::RequestState request(Name("/ndn/site1"), requestId, RequestType::NEW, Status::BEFORE_CHALLENGE, cert, std::move(aesKey));
+ RequestId requestId = {{101}};
+ ca::RequestState request;
+ request.caPrefix = Name("/ndn/site1");
+ request.requestId = requestId;
+ request.requestType = RequestType::NEW;
+ request.cert = cert;
Block paramTLV = makeEmptyBlock(tlv::EncryptedPayload);
paramTLV.push_back(makeStringBlock(tlv::ParameterKey, ChallengeEmail::PARAMETER_KEY_EMAIL));
@@ -96,9 +99,12 @@
auto identity = addIdentity(Name("/ndn/site1"));
auto key = identity.getDefaultKey();
auto cert = key.getDefaultCertificate();
- RequestId requestId = {{1,2,3,4,5,6,7,8}};
- std::array<uint8_t, 16> aesKey;
- ca::RequestState request(Name("/ndn/site1"), requestId, RequestType::NEW, Status::BEFORE_CHALLENGE, cert, std::move(aesKey));
+ RequestId requestId = {{101}};
+ ca::RequestState request;
+ request.caPrefix = Name("/ndn/site1");
+ request.requestId = requestId;
+ request.requestType = RequestType::NEW;
+ request.cert = cert;
Block paramTLV = makeEmptyBlock(tlv::EncryptedPayload);
paramTLV.push_back(makeStringBlock(tlv::ParameterKey, ChallengeEmail::PARAMETER_KEY_EMAIL));
@@ -117,13 +123,18 @@
auto identity = addIdentity(Name("/ndn/site1"));
auto key = identity.getDefaultKey();
auto cert = key.getDefaultCertificate();
- JsonSection json;
- json.put(ChallengeEmail::PARAMETER_KEY_CODE, "4567");
- RequestId requestId = {{1,2,3,4,5,6,7,8}};
- std::array<uint8_t, 16> aesKey;
- ca::RequestState request(Name("/ndn/site1"), requestId, RequestType::NEW, Status::CHALLENGE, cert,
- "email", ChallengeEmail::NEED_CODE, time::system_clock::now(),
- 3, time::seconds(3600), std::move(json), std::move(aesKey), 0);
+ JsonSection secret;
+ secret.put(ChallengeEmail::PARAMETER_KEY_CODE, "4567");
+ RequestId requestId = {{101}};
+ ca::RequestState request;
+ request.caPrefix = Name("/ndn/site1");
+ request.requestId = requestId;
+ request.requestType = RequestType::NEW;
+ request.status = Status::CHALLENGE;
+ request.cert = cert;
+ request.challengeType = "email";
+ request.challengeState = ca::ChallengeState(ChallengeEmail::NEED_CODE, time::system_clock::now(),
+ 3, time::seconds(3600), std::move(secret));
Block paramTLV = makeEmptyBlock(tlv::EncryptedPayload);
paramTLV.push_back(makeStringBlock(tlv::ParameterKey, ChallengeEmail::PARAMETER_KEY_CODE));
@@ -141,13 +152,18 @@
auto identity = addIdentity(Name("/ndn/site1"));
auto key = identity.getDefaultKey();
auto cert = key.getDefaultCertificate();
- JsonSection json;
- json.put(ChallengeEmail::PARAMETER_KEY_CODE, "4567");
- RequestId requestId = {{1,2,3,4,5,6,7,8}};
- std::array<uint8_t, 16> aesKey;
- ca::RequestState request(Name("/ndn/site1"), requestId, RequestType::NEW, Status::CHALLENGE, cert,
- "email", ChallengeEmail::NEED_CODE, time::system_clock::now(),
- 3, time::seconds(3600), std::move(json), std::move(aesKey), 0);
+ JsonSection secret;
+ secret.put(ChallengeEmail::PARAMETER_KEY_CODE, "4567");
+ RequestId requestId = {{101}};
+ ca::RequestState request;
+ request.caPrefix = Name("/ndn/site1");
+ request.requestId = requestId;
+ request.requestType = RequestType::NEW;
+ request.status = Status::CHALLENGE;
+ request.cert = cert;
+ request.challengeType = "email";
+ request.challengeState = ca::ChallengeState(ChallengeEmail::NEED_CODE, time::system_clock::now(),
+ 3, time::seconds(3600), std::move(secret));
Block paramTLV = makeEmptyBlock(tlv::EncryptedPayload);
paramTLV.push_back(makeStringBlock(tlv::ParameterKey, ChallengeEmail::PARAMETER_KEY_CODE));
diff --git a/tests/unit-tests/challenge-pin.t.cpp b/tests/unit-tests/challenge-pin.t.cpp
index f3b10d8..61167d0 100644
--- a/tests/unit-tests/challenge-pin.t.cpp
+++ b/tests/unit-tests/challenge-pin.t.cpp
@@ -38,9 +38,12 @@
auto identity = addIdentity(Name("/ndn/site1"));
auto key = identity.getDefaultKey();
auto cert = key.getDefaultCertificate();
- RequestId requestId = {{1,2,3,4,5,6,7,8}};
- std::array<uint8_t, 16> aesKey;
- ca::RequestState request(Name("/ndn/site1"), requestId, RequestType::NEW, Status::BEFORE_CHALLENGE, cert, std::move(aesKey));
+ RequestId requestId = {{101}};
+ ca::RequestState request;
+ request.caPrefix = Name("/ndn/site1");
+ request.requestId = requestId;
+ request.requestType = RequestType::NEW;
+ request.cert = cert;
ChallengePin challenge;
challenge.handleChallengeRequest(makeEmptyBlock(tlv::EncryptedPayload), request);
@@ -57,11 +60,16 @@
auto cert = key.getDefaultCertificate();
JsonSection secret;
secret.add(ChallengePin::PARAMETER_KEY_CODE, "12345");
- RequestId requestId = {{1,2,3,4,5,6,7,8}};
- std::array<uint8_t, 16> aesKey;
- ca::RequestState request(Name("/ndn/site1"), requestId, RequestType::NEW, Status::CHALLENGE, cert,
- "pin", ChallengePin::NEED_CODE, time::system_clock::now(),
- 3, time::seconds(3600), std::move(secret), std::move(aesKey), 0);
+ RequestId requestId = {{101}};
+ ca::RequestState request;
+ request.caPrefix = Name("/ndn/site1");
+ request.requestId = requestId;
+ request.requestType = RequestType::NEW;
+ request.status = Status::CHALLENGE;
+ request.cert = cert;
+ request.challengeType = "pin";
+ request.challengeState = ca::ChallengeState(ChallengePin::NEED_CODE, time::system_clock::now(),
+ 3, time::seconds(3600), std::move(secret));
Block paramTLV = makeEmptyBlock(tlv::EncryptedPayload);
paramTLV.push_back(makeStringBlock(tlv::ParameterKey, ChallengePin::PARAMETER_KEY_CODE));
@@ -81,11 +89,16 @@
auto cert = key.getDefaultCertificate();
JsonSection secret;
secret.add(ChallengePin::PARAMETER_KEY_CODE, "12345");
- RequestId requestId = {{1,2,3,4,5,6,7,8}};
- std::array<uint8_t, 16> aesKey;
- ca::RequestState request(Name("/ndn/site1"), requestId, RequestType::NEW, Status::CHALLENGE, cert,
- "pin", ChallengePin::NEED_CODE, time::system_clock::now(),
- 3, time::seconds(3600), std::move(secret), std::move(aesKey), 0);
+ RequestId requestId = {{101}};
+ ca::RequestState request;
+ request.caPrefix = Name("/ndn/site1");
+ request.requestId = requestId;
+ request.requestType = RequestType::NEW;
+ request.status = Status::CHALLENGE;
+ request.cert = cert;
+ request.challengeType = "pin";
+ request.challengeState = ca::ChallengeState(ChallengePin::NEED_CODE, time::system_clock::now(),
+ 3, time::seconds(3600), std::move(secret));
Block paramTLV = makeEmptyBlock(tlv::EncryptedPayload);
paramTLV.push_back(makeStringBlock(tlv::ParameterKey, ChallengePin::PARAMETER_KEY_CODE));
diff --git a/tests/unit-tests/protocol-encoders.t.cpp b/tests/unit-tests/protocol-encoders.t.cpp
index c69131b..5147ef9 100644
--- a/tests/unit-tests/protocol-encoders.t.cpp
+++ b/tests/unit-tests/protocol-encoders.t.cpp
@@ -147,11 +147,17 @@
caCache.load("tests/unit-tests/config-files/config-client-1");
security::Certificate certRequest = *caCache.getKnownProfiles().front().m_cert;
RequestId id = {{102}};
- std::array<uint8_t, 16> aesKey;
- std::memcpy(aesKey.data(), key, sizeof(key));
- ca::RequestState state(Name("/ndn/ucla"), id, RequestType::NEW, Status::PENDING,
- certRequest, "pin", "test", time::system_clock::now(), 3, time::seconds(321), JsonSection(),
- std::move(aesKey), 0);
+ ca::RequestState state;
+ state.caPrefix = Name("/ndn/ucla");
+ state.requestId = id;
+ state.requestType = RequestType::NEW;
+ state.status = Status::PENDING;
+ state.cert = certRequest;
+ std::memcpy(state.encryptionKey.data(), key, sizeof(key));
+ state.challengeType = "pin";
+ state.challengeState = ca::ChallengeState("test", time::system_clock::now(),
+ 3, time::seconds(3600), JsonSection());
+
auto contentBlock = challengetlv::encodeDataContent(state, Name("/ndn/ucla/a/b/c"));
requester::RequestState context(m_keyChain, caCache.getKnownProfiles().front(), RequestType::NEW);