2026-04-06 15:48:37 +05:30
|
|
|
// Copyright IBM Corp. 2020, 2026
|
2023-03-14 12:08:36 -04:00
|
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
|
|
2023-03-13 12:27:43 -04:00
|
|
|
package globals
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"testing"
|
|
|
|
|
|
2026-10-12 10:33:41 -07:00
|
|
|
"repo.anhonesthost.net/CyberCoveLLC/threshold/internal/types/resource"
|
2023-03-13 12:27:43 -04:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
)
|
|
|
|
|
|
2023-11-15 19:55:46 -05:00
|
|
|
func TestResourceInfoFromPrefix(t *testing.T) {
|
2023-03-13 12:27:43 -04:00
|
|
|
// Test a random sampling
|
2023-03-16 10:11:55 -04:00
|
|
|
vals := map[string]resource.Type{
|
|
|
|
|
VaultCredentialLibraryPrefix: resource.CredentialLibrary,
|
|
|
|
|
OidcManagedGroupPrefix: resource.ManagedGroup,
|
|
|
|
|
StaticHostSetPrefix: resource.HostSet,
|
|
|
|
|
JsonCredentialPrefix: resource.Credential,
|
2023-03-13 12:27:43 -04:00
|
|
|
}
|
2023-03-16 10:11:55 -04:00
|
|
|
|
|
|
|
|
for prefix, typ := range vals {
|
2023-11-15 19:55:46 -05:00
|
|
|
assert.Equal(t, typ, ResourceInfoFromPrefix(prefix).Type)
|
|
|
|
|
assert.Equal(t, typ, ResourceInfoFromPrefix(fmt.Sprintf("%s_foobar", prefix)).Type)
|
|
|
|
|
assert.Equal(t, resource.Unknown, ResourceInfoFromPrefix(fmt.Sprintf("%sfoobar", prefix)).Type)
|
2023-03-13 12:27:43 -04:00
|
|
|
}
|
|
|
|
|
}
|