Реализовать lab3 в общем Helm-релизе с Traefik, TLS и HPA
This commit is contained in:
@@ -177,3 +177,36 @@ func encodeFixture(t *testing.T, codec *Codec, resource string) string {
|
||||
}
|
||||
return token
|
||||
}
|
||||
|
||||
// TestSharedCodec verifies a second process can verify the first process's cursor.
|
||||
func TestSharedCodec(t *testing.T) {
|
||||
key := base64.StdEncoding.EncodeToString(make([]byte, 32))
|
||||
first, err := NewShared(key)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
second, err := NewShared(key)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
position := Position{CreatedAt: time.Now().UTC(), ID: uuid.New()}
|
||||
encoded, err := first.Encode("chat", position)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
result, err := second.Decode(encoded, "chat")
|
||||
if err != nil || result != position {
|
||||
t.Fatalf("cross-replica cursor: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// TestSharedCodecRejectsInvalidKey requires a full 256-bit decoded secret.
|
||||
func TestSharedCodecRejectsInvalidKey(t *testing.T) {
|
||||
for _, key := range []string{"", "broken!", base64.StdEncoding.EncodeToString([]byte("short"))} {
|
||||
t.Run(key, func(t *testing.T) {
|
||||
if _, err := NewShared(key); err == nil {
|
||||
t.Fatal("invalid key accepted")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user