MCPcopy
hub / github.com/ory/kratos / TestBuildRequest

Function TestBuildRequest

request/builder_test.go:32–320  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

30var testJSONNetTemplate []byte
31
32func TestBuildRequest(t *testing.T) {
33 t.Parallel()
34
35 for _, tc := range []struct {
36 name string
37 method string
38 url string
39 authStrategy AuthStrategy
40 expectedHeader http.Header
41 bodyTemplateURI string
42 body *testRequestBody
43 expectedJSONBody string
44 expectedRawBody string
45 config Config
46 }{
47 {
48 name: "POST request without auth",
49 method: "POST",
50 url: "https://test.kratos.ory.sh/my_endpoint1",
51 authStrategy: NewNoopAuthStrategy(),
52 bodyTemplateURI: "file://./stub/test_body.jsonnet",
53 body: &testRequestBody{
54 To: "+15056445993",
55 From: "+12288534869",
56 Body: "test-sms-body",
57 },
58 expectedJSONBody: `{
59 "body": "test-sms-body",
60 "from": "+12288534869",
61 "to": "+15056445993"
62 }`,
63 config: Config{
64 URL: "https://test.kratos.ory.sh/my_endpoint1",
65 Method: "POST",
66 TemplateURI: "file://./stub/test_body.jsonnet",
67 },
68 },
69 {
70 name: "POST request with legacy template path",
71 method: "POST",
72 url: "https://test.kratos.ory.sh/my_endpoint1",
73 authStrategy: NewNoopAuthStrategy(),
74 bodyTemplateURI: "./stub/test_body.jsonnet",
75 body: &testRequestBody{
76 To: "+15056445993",
77 From: "+12288534869",
78 Body: "test-sms-body",
79 },
80 expectedJSONBody: `{
81 "body": "test-sms-body",
82 "from": "+12288534869",
83 "to": "+15056445993"
84 }`,
85 config: Config{
86 URL: "https://test.kratos.ory.sh/my_endpoint1",
87 Method: "POST",
88 TemplateURI: "./stub/test_body.jsonnet",
89 },

Callers

nothing calls this directly

Calls 9

BuildRequestMethod · 0.95
NewNoopAuthStrategyFunction · 0.85
NewBasicAuthStrategyFunction · 0.85
NewAPIKeyStrategyFunction · 0.85
NewBuilderFunction · 0.85
mustContainHeaderFunction · 0.85
RunMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected