MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / TestAPIKey_IsValid

Function TestAPIKey_IsValid

model/model_test.go:618–650  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

616}
617
618func TestAPIKey_IsValid(t *testing.T) {
619 t.Run("Valid key - not revoked and not expired", func(t *testing.T) {
620 apiKey := &APIKey{
621 IsRevoked: false,
622 ExpiresAt: time.Now().Add(24 * time.Hour),
623 }
624 assert.True(t, apiKey.IsValid())
625 })
626
627 t.Run("Invalid key - revoked", func(t *testing.T) {
628 apiKey := &APIKey{
629 IsRevoked: true,
630 ExpiresAt: time.Now().Add(24 * time.Hour),
631 }
632 assert.False(t, apiKey.IsValid())
633 })
634
635 t.Run("Invalid key - expired", func(t *testing.T) {
636 apiKey := &APIKey{
637 IsRevoked: false,
638 ExpiresAt: time.Now().Add(-24 * time.Hour),
639 }
640 assert.False(t, apiKey.IsValid())
641 })
642
643 t.Run("Invalid key - revoked and expired", func(t *testing.T) {
644 apiKey := &APIKey{
645 IsRevoked: true,
646 ExpiresAt: time.Now().Add(-24 * time.Hour),
647 }
648 assert.False(t, apiKey.IsValid())
649 })
650}
651
652func TestAPIKey_HasScope(t *testing.T) {
653 apiKey := &APIKey{

Callers

nothing calls this directly

Calls 1

IsValidMethod · 0.95

Tested by

no test coverage detected