| 185 | } |
| 186 | |
| 187 | func TestAlgorithmConstants(t *testing.T) { |
| 188 | env, err := cel.NewEnv( |
| 189 | hmaclib.Library(), |
| 190 | ) |
| 191 | if err != nil { |
| 192 | t.Fatalf("cel.NewEnv failed: %v", err) |
| 193 | } |
| 194 | |
| 195 | tests := []struct { |
| 196 | expr string |
| 197 | want string |
| 198 | }{ |
| 199 | {`hmac.SHA256`, "SHA256"}, |
| 200 | {`hmac.SHA384`, "SHA384"}, |
| 201 | {`hmac.SHA512`, "SHA512"}, |
| 202 | {`hmac.SHA224`, "SHA224"}, |
| 203 | {`hmac.SHA512_256`, "SHA512_256"}, |
| 204 | {`hmac.SHA512_224`, "SHA512_224"}, |
| 205 | } |
| 206 | |
| 207 | for _, tc := range tests { |
| 208 | t.Run(tc.expr, func(t *testing.T) { |
| 209 | got := evalExpr(t, env, tc.expr, nil) |
| 210 | if got != tc.want { |
| 211 | t.Errorf("Eval(%q) = %v, want %v", tc.expr, got, tc.want) |
| 212 | } |
| 213 | }) |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | func TestHMACCompositionWithEncodersAndStrings(t *testing.T) { |
| 218 | env, err := cel.NewEnv( |