diff --git a/internal/jimmtest/openfga.go b/internal/jimmtest/openfga.go index a32ae6939..c3e9b884a 100644 --- a/internal/jimmtest/openfga.go +++ b/internal/jimmtest/openfga.go @@ -4,7 +4,6 @@ import ( "context" "encoding/json" "fmt" - "os" "strings" "sync" @@ -16,6 +15,7 @@ import ( "github.com/canonical/jimm/internal/errors" "github.com/canonical/jimm/internal/openfga" + auth_model "github.com/canonical/jimm/openfga" ) var ( @@ -35,13 +35,8 @@ type testSetup struct { } func getAuthModelDefinition() (*sdk.AuthorizationModel, error) { - b, err := os.ReadFile("../../openfga/authorisation_model.json") - if err != nil { - return nil, err - } - authModel := sdk.AuthorizationModel{} - err = json.Unmarshal(b, &authModel) + err := json.Unmarshal(auth_model.AuthModelFile, &authModel) if err != nil { return nil, err } diff --git a/openfga/auth_model.go b/openfga/auth_model.go new file mode 100644 index 000000000..ed5021c62 --- /dev/null +++ b/openfga/auth_model.go @@ -0,0 +1,8 @@ +package openfga + +import ( + _ "embed" +) + +//go:embed authorisation_model.json +var AuthModelFile []byte diff --git a/openfga/readme.md b/openfga/readme.md new file mode 100644 index 000000000..eec33129d --- /dev/null +++ b/openfga/readme.md @@ -0,0 +1,2 @@ +This folder/package exists to hold JIMM's OpenFGA authorisation model. +auth_model.go provides embeds the auth model and provides it for tests.