go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/server/secrets/secrets_test.go (about) 1 // Copyright 2015 The LUCI Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package secrets 16 17 import ( 18 "testing" 19 20 . "github.com/smartystreets/goconvey/convey" 21 ) 22 23 func TestSecret(t *testing.T) { 24 t.Parallel() 25 26 Convey("Blobs works", t, func() { 27 s := Secret{ 28 Active: []byte("s1"), 29 Passive: [][]byte{ 30 []byte("s2"), 31 []byte("s3"), 32 }, 33 } 34 So(s.Blobs(), ShouldResemble, [][]byte{ 35 []byte("s1"), 36 []byte("s2"), 37 []byte("s3"), 38 }) 39 }) 40 41 Convey("Equal works", t, func() { 42 s1 := Secret{ 43 Active: []byte("1"), 44 Passive: [][]byte{ 45 []byte("2"), 46 []byte("3"), 47 }, 48 } 49 s2 := Secret{ 50 Active: []byte("1"), 51 Passive: [][]byte{ 52 []byte("2"), 53 }, 54 } 55 s3 := Secret{ 56 Active: []byte("zzz"), 57 Passive: [][]byte{ 58 []byte("2"), 59 []byte("3"), 60 }, 61 } 62 s4 := Secret{ 63 Active: []byte("1"), 64 Passive: [][]byte{ 65 []byte("2"), 66 []byte("zzz"), 67 }, 68 } 69 So(s1.Equal(s1), ShouldBeTrue) 70 So(s1.Equal(s2), ShouldBeFalse) 71 So(s1.Equal(s3), ShouldBeFalse) 72 So(s1.Equal(s4), ShouldBeFalse) 73 }) 74 }