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

Function TestNewAPIKey

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

Source from the content-addressed store, hash-verified

597}
598
599func TestNewAPIKey(t *testing.T) {
600 name := "Test Key"
601 ownerID := "owner_123"
602 scopes := []string{"read", "write"}
603 expiresAt := time.Now().Add(24 * time.Hour)
604
605 apiKey, err := NewAPIKey(name, ownerID, scopes, expiresAt)
606
607 assert.NoError(t, err)
608 assert.NotNil(t, apiKey)
609 assert.Contains(t, apiKey.APIKeyID, "api_key_")
610 assert.NotEmpty(t, apiKey.Key)
611 assert.Equal(t, name, apiKey.Name)
612 assert.Equal(t, ownerID, apiKey.OwnerID)
613 assert.Equal(t, scopes, apiKey.Scopes)
614 assert.Equal(t, expiresAt, apiKey.ExpiresAt)
615 assert.False(t, apiKey.IsRevoked)
616}
617
618func TestAPIKey_IsValid(t *testing.T) {
619 t.Run("Valid key - not revoked and not expired", func(t *testing.T) {

Callers

nothing calls this directly

Calls 1

NewAPIKeyFunction · 0.85

Tested by

no test coverage detected