aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2017-04-19 17:55:44 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2017-04-19 17:55:44 +0300
commit5050df2747d7b586dae4890efbe670d2cf584eae (patch)
treee5dc33c0f14a806e7defcad47caf05478613edcc
parentd81b21e46f325d0c12df3054fe08aa29bb1061f3 (diff)
Make challenge and fingerprint manifest values optional
-rw-r--r--bbot/manifest11
-rw-r--r--bbot/manifest.cxx27
-rw-r--r--tests/manifest/result-request.test21
-rw-r--r--tests/manifest/task-request.test40
-rw-r--r--tests/manifest/task-response.test46
5 files changed, 85 insertions, 60 deletions
diff --git a/bbot/manifest b/bbot/manifest
index 7e14b7d..3022535 100644
--- a/bbot/manifest
+++ b/bbot/manifest
@@ -60,12 +60,12 @@ namespace bbot
//
// $ cat key.pub | openssl sha256
//
- std::string fingerprint;
+ butl::optional<std::string> fingerprint;
machine_header_manifests machines;
task_request_manifest (std::string a,
- std::string f,
+ butl::optional<std::string> f,
machine_header_manifests m)
: agent (std::move (a)),
fingerprint (std::move (f)),
@@ -260,12 +260,15 @@ namespace bbot
{
public:
std::string session; // The task response session.
- std::string challenge; // The answer to challenge in the task response.
+
+ // The answer to challenge in the task response.
+ //
+ butl::optional<std::string> challenge;
result_manifest result;
result_request_manifest (std::string s,
- std::string c,
+ butl::optional<std::string> c,
result_manifest r)
: session (std::move (s)),
challenge (std::move (c)),
diff --git a/bbot/manifest.cxx b/bbot/manifest.cxx
index 9aedcea..0f7a053 100644
--- a/bbot/manifest.cxx
+++ b/bbot/manifest.cxx
@@ -244,7 +244,7 @@ namespace bbot
}
else if (n == "fingerprint")
{
- if (!fingerprint.empty ())
+ if (fingerprint)
bad_name ("task request fingerprint redefinition");
if (!valid_sha256 (v))
@@ -261,9 +261,6 @@ namespace bbot
if (agent.empty ())
bad_value ("no task request agent specified");
- if (fingerprint.empty ())
- bad_value ("no task request fingerprint specified");
-
// Parse machine header manifests.
//
for (nv = p.next (); !nv.empty (); nv = p.next ())
@@ -281,7 +278,10 @@ namespace bbot
//
s.next ("", "1"); // Start of manifest.
s.next ("agent", agent);
- s.next ("fingerprint", fingerprint);
+
+ if (fingerprint)
+ s.next ("fingerprint", *fingerprint);
+
s.next ("", ""); // End of manifest.
for (const machine_header_manifest& m: machines)
@@ -594,14 +594,11 @@ namespace bbot
session = move (*sess);
- // If session is not empty then the challenge and the result url must
- // present, otherwise they shouldn't.
+ // If session is not empty then the challenge may, and the result url
+ // must, be present, otherwise they shouldn't.
//
if (!session.empty ())
{
- if (!challenge)
- bad_value ("no task response challenge specified");
-
if (!result_url)
bad_value ("no task response result url specified");
}
@@ -908,7 +905,7 @@ namespace bbot
}
else if (n == "challenge")
{
- if (!challenge.empty ())
+ if (challenge)
bad_name ("result request challenge redefinition");
if (v.empty ())
@@ -925,9 +922,6 @@ namespace bbot
if (session.empty ())
bad_value ("no result request session specified");
- if (challenge.empty ())
- bad_value ("no result request challenge specified");
-
nv = p.next ();
if (nv.empty ())
bad_value ("result manifest expected");
@@ -950,7 +944,10 @@ namespace bbot
//
s.next ("", "1"); // Start of manifest.
s.next ("session", session);
- s.next ("challenge", challenge);
+
+ if (challenge)
+ s.next ("challenge", *challenge);
+
s.next ("", ""); // End of manifest.
result.serialize (s);
diff --git a/tests/manifest/result-request.test b/tests/manifest/result-request.test
index 8cf64b9..3e1e08c 100644
--- a/tests/manifest/result-request.test
+++ b/tests/manifest/result-request.test
@@ -9,6 +9,8 @@ test.options += -rq
: Roundtrip the result request manifest.
:
{
+ : all-values
+ :
$* <<EOF >>EOF
: 1
session: abcd
@@ -18,6 +20,18 @@ test.options += -rq
version: 1.0
status: error
EOF
+
+ : no-challenge
+ :
+ $* <<EOF >>EOF
+ : 1
+ session: abcd
+ :
+ name: libfoo
+ version: 1.0
+ status: error
+ EOF
+
}
: redefinition
@@ -75,13 +89,6 @@ EOI
challenge: xyz
EOI
- : challenge
- :
- $* <<EOI 2>'stdin:3:1: error: no result request challenge specified' == 1
- : 1
- session: abc
- EOI
-
: result
:
$* <<EOI 2>'stdin:4:1: error: result manifest expected' == 1
diff --git a/tests/manifest/task-request.test b/tests/manifest/task-request.test
index 135dc8d..157b2ea 100644
--- a/tests/manifest/task-request.test
+++ b/tests/manifest/task-request.test
@@ -8,15 +8,30 @@ test.options += -tq
:
: Roundtrip the task request manifest.
:
-$* <<EOF >>EOF
-: 1
-agent: upsa
-fingerprint: 1105fb394ee870adb154b7abfbbae5755df7dcef6c81db34e8d1b68d2653734e
-:
-id: a2b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
-name: windows_10-msvc_14
-summary: Windows 10 build 1607 with VC 14 update 3
-EOF
+{
+ : all-values
+ :
+ $* <<EOF >>EOF
+ : 1
+ agent: upsa
+ fingerprint: 1105fb394ee870adb154b7abfbbae5755df7dcef6c81db34e8d1b68d2653734e
+ :
+ id: a2b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
+ name: windows_10-msvc_14
+ summary: Windows 10 build 1607 with VC 14 update 3
+ EOF
+
+ : no-fingerprint
+ :
+ $* <<EOF >>EOF
+ : 1
+ agent: upsa
+ :
+ id: a2b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
+ name: windows_10-msvc_14
+ summary: Windows 10 build 1607 with VC 14 update 3
+ EOF
+}
: redefinition
:
@@ -65,13 +80,6 @@ EOI
: 1
fingerprint: 1105fb394ee870adb154b7abfbbae5755df7dcef6c81db34e8d1b68d2653734e
EOI
-
- : fingerprint
- :
- $* <<EOI 2>'stdin:3:1: error: no task request fingerprint specified' == 1
- : 1
- agent: upsa
- EOI
}
: no-machines
diff --git a/tests/manifest/task-response.test b/tests/manifest/task-response.test
index 22bdded..25a76f1 100644
--- a/tests/manifest/task-response.test
+++ b/tests/manifest/task-response.test
@@ -11,17 +11,34 @@ test.options += -ts
{
: session-not-empty
:
- $* <<EOF >>EOF
- : 1
- session: abcd
- challenge: xyz
- result-url: https://cppget.org/?build-result
- :
- name: libfoo
- version: 1.0
- repository: http://pkg.example.org/1/math
- machine: windows_10-msvc_14
- EOF
+ {
+ : all-values
+ :
+ $* <<EOF >>EOF
+ : 1
+ session: abcd
+ challenge: xyz
+ result-url: https://cppget.org/?build-result
+ :
+ name: libfoo
+ version: 1.0
+ repository: http://pkg.example.org/1/math
+ machine: windows_10-msvc_14
+ EOF
+
+ : no-challenge
+ :
+ $* <<EOF >>EOF
+ : 1
+ session: abcd
+ result-url: https://cppget.org/?build-result
+ :
+ name: libfoo
+ version: 1.0
+ repository: http://pkg.example.org/1/math
+ machine: windows_10-msvc_14
+ EOF
+ }
: session-empty
:
@@ -125,13 +142,6 @@ EOI
: 1
EOI
- : challenge
- :
- $* <<EOI 2>'stdin:3:1: error: no task response challenge specified' == 1
- : 1
- session: abc
- EOI
-
: result-url
:
$* <<EOI 2>'stdin:4:1: error: no task response result url specified' == 1