File: shared_test.go

package info (click to toggle)
golang-github-aws-aws-sdk-go-v2 1.24.1-2~bpo12%2B1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-backports
  • size: 554,032 kB
  • sloc: java: 15,941; makefile: 419; sh: 175
file content (53 lines) | stat: -rw-r--r-- 1,135 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package benchmark

import (
	"bytes"
	"flag"
	"fmt"
	"io"
	"os"
	"testing"

	smithyClient "github.com/aws/aws-sdk-go-v2/service/lexruntimeservice"
	"github.com/aws/smithy-go/middleware"
)

var (
	disableSmithySigning bool
)

func init() {
	flag.BoolVar(&disableSmithySigning, "disable-smithy-signing", false,
		"Instructs the test to be run with smithy signing turned off.")
}

func TestMain(m *testing.M) {
	flag.Parse()

	os.Exit(m.Run())
}

func loadTestData(filename string) ([]byte, error) {
	f, err := os.Open(filename)
	if err != nil {
		return nil, err
	}
	defer f.Close()

	var b bytes.Buffer
	if _, err = io.Copy(&b, f); err != nil {
		return nil, fmt.Errorf("failed to read test data, %v", err)
	}

	return b.Bytes(), nil
}

func removeSmithySigner(options *smithyClient.Options) {
	options.APIOptions = append(options.APIOptions, func(stack *middleware.Stack) error {
		stack.Finalize.Remove("SigV4SignHTTPRequestMiddleware")
		stack.Finalize.Remove("SigV4ContentSHA256HeaderMiddleware")
		stack.Finalize.Remove("ComputePayloadSHA256Middleware")
		stack.Finalize.Remove("SigV4UnsignedPayloadMiddleware")
		return nil
	})
}