aboutsummaryrefslogtreecommitdiff
path: root/bbot/manifest.cxx
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 /bbot/manifest.cxx
parentd81b21e46f325d0c12df3054fe08aa29bb1061f3 (diff)
Make challenge and fingerprint manifest values optional
Diffstat (limited to 'bbot/manifest.cxx')
-rw-r--r--bbot/manifest.cxx27
1 files changed, 12 insertions, 15 deletions
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);