@@ -39,6 +39,17 @@ func TestValidateFailure(t *testing.T) {
3939 }
4040 }
4141
42+ expectError := func (want string ) func (* testing.T , * config.Config , error ) {
43+ return func (t * testing.T , _ * config.Config , err error ) {
44+ if err == nil {
45+ t .Fatal ("unexpected success" )
46+ }
47+ if got := err .Error (); got != want {
48+ t .Errorf ("got error %q, want %q" , got , want )
49+ }
50+ }
51+ }
52+
4253 // Tests on the base Config struct.
4354 tt := []ValidateTestcase {
4455 {
@@ -90,19 +101,32 @@ func TestValidateFailure(t *testing.T) {
90101 PSK : & config.AuthPSK {},
91102 },
92103 },
93- Check : shouldFail ,
104+ Check : expectError ("key is empty (at )" ),
105+ },
106+ {
107+ Name : "BadPSKKeyLen" ,
108+ Conf : config.Config {
109+ Mode : config .IndexerMode ,
110+ Auth : config.Auth {
111+ PSK : & config.AuthPSK {
112+ Key : config .Base64 ([]byte {0xde , 0xad , 0xbe , 0xef }),
113+ Issuer : []string {"iss" },
114+ },
115+ },
116+ },
117+ Check : expectError ("key is too short: must be at least 32 bytes (at )" ),
94118 },
95119 {
96120 Name : "BadPSKIssuer" ,
97121 Conf : config.Config {
98122 Mode : config .IndexerMode ,
99123 Auth : config.Auth {
100124 PSK : & config.AuthPSK {
101- Key : config .Base64 ([]byte { 0xde , 0xad , 0xbe , 0xef } ),
125+ Key : config .Base64 ([]byte ( "deadbeefdeadbeefdeadbeefdeadbeef" ) ),
102126 },
103127 },
104128 },
105- Check : shouldFail ,
129+ Check : expectError ( "no issuers defined (at .iss)" ) ,
106130 },
107131 }
108132 for _ , tc := range tt {
0 commit comments