summaryrefslogtreecommitdiff
path: root/pkg/gid
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-06-18 17:11:42 -0600
committermo khan <mo@mokhan.ca>2025-06-18 17:11:42 -0600
commit2694c82d97005ca39f29f540e26249c18a21f6d6 (patch)
tree259be3c918a047e26fb357b406d915315aa0ead5 /pkg/gid
parentc2b8edab01b23fde6cc196a3349ad6aa19a93299 (diff)
refactor: switch to a pure rust implementation
Diffstat (limited to 'pkg/gid')
-rw-r--r--pkg/gid/gid.go36
-rw-r--r--pkg/gid/gid_test.go38
2 files changed, 0 insertions, 74 deletions
diff --git a/pkg/gid/gid.go b/pkg/gid/gid.go
deleted file mode 100644
index 7d1ea978..00000000
--- a/pkg/gid/gid.go
+++ /dev/null
@@ -1,36 +0,0 @@
-package gid
-
-import (
- "net/url"
- "strings"
-
- "github.com/cedar-policy/cedar-go"
-)
-
-func NewEntityUID(globalID string) cedar.EntityUID {
- if !strings.HasPrefix(globalID, "gid://") {
- return DefaultEntityUID(globalID)
- }
-
- url, err := url.Parse(globalID)
- if err != nil {
- return DefaultEntityUID(globalID)
- }
- items := strings.SplitN(url.Path, "/", 3)
- if len(items) != 3 {
- return DefaultEntityUID(globalID)
- }
-
- return cedar.NewEntityUID(
- cedar.EntityType(items[1]),
- cedar.String(items[2]),
- )
-}
-
-func DefaultEntityUID(id string) cedar.EntityUID {
- return cedar.NewEntityUID("User", cedar.String(id))
-}
-
-func ZeroEntityUID() cedar.EntityUID {
- return cedar.NewEntityUID("", "")
-}
diff --git a/pkg/gid/gid_test.go b/pkg/gid/gid_test.go
deleted file mode 100644
index e1f6285b..00000000
--- a/pkg/gid/gid_test.go
+++ /dev/null
@@ -1,38 +0,0 @@
-package gid
-
-import (
- "testing"
-
- "github.com/cedar-policy/cedar-go"
- "github.com/stretchr/testify/assert"
-)
-
-func TestNewEntityUID(t *testing.T) {
- t.Run("returns an Entity UID with an integer id", func(t *testing.T) {
- result := NewEntityUID("gid://example/User/1")
-
- assert.Equal(t, cedar.EntityType("User"), result.Type)
- assert.Equal(t, cedar.String("1"), result.ID)
- })
-
- t.Run("returns an Entity UID with a UUID", func(t *testing.T) {
- result := NewEntityUID("gid://example/User/4707ce42-1017-11f0-acdf-7ec11f4b308c")
-
- assert.Equal(t, cedar.EntityType("User"), result.Type)
- assert.Equal(t, cedar.String("4707ce42-1017-11f0-acdf-7ec11f4b308c"), result.ID)
- })
-
- t.Run("returns an Entity UID with a namespace", func(t *testing.T) {
- result := NewEntityUID("gid://example/Authn::User/1")
-
- assert.Equal(t, cedar.EntityType("Authn::User"), result.Type)
- assert.Equal(t, cedar.String("1"), result.ID)
- })
-
- t.Run("returns a default when a global id is not provided", func(t *testing.T) {
- result := NewEntityUID("alice")
-
- assert.Equal(t, cedar.EntityType("User"), result.Type)
- assert.Equal(t, cedar.String("alice"), result.ID)
- })
-}