github.com/lestrrat-go/jwx/v2@v2.0.21/jwa/key_encryption_gen_test.go (about) 1 // Code generated by tools/cmd/genjwa/main.go. DO NOT EDIT 2 3 package jwa_test 4 5 import ( 6 "testing" 7 8 "github.com/lestrrat-go/jwx/v2/jwa" 9 "github.com/stretchr/testify/assert" 10 ) 11 12 func TestKeyEncryptionAlgorithm(t *testing.T) { 13 t.Parallel() 14 t.Run(`accept jwa constant A128GCMKW`, func(t *testing.T) { 15 t.Parallel() 16 var dst jwa.KeyEncryptionAlgorithm 17 if !assert.NoError(t, dst.Accept(jwa.A128GCMKW), `accept is successful`) { 18 return 19 } 20 if !assert.Equal(t, jwa.A128GCMKW, dst, `accepted value should be equal to constant`) { 21 return 22 } 23 }) 24 t.Run(`accept the string A128GCMKW`, func(t *testing.T) { 25 t.Parallel() 26 var dst jwa.KeyEncryptionAlgorithm 27 if !assert.NoError(t, dst.Accept("A128GCMKW"), `accept is successful`) { 28 return 29 } 30 if !assert.Equal(t, jwa.A128GCMKW, dst, `accepted value should be equal to constant`) { 31 return 32 } 33 }) 34 t.Run(`accept fmt.Stringer for A128GCMKW`, func(t *testing.T) { 35 t.Parallel() 36 var dst jwa.KeyEncryptionAlgorithm 37 if !assert.NoError(t, dst.Accept(stringer{src: "A128GCMKW"}), `accept is successful`) { 38 return 39 } 40 if !assert.Equal(t, jwa.A128GCMKW, dst, `accepted value should be equal to constant`) { 41 return 42 } 43 }) 44 t.Run(`stringification for A128GCMKW`, func(t *testing.T) { 45 t.Parallel() 46 if !assert.Equal(t, "A128GCMKW", jwa.A128GCMKW.String(), `stringified value matches`) { 47 return 48 } 49 }) 50 t.Run(`accept jwa constant A128KW`, func(t *testing.T) { 51 t.Parallel() 52 var dst jwa.KeyEncryptionAlgorithm 53 if !assert.NoError(t, dst.Accept(jwa.A128KW), `accept is successful`) { 54 return 55 } 56 if !assert.Equal(t, jwa.A128KW, dst, `accepted value should be equal to constant`) { 57 return 58 } 59 }) 60 t.Run(`accept the string A128KW`, func(t *testing.T) { 61 t.Parallel() 62 var dst jwa.KeyEncryptionAlgorithm 63 if !assert.NoError(t, dst.Accept("A128KW"), `accept is successful`) { 64 return 65 } 66 if !assert.Equal(t, jwa.A128KW, dst, `accepted value should be equal to constant`) { 67 return 68 } 69 }) 70 t.Run(`accept fmt.Stringer for A128KW`, func(t *testing.T) { 71 t.Parallel() 72 var dst jwa.KeyEncryptionAlgorithm 73 if !assert.NoError(t, dst.Accept(stringer{src: "A128KW"}), `accept is successful`) { 74 return 75 } 76 if !assert.Equal(t, jwa.A128KW, dst, `accepted value should be equal to constant`) { 77 return 78 } 79 }) 80 t.Run(`stringification for A128KW`, func(t *testing.T) { 81 t.Parallel() 82 if !assert.Equal(t, "A128KW", jwa.A128KW.String(), `stringified value matches`) { 83 return 84 } 85 }) 86 t.Run(`accept jwa constant A192GCMKW`, func(t *testing.T) { 87 t.Parallel() 88 var dst jwa.KeyEncryptionAlgorithm 89 if !assert.NoError(t, dst.Accept(jwa.A192GCMKW), `accept is successful`) { 90 return 91 } 92 if !assert.Equal(t, jwa.A192GCMKW, dst, `accepted value should be equal to constant`) { 93 return 94 } 95 }) 96 t.Run(`accept the string A192GCMKW`, func(t *testing.T) { 97 t.Parallel() 98 var dst jwa.KeyEncryptionAlgorithm 99 if !assert.NoError(t, dst.Accept("A192GCMKW"), `accept is successful`) { 100 return 101 } 102 if !assert.Equal(t, jwa.A192GCMKW, dst, `accepted value should be equal to constant`) { 103 return 104 } 105 }) 106 t.Run(`accept fmt.Stringer for A192GCMKW`, func(t *testing.T) { 107 t.Parallel() 108 var dst jwa.KeyEncryptionAlgorithm 109 if !assert.NoError(t, dst.Accept(stringer{src: "A192GCMKW"}), `accept is successful`) { 110 return 111 } 112 if !assert.Equal(t, jwa.A192GCMKW, dst, `accepted value should be equal to constant`) { 113 return 114 } 115 }) 116 t.Run(`stringification for A192GCMKW`, func(t *testing.T) { 117 t.Parallel() 118 if !assert.Equal(t, "A192GCMKW", jwa.A192GCMKW.String(), `stringified value matches`) { 119 return 120 } 121 }) 122 t.Run(`accept jwa constant A192KW`, func(t *testing.T) { 123 t.Parallel() 124 var dst jwa.KeyEncryptionAlgorithm 125 if !assert.NoError(t, dst.Accept(jwa.A192KW), `accept is successful`) { 126 return 127 } 128 if !assert.Equal(t, jwa.A192KW, dst, `accepted value should be equal to constant`) { 129 return 130 } 131 }) 132 t.Run(`accept the string A192KW`, func(t *testing.T) { 133 t.Parallel() 134 var dst jwa.KeyEncryptionAlgorithm 135 if !assert.NoError(t, dst.Accept("A192KW"), `accept is successful`) { 136 return 137 } 138 if !assert.Equal(t, jwa.A192KW, dst, `accepted value should be equal to constant`) { 139 return 140 } 141 }) 142 t.Run(`accept fmt.Stringer for A192KW`, func(t *testing.T) { 143 t.Parallel() 144 var dst jwa.KeyEncryptionAlgorithm 145 if !assert.NoError(t, dst.Accept(stringer{src: "A192KW"}), `accept is successful`) { 146 return 147 } 148 if !assert.Equal(t, jwa.A192KW, dst, `accepted value should be equal to constant`) { 149 return 150 } 151 }) 152 t.Run(`stringification for A192KW`, func(t *testing.T) { 153 t.Parallel() 154 if !assert.Equal(t, "A192KW", jwa.A192KW.String(), `stringified value matches`) { 155 return 156 } 157 }) 158 t.Run(`accept jwa constant A256GCMKW`, func(t *testing.T) { 159 t.Parallel() 160 var dst jwa.KeyEncryptionAlgorithm 161 if !assert.NoError(t, dst.Accept(jwa.A256GCMKW), `accept is successful`) { 162 return 163 } 164 if !assert.Equal(t, jwa.A256GCMKW, dst, `accepted value should be equal to constant`) { 165 return 166 } 167 }) 168 t.Run(`accept the string A256GCMKW`, func(t *testing.T) { 169 t.Parallel() 170 var dst jwa.KeyEncryptionAlgorithm 171 if !assert.NoError(t, dst.Accept("A256GCMKW"), `accept is successful`) { 172 return 173 } 174 if !assert.Equal(t, jwa.A256GCMKW, dst, `accepted value should be equal to constant`) { 175 return 176 } 177 }) 178 t.Run(`accept fmt.Stringer for A256GCMKW`, func(t *testing.T) { 179 t.Parallel() 180 var dst jwa.KeyEncryptionAlgorithm 181 if !assert.NoError(t, dst.Accept(stringer{src: "A256GCMKW"}), `accept is successful`) { 182 return 183 } 184 if !assert.Equal(t, jwa.A256GCMKW, dst, `accepted value should be equal to constant`) { 185 return 186 } 187 }) 188 t.Run(`stringification for A256GCMKW`, func(t *testing.T) { 189 t.Parallel() 190 if !assert.Equal(t, "A256GCMKW", jwa.A256GCMKW.String(), `stringified value matches`) { 191 return 192 } 193 }) 194 t.Run(`accept jwa constant A256KW`, func(t *testing.T) { 195 t.Parallel() 196 var dst jwa.KeyEncryptionAlgorithm 197 if !assert.NoError(t, dst.Accept(jwa.A256KW), `accept is successful`) { 198 return 199 } 200 if !assert.Equal(t, jwa.A256KW, dst, `accepted value should be equal to constant`) { 201 return 202 } 203 }) 204 t.Run(`accept the string A256KW`, func(t *testing.T) { 205 t.Parallel() 206 var dst jwa.KeyEncryptionAlgorithm 207 if !assert.NoError(t, dst.Accept("A256KW"), `accept is successful`) { 208 return 209 } 210 if !assert.Equal(t, jwa.A256KW, dst, `accepted value should be equal to constant`) { 211 return 212 } 213 }) 214 t.Run(`accept fmt.Stringer for A256KW`, func(t *testing.T) { 215 t.Parallel() 216 var dst jwa.KeyEncryptionAlgorithm 217 if !assert.NoError(t, dst.Accept(stringer{src: "A256KW"}), `accept is successful`) { 218 return 219 } 220 if !assert.Equal(t, jwa.A256KW, dst, `accepted value should be equal to constant`) { 221 return 222 } 223 }) 224 t.Run(`stringification for A256KW`, func(t *testing.T) { 225 t.Parallel() 226 if !assert.Equal(t, "A256KW", jwa.A256KW.String(), `stringified value matches`) { 227 return 228 } 229 }) 230 t.Run(`accept jwa constant DIRECT`, func(t *testing.T) { 231 t.Parallel() 232 var dst jwa.KeyEncryptionAlgorithm 233 if !assert.NoError(t, dst.Accept(jwa.DIRECT), `accept is successful`) { 234 return 235 } 236 if !assert.Equal(t, jwa.DIRECT, dst, `accepted value should be equal to constant`) { 237 return 238 } 239 }) 240 t.Run(`accept the string dir`, func(t *testing.T) { 241 t.Parallel() 242 var dst jwa.KeyEncryptionAlgorithm 243 if !assert.NoError(t, dst.Accept("dir"), `accept is successful`) { 244 return 245 } 246 if !assert.Equal(t, jwa.DIRECT, dst, `accepted value should be equal to constant`) { 247 return 248 } 249 }) 250 t.Run(`accept fmt.Stringer for dir`, func(t *testing.T) { 251 t.Parallel() 252 var dst jwa.KeyEncryptionAlgorithm 253 if !assert.NoError(t, dst.Accept(stringer{src: "dir"}), `accept is successful`) { 254 return 255 } 256 if !assert.Equal(t, jwa.DIRECT, dst, `accepted value should be equal to constant`) { 257 return 258 } 259 }) 260 t.Run(`stringification for dir`, func(t *testing.T) { 261 t.Parallel() 262 if !assert.Equal(t, "dir", jwa.DIRECT.String(), `stringified value matches`) { 263 return 264 } 265 }) 266 t.Run(`accept jwa constant ECDH_ES`, func(t *testing.T) { 267 t.Parallel() 268 var dst jwa.KeyEncryptionAlgorithm 269 if !assert.NoError(t, dst.Accept(jwa.ECDH_ES), `accept is successful`) { 270 return 271 } 272 if !assert.Equal(t, jwa.ECDH_ES, dst, `accepted value should be equal to constant`) { 273 return 274 } 275 }) 276 t.Run(`accept the string ECDH-ES`, func(t *testing.T) { 277 t.Parallel() 278 var dst jwa.KeyEncryptionAlgorithm 279 if !assert.NoError(t, dst.Accept("ECDH-ES"), `accept is successful`) { 280 return 281 } 282 if !assert.Equal(t, jwa.ECDH_ES, dst, `accepted value should be equal to constant`) { 283 return 284 } 285 }) 286 t.Run(`accept fmt.Stringer for ECDH-ES`, func(t *testing.T) { 287 t.Parallel() 288 var dst jwa.KeyEncryptionAlgorithm 289 if !assert.NoError(t, dst.Accept(stringer{src: "ECDH-ES"}), `accept is successful`) { 290 return 291 } 292 if !assert.Equal(t, jwa.ECDH_ES, dst, `accepted value should be equal to constant`) { 293 return 294 } 295 }) 296 t.Run(`stringification for ECDH-ES`, func(t *testing.T) { 297 t.Parallel() 298 if !assert.Equal(t, "ECDH-ES", jwa.ECDH_ES.String(), `stringified value matches`) { 299 return 300 } 301 }) 302 t.Run(`accept jwa constant ECDH_ES_A128KW`, func(t *testing.T) { 303 t.Parallel() 304 var dst jwa.KeyEncryptionAlgorithm 305 if !assert.NoError(t, dst.Accept(jwa.ECDH_ES_A128KW), `accept is successful`) { 306 return 307 } 308 if !assert.Equal(t, jwa.ECDH_ES_A128KW, dst, `accepted value should be equal to constant`) { 309 return 310 } 311 }) 312 t.Run(`accept the string ECDH-ES+A128KW`, func(t *testing.T) { 313 t.Parallel() 314 var dst jwa.KeyEncryptionAlgorithm 315 if !assert.NoError(t, dst.Accept("ECDH-ES+A128KW"), `accept is successful`) { 316 return 317 } 318 if !assert.Equal(t, jwa.ECDH_ES_A128KW, dst, `accepted value should be equal to constant`) { 319 return 320 } 321 }) 322 t.Run(`accept fmt.Stringer for ECDH-ES+A128KW`, func(t *testing.T) { 323 t.Parallel() 324 var dst jwa.KeyEncryptionAlgorithm 325 if !assert.NoError(t, dst.Accept(stringer{src: "ECDH-ES+A128KW"}), `accept is successful`) { 326 return 327 } 328 if !assert.Equal(t, jwa.ECDH_ES_A128KW, dst, `accepted value should be equal to constant`) { 329 return 330 } 331 }) 332 t.Run(`stringification for ECDH-ES+A128KW`, func(t *testing.T) { 333 t.Parallel() 334 if !assert.Equal(t, "ECDH-ES+A128KW", jwa.ECDH_ES_A128KW.String(), `stringified value matches`) { 335 return 336 } 337 }) 338 t.Run(`accept jwa constant ECDH_ES_A192KW`, func(t *testing.T) { 339 t.Parallel() 340 var dst jwa.KeyEncryptionAlgorithm 341 if !assert.NoError(t, dst.Accept(jwa.ECDH_ES_A192KW), `accept is successful`) { 342 return 343 } 344 if !assert.Equal(t, jwa.ECDH_ES_A192KW, dst, `accepted value should be equal to constant`) { 345 return 346 } 347 }) 348 t.Run(`accept the string ECDH-ES+A192KW`, func(t *testing.T) { 349 t.Parallel() 350 var dst jwa.KeyEncryptionAlgorithm 351 if !assert.NoError(t, dst.Accept("ECDH-ES+A192KW"), `accept is successful`) { 352 return 353 } 354 if !assert.Equal(t, jwa.ECDH_ES_A192KW, dst, `accepted value should be equal to constant`) { 355 return 356 } 357 }) 358 t.Run(`accept fmt.Stringer for ECDH-ES+A192KW`, func(t *testing.T) { 359 t.Parallel() 360 var dst jwa.KeyEncryptionAlgorithm 361 if !assert.NoError(t, dst.Accept(stringer{src: "ECDH-ES+A192KW"}), `accept is successful`) { 362 return 363 } 364 if !assert.Equal(t, jwa.ECDH_ES_A192KW, dst, `accepted value should be equal to constant`) { 365 return 366 } 367 }) 368 t.Run(`stringification for ECDH-ES+A192KW`, func(t *testing.T) { 369 t.Parallel() 370 if !assert.Equal(t, "ECDH-ES+A192KW", jwa.ECDH_ES_A192KW.String(), `stringified value matches`) { 371 return 372 } 373 }) 374 t.Run(`accept jwa constant ECDH_ES_A256KW`, func(t *testing.T) { 375 t.Parallel() 376 var dst jwa.KeyEncryptionAlgorithm 377 if !assert.NoError(t, dst.Accept(jwa.ECDH_ES_A256KW), `accept is successful`) { 378 return 379 } 380 if !assert.Equal(t, jwa.ECDH_ES_A256KW, dst, `accepted value should be equal to constant`) { 381 return 382 } 383 }) 384 t.Run(`accept the string ECDH-ES+A256KW`, func(t *testing.T) { 385 t.Parallel() 386 var dst jwa.KeyEncryptionAlgorithm 387 if !assert.NoError(t, dst.Accept("ECDH-ES+A256KW"), `accept is successful`) { 388 return 389 } 390 if !assert.Equal(t, jwa.ECDH_ES_A256KW, dst, `accepted value should be equal to constant`) { 391 return 392 } 393 }) 394 t.Run(`accept fmt.Stringer for ECDH-ES+A256KW`, func(t *testing.T) { 395 t.Parallel() 396 var dst jwa.KeyEncryptionAlgorithm 397 if !assert.NoError(t, dst.Accept(stringer{src: "ECDH-ES+A256KW"}), `accept is successful`) { 398 return 399 } 400 if !assert.Equal(t, jwa.ECDH_ES_A256KW, dst, `accepted value should be equal to constant`) { 401 return 402 } 403 }) 404 t.Run(`stringification for ECDH-ES+A256KW`, func(t *testing.T) { 405 t.Parallel() 406 if !assert.Equal(t, "ECDH-ES+A256KW", jwa.ECDH_ES_A256KW.String(), `stringified value matches`) { 407 return 408 } 409 }) 410 t.Run(`accept jwa constant PBES2_HS256_A128KW`, func(t *testing.T) { 411 t.Parallel() 412 var dst jwa.KeyEncryptionAlgorithm 413 if !assert.NoError(t, dst.Accept(jwa.PBES2_HS256_A128KW), `accept is successful`) { 414 return 415 } 416 if !assert.Equal(t, jwa.PBES2_HS256_A128KW, dst, `accepted value should be equal to constant`) { 417 return 418 } 419 }) 420 t.Run(`accept the string PBES2-HS256+A128KW`, func(t *testing.T) { 421 t.Parallel() 422 var dst jwa.KeyEncryptionAlgorithm 423 if !assert.NoError(t, dst.Accept("PBES2-HS256+A128KW"), `accept is successful`) { 424 return 425 } 426 if !assert.Equal(t, jwa.PBES2_HS256_A128KW, dst, `accepted value should be equal to constant`) { 427 return 428 } 429 }) 430 t.Run(`accept fmt.Stringer for PBES2-HS256+A128KW`, func(t *testing.T) { 431 t.Parallel() 432 var dst jwa.KeyEncryptionAlgorithm 433 if !assert.NoError(t, dst.Accept(stringer{src: "PBES2-HS256+A128KW"}), `accept is successful`) { 434 return 435 } 436 if !assert.Equal(t, jwa.PBES2_HS256_A128KW, dst, `accepted value should be equal to constant`) { 437 return 438 } 439 }) 440 t.Run(`stringification for PBES2-HS256+A128KW`, func(t *testing.T) { 441 t.Parallel() 442 if !assert.Equal(t, "PBES2-HS256+A128KW", jwa.PBES2_HS256_A128KW.String(), `stringified value matches`) { 443 return 444 } 445 }) 446 t.Run(`accept jwa constant PBES2_HS384_A192KW`, func(t *testing.T) { 447 t.Parallel() 448 var dst jwa.KeyEncryptionAlgorithm 449 if !assert.NoError(t, dst.Accept(jwa.PBES2_HS384_A192KW), `accept is successful`) { 450 return 451 } 452 if !assert.Equal(t, jwa.PBES2_HS384_A192KW, dst, `accepted value should be equal to constant`) { 453 return 454 } 455 }) 456 t.Run(`accept the string PBES2-HS384+A192KW`, func(t *testing.T) { 457 t.Parallel() 458 var dst jwa.KeyEncryptionAlgorithm 459 if !assert.NoError(t, dst.Accept("PBES2-HS384+A192KW"), `accept is successful`) { 460 return 461 } 462 if !assert.Equal(t, jwa.PBES2_HS384_A192KW, dst, `accepted value should be equal to constant`) { 463 return 464 } 465 }) 466 t.Run(`accept fmt.Stringer for PBES2-HS384+A192KW`, func(t *testing.T) { 467 t.Parallel() 468 var dst jwa.KeyEncryptionAlgorithm 469 if !assert.NoError(t, dst.Accept(stringer{src: "PBES2-HS384+A192KW"}), `accept is successful`) { 470 return 471 } 472 if !assert.Equal(t, jwa.PBES2_HS384_A192KW, dst, `accepted value should be equal to constant`) { 473 return 474 } 475 }) 476 t.Run(`stringification for PBES2-HS384+A192KW`, func(t *testing.T) { 477 t.Parallel() 478 if !assert.Equal(t, "PBES2-HS384+A192KW", jwa.PBES2_HS384_A192KW.String(), `stringified value matches`) { 479 return 480 } 481 }) 482 t.Run(`accept jwa constant PBES2_HS512_A256KW`, func(t *testing.T) { 483 t.Parallel() 484 var dst jwa.KeyEncryptionAlgorithm 485 if !assert.NoError(t, dst.Accept(jwa.PBES2_HS512_A256KW), `accept is successful`) { 486 return 487 } 488 if !assert.Equal(t, jwa.PBES2_HS512_A256KW, dst, `accepted value should be equal to constant`) { 489 return 490 } 491 }) 492 t.Run(`accept the string PBES2-HS512+A256KW`, func(t *testing.T) { 493 t.Parallel() 494 var dst jwa.KeyEncryptionAlgorithm 495 if !assert.NoError(t, dst.Accept("PBES2-HS512+A256KW"), `accept is successful`) { 496 return 497 } 498 if !assert.Equal(t, jwa.PBES2_HS512_A256KW, dst, `accepted value should be equal to constant`) { 499 return 500 } 501 }) 502 t.Run(`accept fmt.Stringer for PBES2-HS512+A256KW`, func(t *testing.T) { 503 t.Parallel() 504 var dst jwa.KeyEncryptionAlgorithm 505 if !assert.NoError(t, dst.Accept(stringer{src: "PBES2-HS512+A256KW"}), `accept is successful`) { 506 return 507 } 508 if !assert.Equal(t, jwa.PBES2_HS512_A256KW, dst, `accepted value should be equal to constant`) { 509 return 510 } 511 }) 512 t.Run(`stringification for PBES2-HS512+A256KW`, func(t *testing.T) { 513 t.Parallel() 514 if !assert.Equal(t, "PBES2-HS512+A256KW", jwa.PBES2_HS512_A256KW.String(), `stringified value matches`) { 515 return 516 } 517 }) 518 t.Run(`accept jwa constant RSA1_5`, func(t *testing.T) { 519 t.Parallel() 520 var dst jwa.KeyEncryptionAlgorithm 521 if !assert.NoError(t, dst.Accept(jwa.RSA1_5), `accept is successful`) { 522 return 523 } 524 if !assert.Equal(t, jwa.RSA1_5, dst, `accepted value should be equal to constant`) { 525 return 526 } 527 }) 528 t.Run(`accept the string RSA1_5`, func(t *testing.T) { 529 t.Parallel() 530 var dst jwa.KeyEncryptionAlgorithm 531 if !assert.NoError(t, dst.Accept("RSA1_5"), `accept is successful`) { 532 return 533 } 534 if !assert.Equal(t, jwa.RSA1_5, dst, `accepted value should be equal to constant`) { 535 return 536 } 537 }) 538 t.Run(`accept fmt.Stringer for RSA1_5`, func(t *testing.T) { 539 t.Parallel() 540 var dst jwa.KeyEncryptionAlgorithm 541 if !assert.NoError(t, dst.Accept(stringer{src: "RSA1_5"}), `accept is successful`) { 542 return 543 } 544 if !assert.Equal(t, jwa.RSA1_5, dst, `accepted value should be equal to constant`) { 545 return 546 } 547 }) 548 t.Run(`stringification for RSA1_5`, func(t *testing.T) { 549 t.Parallel() 550 if !assert.Equal(t, "RSA1_5", jwa.RSA1_5.String(), `stringified value matches`) { 551 return 552 } 553 }) 554 t.Run(`accept jwa constant RSA_OAEP`, func(t *testing.T) { 555 t.Parallel() 556 var dst jwa.KeyEncryptionAlgorithm 557 if !assert.NoError(t, dst.Accept(jwa.RSA_OAEP), `accept is successful`) { 558 return 559 } 560 if !assert.Equal(t, jwa.RSA_OAEP, dst, `accepted value should be equal to constant`) { 561 return 562 } 563 }) 564 t.Run(`accept the string RSA-OAEP`, func(t *testing.T) { 565 t.Parallel() 566 var dst jwa.KeyEncryptionAlgorithm 567 if !assert.NoError(t, dst.Accept("RSA-OAEP"), `accept is successful`) { 568 return 569 } 570 if !assert.Equal(t, jwa.RSA_OAEP, dst, `accepted value should be equal to constant`) { 571 return 572 } 573 }) 574 t.Run(`accept fmt.Stringer for RSA-OAEP`, func(t *testing.T) { 575 t.Parallel() 576 var dst jwa.KeyEncryptionAlgorithm 577 if !assert.NoError(t, dst.Accept(stringer{src: "RSA-OAEP"}), `accept is successful`) { 578 return 579 } 580 if !assert.Equal(t, jwa.RSA_OAEP, dst, `accepted value should be equal to constant`) { 581 return 582 } 583 }) 584 t.Run(`stringification for RSA-OAEP`, func(t *testing.T) { 585 t.Parallel() 586 if !assert.Equal(t, "RSA-OAEP", jwa.RSA_OAEP.String(), `stringified value matches`) { 587 return 588 } 589 }) 590 t.Run(`accept jwa constant RSA_OAEP_256`, func(t *testing.T) { 591 t.Parallel() 592 var dst jwa.KeyEncryptionAlgorithm 593 if !assert.NoError(t, dst.Accept(jwa.RSA_OAEP_256), `accept is successful`) { 594 return 595 } 596 if !assert.Equal(t, jwa.RSA_OAEP_256, dst, `accepted value should be equal to constant`) { 597 return 598 } 599 }) 600 t.Run(`accept the string RSA-OAEP-256`, func(t *testing.T) { 601 t.Parallel() 602 var dst jwa.KeyEncryptionAlgorithm 603 if !assert.NoError(t, dst.Accept("RSA-OAEP-256"), `accept is successful`) { 604 return 605 } 606 if !assert.Equal(t, jwa.RSA_OAEP_256, dst, `accepted value should be equal to constant`) { 607 return 608 } 609 }) 610 t.Run(`accept fmt.Stringer for RSA-OAEP-256`, func(t *testing.T) { 611 t.Parallel() 612 var dst jwa.KeyEncryptionAlgorithm 613 if !assert.NoError(t, dst.Accept(stringer{src: "RSA-OAEP-256"}), `accept is successful`) { 614 return 615 } 616 if !assert.Equal(t, jwa.RSA_OAEP_256, dst, `accepted value should be equal to constant`) { 617 return 618 } 619 }) 620 t.Run(`stringification for RSA-OAEP-256`, func(t *testing.T) { 621 t.Parallel() 622 if !assert.Equal(t, "RSA-OAEP-256", jwa.RSA_OAEP_256.String(), `stringified value matches`) { 623 return 624 } 625 }) 626 t.Run(`bail out on random integer value`, func(t *testing.T) { 627 t.Parallel() 628 var dst jwa.KeyEncryptionAlgorithm 629 if !assert.Error(t, dst.Accept(1), `accept should fail`) { 630 return 631 } 632 }) 633 t.Run(`do not accept invalid (totally made up) string value`, func(t *testing.T) { 634 t.Parallel() 635 var dst jwa.KeyEncryptionAlgorithm 636 if !assert.Error(t, dst.Accept(`totallyInvfalidValue`), `accept should fail`) { 637 return 638 } 639 }) 640 t.Run(`check symmetric values`, func(t *testing.T) { 641 t.Parallel() 642 t.Run(`A128GCMKW`, func(t *testing.T) { 643 assert.True(t, jwa.A128GCMKW.IsSymmetric(), `jwa.A128GCMKW should be symmetric`) 644 }) 645 t.Run(`A128KW`, func(t *testing.T) { 646 assert.True(t, jwa.A128KW.IsSymmetric(), `jwa.A128KW should be symmetric`) 647 }) 648 t.Run(`A192GCMKW`, func(t *testing.T) { 649 assert.True(t, jwa.A192GCMKW.IsSymmetric(), `jwa.A192GCMKW should be symmetric`) 650 }) 651 t.Run(`A192KW`, func(t *testing.T) { 652 assert.True(t, jwa.A192KW.IsSymmetric(), `jwa.A192KW should be symmetric`) 653 }) 654 t.Run(`A256GCMKW`, func(t *testing.T) { 655 assert.True(t, jwa.A256GCMKW.IsSymmetric(), `jwa.A256GCMKW should be symmetric`) 656 }) 657 t.Run(`A256KW`, func(t *testing.T) { 658 assert.True(t, jwa.A256KW.IsSymmetric(), `jwa.A256KW should be symmetric`) 659 }) 660 t.Run(`DIRECT`, func(t *testing.T) { 661 assert.True(t, jwa.DIRECT.IsSymmetric(), `jwa.DIRECT should be symmetric`) 662 }) 663 t.Run(`ECDH_ES`, func(t *testing.T) { 664 assert.False(t, jwa.ECDH_ES.IsSymmetric(), `jwa.ECDH_ES should NOT be symmetric`) 665 }) 666 t.Run(`ECDH_ES_A128KW`, func(t *testing.T) { 667 assert.False(t, jwa.ECDH_ES_A128KW.IsSymmetric(), `jwa.ECDH_ES_A128KW should NOT be symmetric`) 668 }) 669 t.Run(`ECDH_ES_A192KW`, func(t *testing.T) { 670 assert.False(t, jwa.ECDH_ES_A192KW.IsSymmetric(), `jwa.ECDH_ES_A192KW should NOT be symmetric`) 671 }) 672 t.Run(`ECDH_ES_A256KW`, func(t *testing.T) { 673 assert.False(t, jwa.ECDH_ES_A256KW.IsSymmetric(), `jwa.ECDH_ES_A256KW should NOT be symmetric`) 674 }) 675 t.Run(`PBES2_HS256_A128KW`, func(t *testing.T) { 676 assert.True(t, jwa.PBES2_HS256_A128KW.IsSymmetric(), `jwa.PBES2_HS256_A128KW should be symmetric`) 677 }) 678 t.Run(`PBES2_HS384_A192KW`, func(t *testing.T) { 679 assert.True(t, jwa.PBES2_HS384_A192KW.IsSymmetric(), `jwa.PBES2_HS384_A192KW should be symmetric`) 680 }) 681 t.Run(`PBES2_HS512_A256KW`, func(t *testing.T) { 682 assert.True(t, jwa.PBES2_HS512_A256KW.IsSymmetric(), `jwa.PBES2_HS512_A256KW should be symmetric`) 683 }) 684 t.Run(`RSA1_5`, func(t *testing.T) { 685 assert.False(t, jwa.RSA1_5.IsSymmetric(), `jwa.RSA1_5 should NOT be symmetric`) 686 }) 687 t.Run(`RSA_OAEP`, func(t *testing.T) { 688 assert.False(t, jwa.RSA_OAEP.IsSymmetric(), `jwa.RSA_OAEP should NOT be symmetric`) 689 }) 690 t.Run(`RSA_OAEP_256`, func(t *testing.T) { 691 assert.False(t, jwa.RSA_OAEP_256.IsSymmetric(), `jwa.RSA_OAEP_256 should NOT be symmetric`) 692 }) 693 }) 694 t.Run(`check list of elements`, func(t *testing.T) { 695 t.Parallel() 696 var expected = map[jwa.KeyEncryptionAlgorithm]struct{}{ 697 jwa.A128GCMKW: {}, 698 jwa.A128KW: {}, 699 jwa.A192GCMKW: {}, 700 jwa.A192KW: {}, 701 jwa.A256GCMKW: {}, 702 jwa.A256KW: {}, 703 jwa.DIRECT: {}, 704 jwa.ECDH_ES: {}, 705 jwa.ECDH_ES_A128KW: {}, 706 jwa.ECDH_ES_A192KW: {}, 707 jwa.ECDH_ES_A256KW: {}, 708 jwa.PBES2_HS256_A128KW: {}, 709 jwa.PBES2_HS384_A192KW: {}, 710 jwa.PBES2_HS512_A256KW: {}, 711 jwa.RSA1_5: {}, 712 jwa.RSA_OAEP: {}, 713 jwa.RSA_OAEP_256: {}, 714 } 715 for _, v := range jwa.KeyEncryptionAlgorithms() { 716 if _, ok := expected[v]; !assert.True(t, ok, `%s should be in the expected list`, v) { 717 return 718 } 719 delete(expected, v) 720 } 721 if !assert.Len(t, expected, 0) { 722 return 723 } 724 }) 725 }