| 15 | ) |
| 16 | |
| 17 | func TestClaims_Set(t *testing.T) { |
| 18 | type fields struct { |
| 19 | Claims jose.Claims |
| 20 | ExtraClaims map[string]interface{} |
| 21 | } |
| 22 | type args struct { |
| 23 | key string |
| 24 | value interface{} |
| 25 | } |
| 26 | tests := []struct { |
| 27 | name string |
| 28 | fields fields |
| 29 | args args |
| 30 | want *Claims |
| 31 | }{ |
| 32 | {"ok nil", fields{jose.Claims{}, nil}, args{"key", "value"}, &Claims{ExtraClaims: map[string]interface{}{"key": "value"}}}, |
| 33 | {"ok empty", fields{jose.Claims{}, make(map[string]interface{})}, args{"key", "value"}, &Claims{ExtraClaims: map[string]interface{}{"key": "value"}}}, |
| 34 | {"ok not empty", fields{jose.Claims{}, map[string]interface{}{"foo": "bar"}}, args{"key", "value"}, &Claims{ExtraClaims: map[string]interface{}{"key": "value", "foo": "bar"}}}, |
| 35 | } |
| 36 | for _, tt := range tests { |
| 37 | t.Run(tt.name, func(t *testing.T) { |
| 38 | c := &Claims{ |
| 39 | Claims: tt.fields.Claims, |
| 40 | ExtraClaims: tt.fields.ExtraClaims, |
| 41 | } |
| 42 | c.Set(tt.args.key, tt.args.value) |
| 43 | if !reflect.DeepEqual(c, tt.want) { |
| 44 | t.Errorf("Options claims = %v, want %v", c, tt.want) |
| 45 | } |
| 46 | }) |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | func TestClaims_SetHeader(t *testing.T) { |
| 51 | type fields struct { |