feat(apikey): added route to list user api keys (#1708)

adding api key expiration date

Signed-off-by: Petu Eusebiu <peusebiu@cisco.com>
This commit is contained in:
peusebiu
2023-08-29 19:38:38 +03:00
committed by GitHub
parent 28858f695f
commit 6926bddd3a
15 changed files with 1132 additions and 153 deletions
+20
View File
@@ -95,6 +95,10 @@ type MetaDBMock struct {
GetUserAPIKeyInfoFn func(hashedKey string) (string, error)
IsAPIKeyExpiredFn func(ctx context.Context, hashedKey string) (bool, error)
GetUserAPIKeysFn func(ctx context.Context) ([]mTypes.APIKeyDetails, error)
AddUserAPIKeyFn func(ctx context.Context, hashedKey string, apiKeyDetails *mTypes.APIKeyDetails) error
UpdateUserAPIKeyLastUsedFn func(ctx context.Context, hashedKey string) error
@@ -427,6 +431,22 @@ func (sdm MetaDBMock) GetUserAPIKeyInfo(hashedKey string) (string, error) {
return "", nil
}
func (sdm MetaDBMock) IsAPIKeyExpired(ctx context.Context, hashedKey string) (bool, error) {
if sdm.IsAPIKeyExpiredFn != nil {
return sdm.IsAPIKeyExpiredFn(ctx, hashedKey)
}
return false, nil
}
func (sdm MetaDBMock) GetUserAPIKeys(ctx context.Context) ([]mTypes.APIKeyDetails, error) {
if sdm.GetUserAPIKeysFn != nil {
return sdm.GetUserAPIKeysFn(ctx)
}
return nil, nil
}
func (sdm MetaDBMock) AddUserAPIKey(ctx context.Context, hashedKey string, apiKeyDetails *mTypes.APIKeyDetails) error {
if sdm.AddUserAPIKeyFn != nil {
return sdm.AddUserAPIKeyFn(ctx, hashedKey, apiKeyDetails)