| 650 | } |
| 651 | |
| 652 | func TestAPIKey_HasScope(t *testing.T) { |
| 653 | apiKey := &APIKey{ |
| 654 | Scopes: []string{"read", "write", "admin"}, |
| 655 | } |
| 656 | |
| 657 | t.Run("Has scope - read", func(t *testing.T) { |
| 658 | assert.True(t, apiKey.HasScope("read")) |
| 659 | }) |
| 660 | |
| 661 | t.Run("Has scope - admin", func(t *testing.T) { |
| 662 | assert.True(t, apiKey.HasScope("admin")) |
| 663 | }) |
| 664 | |
| 665 | t.Run("Does not have scope", func(t *testing.T) { |
| 666 | assert.False(t, apiKey.HasScope("delete")) |
| 667 | }) |
| 668 | |
| 669 | t.Run("Empty scopes", func(t *testing.T) { |
| 670 | emptyKey := &APIKey{Scopes: []string{}} |
| 671 | assert.False(t, emptyKey.HasScope("read")) |
| 672 | }) |
| 673 | } |
| 674 | |
| 675 | func TestConvertToStructFieldName(t *testing.T) { |
| 676 | tests := []struct { |