Выпуск WDTT Plus v18
This commit is contained in:
1 parent
abf0a0f130
commit
b3935b947a
101 files changed
+16512
-1477
No files matched your search
@@ -0,0 +1,38 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestParseOpaqueHTTPSCommand(t *testing.T) {
|
||||
line := strings.Join([]string{
|
||||
"OPAQUE_HTTPS_POST",
|
||||
"request-1234",
|
||||
base64.RawURLEncoding.EncodeToString([]byte("https://example.org/status")),
|
||||
base64.RawURLEncoding.EncodeToString([]byte(`{"operation":"status"}`)),
|
||||
}, "|")
|
||||
command, err := parseOpaqueHTTPSCommand(line)
|
||||
if err != nil || command.requestID != "request-1234" || command.url != "https://example.org/status" {
|
||||
t.Fatalf("command rejected: %#v, %v", command, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleOpaqueHTTPSResponseUsesSharedAssembler(t *testing.T) {
|
||||
dispatcher := &Dispatcher{updateMetadataWaiters: make(map[string]*updateMetadataAssembly)}
|
||||
waiter := &updateMetadataAssembly{result: make(chan updateMetadataResult, 1)}
|
||||
dispatcher.updateMetadataWaiters["request-1234"] = waiter
|
||||
payload := []byte(`{"status":200,"body":"ok"}`)
|
||||
frame := []byte(
|
||||
opaqueHTTPSResponsePrefix + "request-1234|OK|0|1|" +
|
||||
base64.RawURLEncoding.EncodeToString(payload),
|
||||
)
|
||||
if !dispatcher.handleUpdateMetadataResponse(frame) {
|
||||
t.Fatal("opaque HTTPS response was not recognized")
|
||||
}
|
||||
result := <-waiter.result
|
||||
if result.err != nil || string(result.payload) != string(payload) {
|
||||
t.Fatalf("result = %q, %v", result.payload, result.err)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user