feat(clients): bedrock: SigV4 signer, Converse, event streams, guardrails, agents, KB, batch
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
// Routes: GET /ai/bedrock (page), /status, /calls (no credential needed)
|
||||
#include <cstdlib>
|
||||
|
||||
#include "support/Assert.hpp"
|
||||
|
||||
using namespace molo::example::test;
|
||||
|
||||
int main() {
|
||||
setenv("MOLO_ENV_FILES", "off", 1);
|
||||
for (const char* v : {"AWS_BEARER_TOKEN_BEDROCK", "AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN", "AWS_REGION", "AWS_DEFAULT_REGION"})
|
||||
unsetenv(v);
|
||||
Fixture f;
|
||||
auto page = f.client->get("/ai/bedrock");
|
||||
check(page.status == 200, "page 200");
|
||||
check(contains(page.headers.get("Content-Type"), "text/html"), "html");
|
||||
check(contains(page.body, "Amazon Bedrock") && contains(page.body, "viewport"), "title and mobile viewport");
|
||||
check(contains(page.body, "/embedded/ai_bedrock.js"), "script wired");
|
||||
check(contains(page.body, "<select"), "route picker is a dropdown, not a button row");
|
||||
check(f.client->post("/ai/bedrock", "{}", "application/json").status == 405, "post page is 405");
|
||||
|
||||
auto script = f.client->get("/embedded/ai_bedrock.js");
|
||||
check(script.status == 200 && contains(script.body, "/ai/bedrock/"), "script is embedded");
|
||||
|
||||
auto st = f.client->get("/ai/bedrock/status");
|
||||
check(st.status == 200 && contains(st.body, "\"configured\":false"), "status without a credential");
|
||||
check(contains(st.body, "\"auth_mode\":\"none\"") && contains(st.body, "\"region\":\"us-east-1\""), "status names mode and default region");
|
||||
check(contains(st.body, "AWS_BEARER_TOKEN_BEDROCK") && contains(st.body, "AWS_ACCESS_KEY_ID") &&
|
||||
contains(st.body, "AWS_SECRET_ACCESS_KEY") && contains(st.body, "AWS_SESSION_TOKEN") && contains(st.body, "AWS_REGION"),
|
||||
"status names the credential env vars");
|
||||
check(contains(st.body, "bedrock-runtime.us-east-1.amazonaws.com") && contains(st.body, "bedrock.us-east-1.amazonaws.com") &&
|
||||
contains(st.body, "bedrock-agent-runtime.us-east-1.amazonaws.com"),
|
||||
"status lists the three hosts");
|
||||
check(f.client->post("/ai/bedrock/status", "{}", "application/json").status == 405, "post status is 405");
|
||||
|
||||
auto calls = f.client->get("/ai/bedrock/calls");
|
||||
check(calls.status == 200 && contains(calls.body, "Converse") && contains(calls.body, "/model/{modelId}/converse-stream") &&
|
||||
contains(calls.body, "ApplyGuardrail") && contains(calls.body, "/knowledgebases/{knowledgeBaseId}/retrieve") &&
|
||||
contains(calls.body, "CreateModelInvocationJob"),
|
||||
"call table listed");
|
||||
check(contains(calls.body, "\"bearer_ok\":false"), "agent runtime marked as SigV4 only");
|
||||
return finish("ai/bedrock/page");
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
// Routes: POST /ai/bedrock/* (405, 422, dry runs, 503 without a credential)
|
||||
#include <cstdlib>
|
||||
|
||||
#include "support/Assert.hpp"
|
||||
|
||||
using namespace molo::example::test;
|
||||
|
||||
int main() {
|
||||
setenv("MOLO_ENV_FILES", "off", 1);
|
||||
for (const char* v : {"AWS_BEARER_TOKEN_BEDROCK", "AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN", "AWS_REGION", "AWS_DEFAULT_REGION"})
|
||||
unsetenv(v);
|
||||
Fixture f;
|
||||
auto post = [&](const std::string& route, const std::string& body) {
|
||||
return f.client->post("/ai/bedrock/" + route, body, "application/json");
|
||||
};
|
||||
const char* all[] = {"converse", "converse-stream", "invoke", "invoke-stream", "count-tokens", "guardrail",
|
||||
"agent", "retrieve", "models", "profiles", "guardrails", "batch", "sign"};
|
||||
for (const char* r : all) {
|
||||
std::string route = std::string("/ai/bedrock/") + r;
|
||||
check(f.client->get(route).status == 405, route + " get is 405");
|
||||
check(post(r, "not json").status == 422, route + " bad json is 422");
|
||||
check(post(r, "[1]").status == 422, route + " non-object is 422");
|
||||
}
|
||||
|
||||
// 422: input rules run before anything else (also without a credential)
|
||||
check(post("converse", "{}").status == 422, "converse needs prompt");
|
||||
check(post("converse", "{\"prompt\":\"hi\",\"temperature\":1.5}").status == 422, "temperature over 1");
|
||||
check(post("converse", "{\"prompt\":\"hi\",\"top_p\":-1}").status == 422, "top_p under 0");
|
||||
check(post("converse", "{\"prompt\":\"hi\",\"max_tokens\":0}").status == 422, "max_tokens 0");
|
||||
check(post("converse", "{\"prompt\":\"hi\",\"model\":\"a b\"}").status == 422, "model with a space");
|
||||
check(post("converse", "{\"prompt\":\"hi\",\"model\":\"../x\"}").status == 422, "model with dots");
|
||||
check(post("converse", "{\"prompt\":\"hi\",\"service_tier\":\"gold\"}").status == 422, "bad service tier");
|
||||
check(post("converse", "{\"prompt\":\"hi\",\"guardrail_id\":\"g\"}").status == 422, "guardrail needs a version");
|
||||
check(post("converse", "{\"prompt\":\"hi\",\"stop\":[1]}").status == 422, "stop must be strings");
|
||||
check(post("converse-stream", "{\"prompt\":\"hi\",\"latency\":\"warp\"}").status == 422, "bad latency");
|
||||
check(post("invoke", "{\"model\":\"m\"}").status == 422, "invoke needs a body");
|
||||
check(post("invoke", "{\"model\":\"m\",\"body\":{},\"trace\":\"LOUD\"}").status == 422, "bad trace");
|
||||
check(post("invoke-stream", "{\"body\":{}}").status == 422, "invoke-stream needs a model");
|
||||
check(post("count-tokens", "{}").status == 422, "count-tokens needs a prompt");
|
||||
check(post("guardrail", "{\"text\":\"x\"}").status == 422, "guardrail needs an id");
|
||||
check(post("guardrail", "{\"guardrail_id\":\"g\",\"text\":\"x\",\"source\":\"BOTH\"}").status == 422, "bad source");
|
||||
check(post("guardrail", "{\"guardrail_id\":\"g\",\"text\":\"x\",\"qualifiers\":[\"weird\"]}").status == 422, "bad qualifier");
|
||||
check(post("agent", "{\"agent_id\":\"A\",\"alias_id\":\"B\",\"session_id\":\"x\",\"prompt\":\"hi\"}").status == 422, "session id under 2 chars");
|
||||
check(post("agent", "{\"agent_id\":\"WAYTOOLONGAGENT\",\"alias_id\":\"B\",\"session_id\":\"sess-1\",\"prompt\":\"hi\"}").status == 422, "agent id over 10");
|
||||
check(post("retrieve", "{\"knowledge_base_id\":\"short\",\"query\":\"q\"}").status == 422, "kb id must be 10 chars");
|
||||
check(post("retrieve", "{\"knowledge_base_id\":\"KB12345678\",\"query\":\"q\",\"number_of_results\":101}").status == 422, "over 100 results");
|
||||
check(post("retrieve", "{\"knowledge_base_id\":\"KB12345678\",\"query\":\"q\",\"search_type\":\"FUZZY\"}").status == 422, "bad search type");
|
||||
check(post("models", "{\"action\":\"fly\"}").status == 422, "bad models action");
|
||||
check(post("models", "{\"action\":\"get\"}").status == 422, "models get needs id");
|
||||
check(post("models", "{\"action\":\"get\",\"id\":\"../x\"}").status == 422, "bad model id");
|
||||
check(post("profiles", "{\"max_results\":0}").status == 422, "max_results 0");
|
||||
check(post("profiles", "{\"max_results\":1001}").status == 422, "max_results over 1000");
|
||||
check(post("guardrails", "{\"action\":\"get\"}").status == 422, "guardrails get needs id");
|
||||
check(post("batch", "{}").status == 422, "batch needs an action");
|
||||
check(post("batch", "{\"action\":\"nope\"}").status == 422, "bad batch action");
|
||||
check(post("batch", "{\"action\":\"stop\",\"id\":\"../x\"}").status == 422, "bad job id");
|
||||
check(post("batch", "{\"action\":\"create\",\"job_name\":\"j\",\"role_arn\":\"role\",\"model\":\"m\",\"input_s3_uri\":\"s3://b/i\",\"output_s3_uri\":\"s3://b/o\"}").status == 422,
|
||||
"bad role arn");
|
||||
check(post("batch", "{\"action\":\"create\",\"job_name\":\"j\",\"role_arn\":\"arn:aws:iam::123456789012:role/R\",\"model\":\"m\",\"input_s3_uri\":\"s3://b/i\",\"output_s3_uri\":\"s3://b/o\",\"timeout_hours\":12}").status == 422,
|
||||
"timeout under 24 hours");
|
||||
|
||||
// dry runs: paid or state-changing routes show the exact request
|
||||
auto dry = post("converse", "{\"prompt\":\"hi\",\"model\":\"anthropic.claude-3-sonnet-20240229-v1:0\",\"max_tokens\":50}");
|
||||
check(dry.status == 200 && contains(dry.body, "\"dry_run\":true") && contains(dry.body, "\"maxTokens\":50") &&
|
||||
contains(dry.body, "POST /model/anthropic.claude-3-sonnet-20240229-v1%3A0/converse"),
|
||||
"converse is a dry run without confirm");
|
||||
check(contains(post("converse-stream", "{\"prompt\":\"hi\"}").body, "/converse-stream"), "converse-stream dry run");
|
||||
check(contains(post("invoke", "{\"model\":\"amazon.titan-embed-text-v2:0\",\"body\":{\"inputText\":\"x\"}}").body, "\"dry_run\":true"), "invoke dry run");
|
||||
check(contains(post("invoke-stream", "{\"model\":\"m\",\"body\":{}}").body, "invoke-with-response-stream"), "invoke-stream dry run");
|
||||
check(contains(post("guardrail", "{\"guardrail_id\":\"gr1\",\"text\":\"x\"}").body, "/guardrail/gr1/version/DRAFT/apply"), "guardrail dry run defaults to DRAFT");
|
||||
check(contains(post("agent", "{\"agent_id\":\"AGENT12345\",\"alias_id\":\"ALIAS12345\",\"session_id\":\"sess-1\",\"prompt\":\"hi\"}").body,
|
||||
"/agents/AGENT12345/agentAliases/ALIAS12345/sessions/sess-1/text"),
|
||||
"agent dry run");
|
||||
check(contains(post("retrieve", "{\"knowledge_base_id\":\"KB12345678\",\"query\":\"What is AWS?\"}").body, "\"retrievalQuery\":{\"text\":\"What is AWS?\"}"),
|
||||
"retrieve dry run shows the documented body");
|
||||
check(contains(post("batch", "{\"action\":\"stop\",\"id\":\"abcdefghijkl\"}").body, "\"dry_run\":true"), "batch stop is a dry run");
|
||||
check(contains(post("batch", "{\"action\":\"create\",\"job_name\":\"nightly\",\"role_arn\":\"arn:aws:iam::123456789012:role/R\",\"model\":\"amazon.nova-micro-v1:0\",\"input_s3_uri\":\"s3://b/i.jsonl\",\"output_s3_uri\":\"s3://b/o/\"}").body,
|
||||
"\"dry_run\":true"),
|
||||
"batch create is a dry run");
|
||||
|
||||
// 503: free calls and confirmed calls need the credential
|
||||
for (const char* r : {"count-tokens"}) {
|
||||
auto res = post(r, "{\"prompt\":\"hi\"}");
|
||||
check(res.status == 503 && contains(res.body, "not_configured"), std::string(r) + " without a credential is 503");
|
||||
}
|
||||
check(post("models", "{}").status == 503, "models list without a credential is 503");
|
||||
check(post("models", "{\"action\":\"get\",\"id\":\"amazon.nova-micro-v1:0\"}").status == 503, "models get without a credential is 503");
|
||||
check(post("profiles", "{}").status == 503, "profiles without a credential is 503");
|
||||
check(post("guardrails", "{}").status == 503, "guardrails without a credential is 503");
|
||||
check(post("batch", "{\"action\":\"list\"}").status == 503, "batch list without a credential is 503");
|
||||
check(post("batch", "{\"action\":\"get\",\"id\":\"abcdefghijkl\"}").status == 503, "batch get without a credential is 503");
|
||||
check(post("converse", "{\"prompt\":\"hi\",\"confirm\":true}").status == 503, "confirmed converse without a credential is 503");
|
||||
check(post("converse-stream", "{\"prompt\":\"hi\",\"confirm\":true}").status == 503, "confirmed converse-stream is 503");
|
||||
check(post("invoke", "{\"model\":\"m\",\"body\":{},\"confirm\":true}").status == 503, "confirmed invoke is 503");
|
||||
check(post("invoke-stream", "{\"model\":\"m\",\"body\":{},\"confirm\":true}").status == 503, "confirmed invoke-stream is 503");
|
||||
check(post("guardrail", "{\"guardrail_id\":\"g\",\"text\":\"x\",\"confirm\":true}").status == 503, "confirmed guardrail is 503");
|
||||
check(post("agent", "{\"agent_id\":\"A1\",\"alias_id\":\"B1\",\"session_id\":\"sess-1\",\"prompt\":\"hi\",\"confirm\":true}").status == 503, "confirmed agent is 503");
|
||||
check(post("retrieve", "{\"knowledge_base_id\":\"KB12345678\",\"query\":\"q\",\"confirm\":true}").status == 503, "confirmed retrieve is 503");
|
||||
check(post("batch", "{\"action\":\"stop\",\"id\":\"abcdefghijkl\",\"confirm\":true}").status == 503, "confirmed batch stop is 503");
|
||||
return finish("ai/bedrock/routes");
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// Route: POST /ai/bedrock/sign is local (no credential, no network). With the
|
||||
// request of AWS's get-vanilla test case it must give the suite's signature.
|
||||
#include <cstdlib>
|
||||
|
||||
#include "support/Assert.hpp"
|
||||
|
||||
using namespace molo::example::test;
|
||||
|
||||
int main() {
|
||||
setenv("MOLO_ENV_FILES", "off", 1);
|
||||
for (const char* v : {"AWS_BEARER_TOKEN_BEDROCK", "AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN"}) unsetenv(v);
|
||||
Fixture f;
|
||||
auto sign = [&](const std::string& body) { return f.client->post("/ai/bedrock/sign", body, "application/json"); };
|
||||
|
||||
// aws4_testsuite get-vanilla: GET /, host example.amazonaws.com, 20150830T123600Z, us-east-1, service "service".
|
||||
auto r = sign("{\"service\":\"service\",\"region\":\"us-east-1\"}");
|
||||
check(r.status == 200, "sign answers without a credential");
|
||||
check(contains(r.body, "5fa00fa31553b73ebf1942676e86291e8372ff2a2260956d9b8aae1d763fbf31"), "signature equals AWS's get-vanilla vector");
|
||||
check(contains(r.body, "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request"), "authorization header shape");
|
||||
check(contains(r.body, "documentation credentials"), "says whose credentials it used");
|
||||
check(!contains(r.body, "wJalrXUtnFEMI"), "the secret is not echoed");
|
||||
|
||||
auto q = sign("{\"service\":\"service\",\"query\":\"Param-3=Value3&Param=Value2\"}");
|
||||
check(q.status == 200 && contains(q.body, "Param=Value2&Param-3=Value3"), "query is sorted in the canonical request");
|
||||
|
||||
auto bedrock = sign("{\"method\":\"POST\",\"path\":\"/model/anthropic.claude-3-sonnet-20240229-v1%3A0/converse\",\"host\":\"bedrock-runtime.us-east-1.amazonaws.com\",\"body\":\"{}\"}");
|
||||
check(bedrock.status == 200 && contains(bedrock.body, "v1%253A0"), "a Bedrock model path is encoded twice in the canonical request");
|
||||
|
||||
check(sign("{\"method\":\"TRACE\"}").status == 422, "unsupported method");
|
||||
check(sign("{\"path\":\"no-slash\"}").status == 422, "path must start with /");
|
||||
check(sign("{\"region\":\"US EAST\"}").status == 422, "bad region");
|
||||
check(sign("{\"date\":\"yesterday\"}").status == 422, "bad date");
|
||||
return finish("ai/bedrock/sign");
|
||||
}
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;my-header1;x-amz-date, Signature=c9d5ea9f3f72853aea855b47ea873832890dbdd183b4468f858259531a5138ea
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
GET
|
||||
/
|
||||
|
||||
host:example.amazonaws.com
|
||||
my-header1:value2,value2,value1
|
||||
x-amz-date:20150830T123600Z
|
||||
|
||||
host;my-header1;x-amz-date
|
||||
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
GET / HTTP/1.1
|
||||
Host:example.amazonaws.com
|
||||
My-Header1:value2
|
||||
My-Header1:value2
|
||||
My-Header1:value1
|
||||
X-Amz-Date:20150830T123600Z
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
AWS4-HMAC-SHA256
|
||||
20150830T123600Z
|
||||
20150830/us-east-1/service/aws4_request
|
||||
dc7f04a3abfde8d472b0ab1a418b741b7c67174dad1551b4117b15527fbe966c
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;my-header1;x-amz-date, Signature=cfd34249e4b1c8d6b91ef74165d41a32e5fab3306300901bb65a51a73575eefd
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
GET
|
||||
/
|
||||
|
||||
host:example.amazonaws.com
|
||||
my-header1:value1 value2 value3
|
||||
x-amz-date:20150830T123600Z
|
||||
|
||||
host;my-header1;x-amz-date
|
||||
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
GET / HTTP/1.1
|
||||
Host:example.amazonaws.com
|
||||
My-Header1:value1
|
||||
value2
|
||||
value3
|
||||
X-Amz-Date:20150830T123600Z
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
AWS4-HMAC-SHA256
|
||||
20150830T123600Z
|
||||
20150830/us-east-1/service/aws4_request
|
||||
e99419459a677bc11de234014be3c4e72c1ea5b454ceb58b613061f5d7a162e8
|
||||
+1
@@ -0,0 +1 @@
|
||||
AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;my-header1;x-amz-date, Signature=08c7e5a9acfcfeb3ab6b2185e75ce8b1deb5e634ec47601a50643f830c755c01
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
GET
|
||||
/
|
||||
|
||||
host:example.amazonaws.com
|
||||
my-header1:value4,value1,value3,value2
|
||||
x-amz-date:20150830T123600Z
|
||||
|
||||
host;my-header1;x-amz-date
|
||||
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
GET / HTTP/1.1
|
||||
Host:example.amazonaws.com
|
||||
My-Header1:value4
|
||||
My-Header1:value1
|
||||
My-Header1:value3
|
||||
My-Header1:value2
|
||||
X-Amz-Date:20150830T123600Z
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
AWS4-HMAC-SHA256
|
||||
20150830T123600Z
|
||||
20150830/us-east-1/service/aws4_request
|
||||
31ce73cd3f3d9f66977ad3dd957dc47af14df92fcd8509f59b349e9137c58b86
|
||||
+1
@@ -0,0 +1 @@
|
||||
AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;my-header1;my-header2;x-amz-date, Signature=acc3ed3afb60bb290fc8d2dd0098b9911fcaa05412b367055dee359757a9c736
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
GET
|
||||
/
|
||||
|
||||
host:example.amazonaws.com
|
||||
my-header1:value1
|
||||
my-header2:"a b c"
|
||||
x-amz-date:20150830T123600Z
|
||||
|
||||
host;my-header1;my-header2;x-amz-date
|
||||
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
GET / HTTP/1.1
|
||||
Host:example.amazonaws.com
|
||||
My-Header1: value1
|
||||
My-Header2: "a b c"
|
||||
X-Amz-Date:20150830T123600Z
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
AWS4-HMAC-SHA256
|
||||
20150830T123600Z
|
||||
20150830/us-east-1/service/aws4_request
|
||||
a726db9b0df21c14f559d0a978e563112acb1b9e05476f0a6a1c7d68f28605c7
|
||||
@@ -0,0 +1 @@
|
||||
AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=07ef7494c76fa4850883e2b006601f940f8a34d404d0cfa977f52a65bbf5f24f
|
||||
@@ -0,0 +1,8 @@
|
||||
GET
|
||||
/-._~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
|
||||
|
||||
host:example.amazonaws.com
|
||||
x-amz-date:20150830T123600Z
|
||||
|
||||
host;x-amz-date
|
||||
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
||||
@@ -0,0 +1,3 @@
|
||||
GET /-._~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz HTTP/1.1
|
||||
Host:example.amazonaws.com
|
||||
X-Amz-Date:20150830T123600Z
|
||||
@@ -0,0 +1,4 @@
|
||||
AWS4-HMAC-SHA256
|
||||
20150830T123600Z
|
||||
20150830/us-east-1/service/aws4_request
|
||||
6a968768eefaa713e2a6b16b589a8ea192661f098f37349f4e2c0082757446f9
|
||||
@@ -0,0 +1 @@
|
||||
AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=8318018e0b0f223aa2bbf98705b62bb787dc9c0e678f255a891fd03141be5d85
|
||||
@@ -0,0 +1,8 @@
|
||||
GET
|
||||
/%E1%88%B4
|
||||
|
||||
host:example.amazonaws.com
|
||||
x-amz-date:20150830T123600Z
|
||||
|
||||
host;x-amz-date
|
||||
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
||||
@@ -0,0 +1,3 @@
|
||||
GET /ሴ HTTP/1.1
|
||||
Host:example.amazonaws.com
|
||||
X-Amz-Date:20150830T123600Z
|
||||
@@ -0,0 +1,4 @@
|
||||
AWS4-HMAC-SHA256
|
||||
20150830T123600Z
|
||||
20150830/us-east-1/service/aws4_request
|
||||
2a0a97d02205e45ce2e994789806b19270cfbbb0921b278ccf58f5249ac42102
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=a67d582fa61cc504c4bae71f336f98b97f1ea3c7a6bfe1b6e45aec72011b9aeb
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
GET
|
||||
/
|
||||
Param1=value1
|
||||
host:example.amazonaws.com
|
||||
x-amz-date:20150830T123600Z
|
||||
|
||||
host;x-amz-date
|
||||
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
GET /?Param1=value1 HTTP/1.1
|
||||
Host:example.amazonaws.com
|
||||
X-Amz-Date:20150830T123600Z
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
AWS4-HMAC-SHA256
|
||||
20150830T123600Z
|
||||
20150830/us-east-1/service/aws4_request
|
||||
1e24db194ed7d0eec2de28d7369675a243488e08526e8c1c73571282f7c517ab
|
||||
+1
@@ -0,0 +1 @@
|
||||
AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=371d3713e185cc334048618a97f809c9ffe339c62934c032af5a0e595648fcac
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
GET
|
||||
/
|
||||
%E1%88%B4=Value1&Param=Value2&Param-3=Value3
|
||||
host:example.amazonaws.com
|
||||
x-amz-date:20150830T123600Z
|
||||
|
||||
host;x-amz-date
|
||||
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
GET /?Param-3=Value3&Param=Value2&%E1%88%B4=Value1 HTTP/1.1
|
||||
Host:example.amazonaws.com
|
||||
X-Amz-Date:20150830T123600Z
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
AWS4-HMAC-SHA256
|
||||
20150830T123600Z
|
||||
20150830/us-east-1/service/aws4_request
|
||||
868294f5c38bd141c4972a373a76654f1418a8e4fc18b2e7903ae45e8ae0ec71
|
||||
+1
@@ -0,0 +1 @@
|
||||
AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=b97d918cfa904a5beff61c982a1b6f458b799221646efd99d3219ec94cdf2500
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
GET
|
||||
/
|
||||
Param1=value1&Param2=value2
|
||||
host:example.amazonaws.com
|
||||
x-amz-date:20150830T123600Z
|
||||
|
||||
host;x-amz-date
|
||||
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
GET /?Param2=value2&Param1=value1 HTTP/1.1
|
||||
Host:example.amazonaws.com
|
||||
X-Amz-Date:20150830T123600Z
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
AWS4-HMAC-SHA256
|
||||
20150830T123600Z
|
||||
20150830/us-east-1/service/aws4_request
|
||||
816cd5b414d056048ba4f7c5386d6e0533120fb1fcfa93762cf0fc39e2cf19e0
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=eedbc4e291e521cf13422ffca22be7d2eb8146eecf653089df300a15b2382bd1
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
GET
|
||||
/
|
||||
Param1=Value1&Param1=value2
|
||||
host:example.amazonaws.com
|
||||
x-amz-date:20150830T123600Z
|
||||
|
||||
host;x-amz-date
|
||||
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
GET /?Param1=value2&Param1=Value1 HTTP/1.1
|
||||
Host:example.amazonaws.com
|
||||
X-Amz-Date:20150830T123600Z
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
AWS4-HMAC-SHA256
|
||||
20150830T123600Z
|
||||
20150830/us-east-1/service/aws4_request
|
||||
704b4cef673542d84cdff252633f065e8daeba5f168b77116f8b1bcaf3d38f89
|
||||
+1
@@ -0,0 +1 @@
|
||||
AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=5772eed61e12b33fae39ee5e7012498b51d56abc0abb7c60486157bd471c4694
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
GET
|
||||
/
|
||||
Param1=value1&Param1=value2
|
||||
host:example.amazonaws.com
|
||||
x-amz-date:20150830T123600Z
|
||||
|
||||
host;x-amz-date
|
||||
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
GET /?Param1=value2&Param1=value1 HTTP/1.1
|
||||
Host:example.amazonaws.com
|
||||
X-Amz-Date:20150830T123600Z
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
AWS4-HMAC-SHA256
|
||||
20150830T123600Z
|
||||
20150830/us-east-1/service/aws4_request
|
||||
c968629d70850097a2d8781c9bf7edcb988b04cac14cca9be4acc3595f884606
|
||||
+1
@@ -0,0 +1 @@
|
||||
AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=9c3e54bfcdf0b19771a7f523ee5669cdf59bc7cc0884027167c21bb143a40197
|
||||
tests/src/vendors/bedrock/sigv4_suite/get-vanilla-query-unreserved/get-vanilla-query-unreserved.creq
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
GET
|
||||
/
|
||||
-._~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz=-._~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
|
||||
host:example.amazonaws.com
|
||||
x-amz-date:20150830T123600Z
|
||||
|
||||
host;x-amz-date
|
||||
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
GET /?-._~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz=-._~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz HTTP/1.1
|
||||
Host:example.amazonaws.com
|
||||
X-Amz-Date:20150830T123600Z
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
AWS4-HMAC-SHA256
|
||||
20150830T123600Z
|
||||
20150830/us-east-1/service/aws4_request
|
||||
c30d4703d9f799439be92736156d47ccfb2d879ddf56f5befa6d1d6aab979177
|
||||
+1
@@ -0,0 +1 @@
|
||||
AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=5fa00fa31553b73ebf1942676e86291e8372ff2a2260956d9b8aae1d763fbf31
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
GET
|
||||
/
|
||||
|
||||
host:example.amazonaws.com
|
||||
x-amz-date:20150830T123600Z
|
||||
|
||||
host;x-amz-date
|
||||
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
||||
@@ -0,0 +1,3 @@
|
||||
GET / HTTP/1.1
|
||||
Host:example.amazonaws.com
|
||||
X-Amz-Date:20150830T123600Z
|
||||
@@ -0,0 +1,4 @@
|
||||
AWS4-HMAC-SHA256
|
||||
20150830T123600Z
|
||||
20150830/us-east-1/service/aws4_request
|
||||
bb579772317eb040ac9ed261061d46c1f17a8133879d6129b6e1c25292927e63
|
||||
+1
@@ -0,0 +1 @@
|
||||
AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=2cdec8eed098649ff3a119c94853b13c643bcf08f8b0a1d91e12c9027818dd04
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
GET
|
||||
/
|
||||
%E1%88%B4=bar
|
||||
host:example.amazonaws.com
|
||||
x-amz-date:20150830T123600Z
|
||||
|
||||
host;x-amz-date
|
||||
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
GET /?ሴ=bar HTTP/1.1
|
||||
Host:example.amazonaws.com
|
||||
X-Amz-Date:20150830T123600Z
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
AWS4-HMAC-SHA256
|
||||
20150830T123600Z
|
||||
20150830/us-east-1/service/aws4_request
|
||||
eb30c5bed55734080471a834cc727ae56beb50e5f39d1bff6d0d38cb192a7073
|
||||
+1
@@ -0,0 +1 @@
|
||||
AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date;x-amz-security-token, Signature=07ec1639c89043aa0e3e2de82b96708f198cceab042d4a97044c66dd9f74e7f8
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
GET
|
||||
/
|
||||
|
||||
host:example.amazonaws.com
|
||||
x-amz-date:20150830T123600Z
|
||||
x-amz-security-token:6e86291e8372ff2a2260956d9b8aae1d763fbf315fa00fa31553b73ebf194267
|
||||
|
||||
host;x-amz-date;x-amz-security-token
|
||||
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
GET / HTTP/1.1
|
||||
Host:example.amazonaws.com
|
||||
X-Amz-Date:20150830T123600Z
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
AWS4-HMAC-SHA256
|
||||
20150830T123600Z
|
||||
20150830/us-east-1/service/aws4_request
|
||||
067b36aa60031588cea4a4cde1f21215227a047690c72247f1d70b32fbbfad2b
|
||||
@@ -0,0 +1 @@
|
||||
AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=5fa00fa31553b73ebf1942676e86291e8372ff2a2260956d9b8aae1d763fbf31
|
||||
@@ -0,0 +1,8 @@
|
||||
GET
|
||||
/
|
||||
|
||||
host:example.amazonaws.com
|
||||
x-amz-date:20150830T123600Z
|
||||
|
||||
host;x-amz-date
|
||||
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
||||
@@ -0,0 +1,3 @@
|
||||
GET / HTTP/1.1
|
||||
Host:example.amazonaws.com
|
||||
X-Amz-Date:20150830T123600Z
|
||||
@@ -0,0 +1,4 @@
|
||||
AWS4-HMAC-SHA256
|
||||
20150830T123600Z
|
||||
20150830/us-east-1/service/aws4_request
|
||||
bb579772317eb040ac9ed261061d46c1f17a8133879d6129b6e1c25292927e63
|
||||
+1
@@ -0,0 +1 @@
|
||||
AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=5da7c1a2acd57cee7505fc6676e4e544621c30862966e37dddb68e92efbe5d6b
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
POST
|
||||
/
|
||||
|
||||
host:example.amazonaws.com
|
||||
x-amz-date:20150830T123600Z
|
||||
|
||||
host;x-amz-date
|
||||
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
POST / HTTP/1.1
|
||||
Host:example.amazonaws.com
|
||||
X-Amz-Date:20150830T123600Z
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
AWS4-HMAC-SHA256
|
||||
20150830T123600Z
|
||||
20150830/us-east-1/service/aws4_request
|
||||
553f88c9e4d10fc9e109e2aeb65f030801b70c2f6468faca261d401ae622fc87
|
||||
+1
@@ -0,0 +1 @@
|
||||
AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;my-header1;x-amz-date, Signature=c5410059b04c1ee005303aed430f6e6645f61f4dc9e1461ec8f8916fdf18852c
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
POST
|
||||
/
|
||||
|
||||
host:example.amazonaws.com
|
||||
my-header1:value1
|
||||
x-amz-date:20150830T123600Z
|
||||
|
||||
host;my-header1;x-amz-date
|
||||
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
POST / HTTP/1.1
|
||||
Host:example.amazonaws.com
|
||||
My-Header1:value1
|
||||
X-Amz-Date:20150830T123600Z
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
AWS4-HMAC-SHA256
|
||||
20150830T123600Z
|
||||
20150830/us-east-1/service/aws4_request
|
||||
9368318c2967cf6de74404b30c65a91e8f6253e0a8659d6d5319f1a812f87d65
|
||||
+1
@@ -0,0 +1 @@
|
||||
AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;my-header1;x-amz-date, Signature=cdbc9802e29d2942e5e10b5bccfdd67c5f22c7c4e8ae67b53629efa58b974b7d
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
POST
|
||||
/
|
||||
|
||||
host:example.amazonaws.com
|
||||
my-header1:VALUE1
|
||||
x-amz-date:20150830T123600Z
|
||||
|
||||
host;my-header1;x-amz-date
|
||||
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
POST / HTTP/1.1
|
||||
Host:example.amazonaws.com
|
||||
My-Header1:VALUE1
|
||||
X-Amz-Date:20150830T123600Z
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
AWS4-HMAC-SHA256
|
||||
20150830T123600Z
|
||||
20150830/us-east-1/service/aws4_request
|
||||
d51ced243e649e3de6ef63afbbdcbca03131a21a7103a1583706a64618606a93
|
||||
+1
@@ -0,0 +1 @@
|
||||
AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=28038455d6de14eafc1f9222cf5aa6f1a96197d7deb8263271d420d138af7f11
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
POST
|
||||
/
|
||||
Param1=value1
|
||||
host:example.amazonaws.com
|
||||
x-amz-date:20150830T123600Z
|
||||
|
||||
host;x-amz-date
|
||||
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
POST /?Param1=value1 HTTP/1.1
|
||||
Host:example.amazonaws.com
|
||||
X-Amz-Date:20150830T123600Z
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
AWS4-HMAC-SHA256
|
||||
20150830T123600Z
|
||||
20150830/us-east-1/service/aws4_request
|
||||
9d659678c1756bb3113e2ce898845a0a79dbbc57b740555917687f1b3340fbbd
|
||||
+1
@@ -0,0 +1 @@
|
||||
AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=28038455d6de14eafc1f9222cf5aa6f1a96197d7deb8263271d420d138af7f11
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
POST
|
||||
/
|
||||
Param1=value1
|
||||
host:example.amazonaws.com
|
||||
x-amz-date:20150830T123600Z
|
||||
|
||||
host;x-amz-date
|
||||
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
POST /?Param1=value1 HTTP/1.1
|
||||
Host:example.amazonaws.com
|
||||
X-Amz-Date:20150830T123600Z
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
AWS4-HMAC-SHA256
|
||||
20150830T123600Z
|
||||
20150830/us-east-1/service/aws4_request
|
||||
9d659678c1756bb3113e2ce898845a0a79dbbc57b740555917687f1b3340fbbd
|
||||
@@ -0,0 +1 @@
|
||||
AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=5da7c1a2acd57cee7505fc6676e4e544621c30862966e37dddb68e92efbe5d6b
|
||||
@@ -0,0 +1,8 @@
|
||||
POST
|
||||
/
|
||||
|
||||
host:example.amazonaws.com
|
||||
x-amz-date:20150830T123600Z
|
||||
|
||||
host;x-amz-date
|
||||
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
||||
@@ -0,0 +1,3 @@
|
||||
POST / HTTP/1.1
|
||||
Host:example.amazonaws.com
|
||||
X-Amz-Date:20150830T123600Z
|
||||
@@ -0,0 +1,4 @@
|
||||
AWS4-HMAC-SHA256
|
||||
20150830T123600Z
|
||||
20150830/us-east-1/service/aws4_request
|
||||
553f88c9e4d10fc9e109e2aeb65f030801b70c2f6468faca261d401ae622fc87
|
||||
+1
@@ -0,0 +1 @@
|
||||
AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=content-type;host;x-amz-date, Signature=1a72ec8f64bd914b0e42e42607c7fbce7fb2c7465f63e3092b3b0d39fa77a6fe
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
POST
|
||||
/
|
||||
|
||||
content-type:application/x-www-form-urlencoded; charset=utf8
|
||||
host:example.amazonaws.com
|
||||
x-amz-date:20150830T123600Z
|
||||
|
||||
content-type;host;x-amz-date
|
||||
9095672bbd1f56dfc5b65f3e153adc8731a4a654192329106275f4c7b24d0b6e
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
POST / HTTP/1.1
|
||||
Content-Type:application/x-www-form-urlencoded; charset=utf8
|
||||
Host:example.amazonaws.com
|
||||
X-Amz-Date:20150830T123600Z
|
||||
|
||||
Param1=value1
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
AWS4-HMAC-SHA256
|
||||
20150830T123600Z
|
||||
20150830/us-east-1/service/aws4_request
|
||||
2e1cf7ed91881a30569e46552437e4156c823447bf1781b921b5d486c568dd1c
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=content-type;host;x-amz-date, Signature=ff11897932ad3f4e8b18135d722051e5ac45fc38421b1da7b9d196a0fe09473a
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
POST
|
||||
/
|
||||
|
||||
content-type:application/x-www-form-urlencoded
|
||||
host:example.amazonaws.com
|
||||
x-amz-date:20150830T123600Z
|
||||
|
||||
content-type;host;x-amz-date
|
||||
9095672bbd1f56dfc5b65f3e153adc8731a4a654192329106275f4c7b24d0b6e
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
POST / HTTP/1.1
|
||||
Content-Type:application/x-www-form-urlencoded
|
||||
Host:example.amazonaws.com
|
||||
X-Amz-Date:20150830T123600Z
|
||||
|
||||
Param1=value1
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
AWS4-HMAC-SHA256
|
||||
20150830T123600Z
|
||||
20150830/us-east-1/service/aws4_request
|
||||
42a5e5bb34198acb3e84da4f085bb7927f2bc277ca766e6d19c73c2154021281
|
||||
Vendored
+95
@@ -0,0 +1,95 @@
|
||||
#pragma once
|
||||
|
||||
// Shared rig for the Bedrock tests: a BedrockClient over a recording
|
||||
// MockTransport, a fixed clock (2015-08-30T12:36:00Z, the date of AWS's SigV4
|
||||
// suite) and AWS's documentation credentials. The mock only records the
|
||||
// requests the real client builds; replies are either examples taken from the
|
||||
// AWS API reference (labelled DOC) or documents shaped by the service model
|
||||
// (labelled MODEL). Nothing here verifies vendor behavior: see
|
||||
// src/vendors/bedrock/SPEC.md ## Unverified.
|
||||
|
||||
#include <ctime>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "clients/transports/mock_transport.h"
|
||||
#include "framework.h"
|
||||
#include "llm/error.h"
|
||||
#include "security/crypto/Base64.h"
|
||||
#include "vendors/bedrock/agent.h"
|
||||
#include "vendors/bedrock/caps.h"
|
||||
#include "vendors/bedrock/chat_model.h"
|
||||
#include "vendors/bedrock/client.h"
|
||||
#include "vendors/bedrock/control.h"
|
||||
#include "vendors/bedrock/event_stream.h"
|
||||
#include "vendors/bedrock/runtime.h"
|
||||
|
||||
namespace bedrock_test {
|
||||
|
||||
using molo::clients::ClientRequest;
|
||||
using molo::clients::ClientResponse;
|
||||
using molo::clients::HeaderMap;
|
||||
using molo::clients::Method;
|
||||
using molo::clients::transports::MockExpectation;
|
||||
using molo::clients::transports::MockTransport;
|
||||
using Json = molo::clients::body::Json;
|
||||
using namespace molo::bedrock;
|
||||
|
||||
inline ClientResponse reply(const std::string& body, int status = 200,
|
||||
const std::string& type = "application/json") {
|
||||
HeaderMap h;
|
||||
h.set("Content-Type", type);
|
||||
return ClientResponse(status, h, body);
|
||||
}
|
||||
|
||||
inline ClientResponse stream_reply(const std::string& body) {
|
||||
return reply(body, 200, "application/vnd.amazon.eventstream");
|
||||
}
|
||||
|
||||
inline bool has(const std::string& hay, const std::string& needle) { return hay.find(needle) != std::string::npos; }
|
||||
|
||||
constexpr const char* kAccess = "AKIDEXAMPLE";
|
||||
constexpr const char* kSecret = "wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY";
|
||||
constexpr const char* kBearer = "bedrock-api-key-TESTKEY-DO-NOT-LEAK";
|
||||
constexpr long kFixedTime = 1440938160; // 20150830T123600Z
|
||||
|
||||
inline Credentials sigv4_credentials(const std::string& region = "us-east-1") {
|
||||
AwsCredentials a;
|
||||
a.access_key_id = kAccess;
|
||||
a.secret_access_key = kSecret;
|
||||
return Credentials::sigv4(a, region);
|
||||
}
|
||||
|
||||
struct Rig {
|
||||
MockTransport* mock = nullptr;
|
||||
std::shared_ptr<BedrockClient> client;
|
||||
|
||||
explicit Rig(Credentials credentials = sigv4_credentials()) {
|
||||
auto t = std::make_unique<MockTransport>();
|
||||
mock = t.get();
|
||||
client = std::make_shared<BedrockClient>(std::move(t), std::move(credentials), [] { return std::time_t(kFixedTime); });
|
||||
}
|
||||
Runtime runtime() const { return Runtime(client); }
|
||||
Models models() const { return Models(client); }
|
||||
Guardrails guardrails() const { return Guardrails(client); }
|
||||
BatchJobs jobs() const { return BatchJobs(client); }
|
||||
AgentRuntime agents() const { return AgentRuntime(client); }
|
||||
|
||||
void expect(Method m, const std::string& path, ClientResponse r, int times = 1) {
|
||||
MockExpectation e;
|
||||
e.method = m;
|
||||
e.path = path;
|
||||
e.response = std::move(r);
|
||||
e.times = times;
|
||||
mock->expect(e);
|
||||
}
|
||||
// Frame builders (the documented layout; see event_stream.h).
|
||||
static std::string event(const std::string& type, const std::string& json) {
|
||||
return EventStreamDecoder::encode({{":message-type", "event"}, {":event-type", type}, {":content-type", "application/json"}}, json);
|
||||
}
|
||||
static std::string exception(const std::string& type, const std::string& json) {
|
||||
return EventStreamDecoder::encode({{":message-type", "exception"}, {":exception-type", type}, {":content-type", "application/json"}}, json);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace bedrock_test
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user