feat: add durable Worker execution and WSS server
This commit is contained in:
38
pulse/worker/service_test.go
Normal file
38
pulse/worker/service_test.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package worker
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
core "git.yuntuo.hk/k2safe/orbit/model"
|
||||
)
|
||||
|
||||
func TestRegistrationAndSecretBoundaries(t *testing.T) {
|
||||
secret, digest, err := NewSecret()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
parsed, err := SecretDigest(secret)
|
||||
if err != nil || parsed != digest {
|
||||
t.Fatal("secret round trip")
|
||||
}
|
||||
for _, bad := range []string{secret + "=", secret + "\n", strings.Repeat("!", 43), secret[:42]} {
|
||||
if _, err := SecretDigest(bad); err == nil {
|
||||
t.Fatal("malformed secret accepted")
|
||||
}
|
||||
}
|
||||
input := ConnectInput{InstanceID: core.ID(strings.Repeat("1", 32)), InstanceSecret: secret, QueueID: core.ID(strings.Repeat("2", 32)), Capacity: 1, Capabilities: []Capability{{"z", "v1", "v1"}, {"a", "v1", "v1"}}}
|
||||
normalized, err := NormalizeConnect(input)
|
||||
if err != nil || normalized.Capabilities[0].Handler != "a" || input.Capabilities[0].Handler != "z" {
|
||||
t.Fatalf("normalization changed caller input: %v", err)
|
||||
}
|
||||
input.Capabilities = append(input.Capabilities, input.Capabilities[0])
|
||||
if _, err := NormalizeConnect(input); err == nil {
|
||||
t.Fatal("duplicate capability accepted")
|
||||
}
|
||||
input = normalized
|
||||
input.Capacity = 257
|
||||
if _, err := NormalizeConnect(input); err == nil {
|
||||
t.Fatal("excess capacity accepted")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user