2024-10-10 13:02:25 +00:00
|
|
|
package iamutil
|
2023-09-05 11:20:55 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2024-10-10 13:02:25 +00:00
|
|
|
"github.com/databricks/databricks-sdk-go/service/iam"
|
2023-09-05 11:20:55 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestIsServicePrincipal_ValidUUID(t *testing.T) {
|
2024-10-10 13:02:25 +00:00
|
|
|
user := &iam.User{
|
|
|
|
UserName: "8b948b2e-d2b5-4b9e-8274-11b596f3b652",
|
|
|
|
}
|
|
|
|
isSP := IsServicePrincipal(user)
|
2023-09-05 11:20:55 +00:00
|
|
|
assert.True(t, isSP, "Expected user ID to be recognized as a service principal")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestIsServicePrincipal_InvalidUUID(t *testing.T) {
|
2024-10-10 13:02:25 +00:00
|
|
|
user := &iam.User{
|
|
|
|
UserName: "invalid",
|
|
|
|
}
|
|
|
|
isSP := IsServicePrincipal(user)
|
2023-09-05 11:20:55 +00:00
|
|
|
assert.False(t, isSP, "Expected user ID to not be recognized as a service principal")
|
|
|
|
}
|