diff options
author | vitalyisaev <vitalyisaev@ydb.tech> | 2023-12-12 21:55:07 +0300 |
---|---|---|
committer | vitalyisaev <vitalyisaev@ydb.tech> | 2023-12-12 22:25:10 +0300 |
commit | 4967f99474a4040ba150eb04995de06342252718 (patch) | |
tree | c9c118836513a8fab6e9fcfb25be5d404338bca7 /vendor/github.com/aws/smithy-go/transport/http/host_test.go | |
parent | 2ce9cccb9b0bdd4cd7a3491dc5cbf8687cda51de (diff) | |
download | ydb-4967f99474a4040ba150eb04995de06342252718.tar.gz |
YQ Connector: prepare code base for S3 integration
1. Кодовая база Коннектора переписана с помощью Go дженериков так, чтобы добавление нового источника данных (в частности S3 + csv) максимально переиспользовало имеющийся код (чтобы сохранялась логика нарезания на блоки данных, учёт трафика и пр.)
2. API Connector расширено для работы с S3, но ещё пока не протестировано.
Diffstat (limited to 'vendor/github.com/aws/smithy-go/transport/http/host_test.go')
-rw-r--r-- | vendor/github.com/aws/smithy-go/transport/http/host_test.go | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/vendor/github.com/aws/smithy-go/transport/http/host_test.go b/vendor/github.com/aws/smithy-go/transport/http/host_test.go new file mode 100644 index 0000000000..9ced92a3ca --- /dev/null +++ b/vendor/github.com/aws/smithy-go/transport/http/host_test.go @@ -0,0 +1,87 @@ +package http + +import ( + "strconv" + "testing" +) + +func TestValidPortNumber(t *testing.T) { + cases := []struct { + Input string + Valid bool + }{ + {Input: "123", Valid: true}, + {Input: "123.0", Valid: false}, + {Input: "-123", Valid: false}, + {Input: "65536", Valid: false}, + {Input: "0", Valid: true}, + } + for i, c := range cases { + t.Run(strconv.Itoa(i), func(t *testing.T) { + valid := ValidPortNumber(c.Input) + if e, a := c.Valid, valid; e != a { + t.Errorf("expect valid %v, got %v", e, a) + } + }) + } + +} + +func TestValidHostLabel(t *testing.T) { + cases := []struct { + Input string + Valid bool + }{ + {Input: "abc123", Valid: true}, + {Input: "123", Valid: true}, + {Input: "abc", Valid: true}, + {Input: "123-abc", Valid: true}, + {Input: "{thing}-abc", Valid: false}, + {Input: "abc.123", Valid: false}, + {Input: "abc/123", Valid: false}, + {Input: "012345678901234567890123456789012345678901234567890123456789123", Valid: true}, + {Input: "0123456789012345678901234567890123456789012345678901234567891234", Valid: false}, + {Input: "", Valid: false}, + } + + for i, c := range cases { + t.Run(strconv.Itoa(i), func(t *testing.T) { + valid := ValidHostLabel(c.Input) + if e, a := c.Valid, valid; e != a { + t.Errorf("expect valid %v, got %v", e, a) + } + }) + } +} + +func TestValidateEndpointHostHandler(t *testing.T) { + cases := map[string]struct { + Input string + Valid bool + }{ + "valid host": {Input: "abc.123", Valid: true}, + "fqdn host": {Input: "abc.123.", Valid: true}, + "empty label": {Input: "abc..", Valid: false}, + "max host len": { + Input: "123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.12345", + Valid: true, + }, + "too long host": { + Input: "123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456", + Valid: false, + }, + "valid host with port number": {Input: "abd.123:1234", Valid: true}, + "valid host with invalid port number": {Input: "abc.123:99999", Valid: false}, + "empty host with port number": {Input: ":1234", Valid: false}, + "valid host with empty port number": {Input: "abc.123:", Valid: false}, + } + + for name, c := range cases { + t.Run(name, func(t *testing.T) { + err := ValidateEndpointHost(c.Input) + if e, a := c.Valid, err == nil; e != a { + t.Errorf("expect valid %v, got %v, %v", e, a, err) + } + }) + } +} |