MCPcopy
hub / github.com/minio/minio-go / TestSignatureCalculationV4

Function TestSignatureCalculationV4

pkg/signer/request-signature_test.go:27–51  ·  view source on GitHub ↗

Tests signature calculation.

(t *testing.T)

Source from the content-addressed store, hash-verified

25
26// Tests signature calculation.
27func TestSignatureCalculationV4(t *testing.T) {
28 req, err := http.NewRequest(http.MethodGet, "https://s3.amazonaws.com", nil)
29 if err != nil {
30 t.Fatal("Error:", err)
31 }
32 req = SignV4(*req, "", "", "", "us-east-1")
33 if req.Header.Get("Authorization") != "" {
34 t.Fatal("Error: anonymous credentials should not have Authorization header.")
35 }
36
37 req = PreSignV4(*req, "", "", "", "us-east-1", 0)
38 if strings.Contains(req.URL.RawQuery, "X-Amz-Signature") {
39 t.Fatal("Error: anonymous credentials should not have Signature query resource.")
40 }
41
42 req = SignV4(*req, "ACCESS-KEY", "SECRET-KEY", "", "us-east-1")
43 if req.Header.Get("Authorization") == "" {
44 t.Fatal("Error: normal credentials should have Authorization header.")
45 }
46
47 req = PreSignV4(*req, "ACCESS-KEY", "SECRET-KEY", "", "us-east-1", 0)
48 if !strings.Contains(req.URL.RawQuery, "X-Amz-Signature") {
49 t.Fatal("Error: normal credentials should have Signature query resource.")
50 }
51}
52
53func TestSignatureCalculationV2(t *testing.T) {
54 testCases := []struct {

Callers

nothing calls this directly

Calls 4

SignV4Function · 0.85
PreSignV4Function · 0.85
GetMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected