mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2026-05-17 08:36:55 +03:00
### Describe Your Changes Fixes which are required in order to build FIPS-compliant binaries. These changes were originally added for enterprise version and synced to opensource for consistency and easier maintenance. - consistently use `hash/fnv` at `app/vmalert` when calculating checksums. Usage of md5 is not allowed in FIPS mode. - increase encryption keys size used in testing in order to allow tests to successfully run in FIPS mode ### Checklist The following checks are **mandatory**: - [x] My change adheres to [VictoriaMetrics contributing guidelines](https://docs.victoriametrics.com/contributing/). Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com>
31 lines
991 B
Go
31 lines
991 B
Go
package awsapi
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestNewSignedRequest(t *testing.T) {
|
|
f := func(apiURL string, authHeaderExpected string) {
|
|
t.Helper()
|
|
service := "ec2"
|
|
region := "us-east-1"
|
|
ac := &credentials{
|
|
AccessKeyID: strings.Repeat("fake-access-key", 2),
|
|
SecretAccessKey: strings.Repeat("foobar", 10),
|
|
}
|
|
ct := time.Unix(0, 0).UTC()
|
|
req, err := newSignedGetRequestWithTime(apiURL, service, region, ac, ct)
|
|
if err != nil {
|
|
t.Fatalf("error in newSignedRequest: %s", err)
|
|
}
|
|
authHeader := req.Header.Get("Authorization")
|
|
if authHeader != authHeaderExpected {
|
|
t.Fatalf("unexpected auth header;\ngot\n%s\nwant\n%s", authHeader, authHeaderExpected)
|
|
}
|
|
}
|
|
f("https://ec2.amazonaws.com/?Action=DescribeRegions&Version=2013-10-15",
|
|
"AWS4-HMAC-SHA256 Credential=fake-access-keyfake-access-key/19700101/us-east-1/ec2/aws4_request, SignedHeaders=host;x-amz-date, Signature=e6c0f635693173f83eea9f443ae364d9099c98b0f5e7b1356e7cfc9c742daea2")
|
|
}
|