Skip to content

Commit

Permalink
chore: add policy schema test
Browse files Browse the repository at this point in the history
  • Loading branch information
markphelps committed Apr 21, 2024
1 parent eb304f9 commit b2ae212
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions internal/server/authz/policies/schema_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package policies

import (
"encoding/json"
"os"
"testing"

"github.com/santhosh-tekuri/jsonschema/v5"
"github.com/stretchr/testify/require"
)

func TestJSONSchema(t *testing.T) {
schema, err := jsonschema.Compile("policy.schema.json")
require.NoError(t, err)

file, err := os.ReadFile("default.json")
require.NoError(t, err)

data := map[string]interface{}{}

err = json.Unmarshal(file, &data)
require.NoError(t, err)

err = schema.Validate(data)
require.NoError(t, err)
}

0 comments on commit b2ae212

Please sign in to comment.