feat: import Sea vHost single-server testing release
This commit is contained in:
commit
248badd33e
441 files changed
+63221
No files matched your search
@@ -0,0 +1,28 @@
|
||||
package secrets
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestBoxRoundTripAndAuthentication(t *testing.T) {
|
||||
box := New("a sufficiently long installation secret")
|
||||
sealed, err := box.Seal("ftp:42", "random-password")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if bytes.Contains(sealed, []byte("random-password")) {
|
||||
t.Fatal("ciphertext contains plaintext")
|
||||
}
|
||||
opened, err := box.Open("ftp:42", sealed)
|
||||
if err != nil || opened != "random-password" {
|
||||
t.Fatalf("Open() = %q, %v", opened, err)
|
||||
}
|
||||
if _, err = box.Open("database:42", sealed); err == nil {
|
||||
t.Fatal("ciphertext was accepted for another resource label")
|
||||
}
|
||||
sealed[len(sealed)-1] ^= 1
|
||||
if _, err = box.Open("ftp:42", sealed); err == nil {
|
||||
t.Fatal("tampered ciphertext was accepted")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user