veyron/security: DebugString now sorts its output to allow for simpler, deterministic testing.
Change-Id: If4600ceb658d0ba37225d230bc072fe6e14066ba
diff --git a/security/blessingstore.go b/security/blessingstore.go
index 1adfbe2..be3449b 100644
--- a/security/blessingstore.go
+++ b/security/blessingstore.go
@@ -5,6 +5,7 @@
"errors"
"fmt"
"reflect"
+ "sort"
"sync"
"veyron.io/veyron/veyron/security/serialization"
@@ -147,7 +148,14 @@
b := bytes.NewBufferString(fmt.Sprintf("Default blessings: %v\n", bs.state.Default.Blessings()))
b.WriteString(fmt.Sprintf(format, "Peer pattern", "Blessings"))
- for pattern, wb := range bs.state.Store {
+
+ sorted := make([]string, 0, len(bs.state.Store))
+ for k, _ := range bs.state.Store {
+ sorted = append(sorted, string(k))
+ }
+ sort.Strings(sorted)
+ for _, pattern := range sorted {
+ wb := bs.state.Store[security.BlessingPattern(pattern)]
b.WriteString(fmt.Sprintf(format, pattern, wb.Blessings()))
}
return b.String()
diff --git a/tools/principal/test.sh b/tools/principal/test.sh
index 6687ddd..970099e 100755
--- a/tools/principal/test.sh
+++ b/tools/principal/test.sh
@@ -52,7 +52,7 @@
"${PRINCIPAL_BIN}" --veyron.credentials=./bob store setdefault alice.bless || shell_test::fail "line ${LINENO}: store setdefault failed"
"${PRINCIPAL_BIN}" --veyron.credentials=./bob store default >bob.store.default || shell_test::fail "line ${LINENO}: store default failed"
"${PRINCIPAL_BIN}" --veyron.credentials=./bob store set alice.bless alice/... || shell_test::fail "line ${LINENO}: store set failed"
- "${PRINCIPAL_BIN}" --veyron.credentials=./bob store forpeer alice/server >bob.store.forpeer || shell_test::fail "line ${LINENO}: store forpeer failed"
+ "${PRINCIPAL_BIN}" --veyron.credentials=./bob store forpeer alice/server >bob.store.forpeer || shell_test::fail "line ${LINENO}: store forpeer failed"
# Run recvblessings on carol, and have alice send blessings over
# (blessings received must be set as default and shareable with all peers.)
@@ -102,7 +102,7 @@
Public key : Pattern
XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX : [alice/...]
EOF
- if ! diff got want; then
+ if ! diff -C 5 got want; then
shell_test::fail "line ${LINENO}"
fi
@@ -114,7 +114,7 @@
Chain #0 (1 certificates). Root certificate public key: XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX
Certificate #0: alicereborn with 0 caveats
EOF
- if ! diff got want; then
+ if ! diff -C 5 got want; then
shell_test::fail "line ${LINENO}"
fi
@@ -128,7 +128,7 @@
Certificate #1: friend with 1 caveat
(0) security.unixTimeExpiryCaveat
EOF
- if ! diff got want; then
+ if ! diff -C 5 got want; then
shell_test::fail "line ${LINENO}"
fi
@@ -144,7 +144,7 @@
Certificate #1: friend with 1 caveat
(0) security.unixTimeExpiryCaveat
EOF
- if ! diff got want; then
+ if ! diff -C 5 got want; then
shell_test::fail "line ${LINENO}"
fi
@@ -161,7 +161,7 @@
XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX : [alice/...]
XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX : [carol/...]
EOF
- if ! diff got want; then
+ if ! diff -C 5 got want; then
shell_test::fail "line ${LINENO}"
fi
shell_test::pass