@@ -36,6 +36,27 @@ func TestAccResourceAccessPolicy_allow(t *testing.T) {
3636 })
3737}
3838
39+ func TestAccResourceAccessPolicy_schema_updated (t * testing.T ) {
40+ resource .Test (t , resource.TestCase {
41+ PreCheck : func () { testAccPreCheck (t ) },
42+ ProviderFactories : testProviderFactories ,
43+ Steps : []resource.TestStep {
44+ {
45+ Config : testAccResourceAccessPolicy_schema ,
46+ Check : resource .ComposeTestCheckFunc (
47+ resource .TestCheckResourceAttr ("aidbox_access_policy.example" , "schema" , "{\" required\" :[\" client\" ,\" uri\" ,\" request-method\" ],\" properties\" :{\" uri\" :{\" type\" :\" string\" ,\" pattern\" :\" ^/fhir/.*\" },\" client\" :{\" required\" :[\" id\" ],\" properties\" :{\" id\" :{\" const\" :\" postman\" }}},\" request-method\" :{\" const\" :\" get\" }}}" ),
48+ ),
49+ },
50+ {
51+ Config : testAccResourceAccessPolicy_schema_updated ,
52+ Check : resource .ComposeTestCheckFunc (
53+ resource .TestCheckResourceAttr ("aidbox_access_policy.example" , "schema" , "{\" required\" :[\" client\" ,\" uri\" ,\" request-method\" ],\" properties\" :{\" uri\" :{\" type\" :\" string\" ,\" pattern\" :\" ^/(fhir|ValueSet)(/.*|$)\" },\" client\" :{\" required\" :[\" id\" ],\" properties\" :{\" id\" :{\" const\" :\" postman\" }}},\" request-method\" :{\" const\" :\" get\" }}}" ),
54+ ),
55+ },
56+ },
57+ })
58+ }
59+
3960const testAccResourceAccessPolicy_schema = `
4061resource "aidbox_access_policy" "example" {
4162 description = "A policy to allow postman to access data"
@@ -69,6 +90,39 @@ resource "aidbox_access_policy" "example" {
6990}
7091`
7192
93+ const testAccResourceAccessPolicy_schema_updated = `
94+ resource "aidbox_access_policy" "example" {
95+ description = "A policy to allow postman to access data"
96+ engine = "json-schema"
97+ # The test complains about whitespace differences after application when using jsonencode.
98+ # For practical purposes, jsonencode is much easier to read, so you should use that.
99+ schema = "{\"required\":[\"client\",\"uri\",\"request-method\"],\"properties\":{\"uri\":{\"type\":\"string\",\"pattern\":\"^/(fhir|ValueSet)(/.*|$)\"},\"client\":{\"required\":[\"id\"],\"properties\":{\"id\":{\"const\":\"postman\"}}},\"request-method\":{\"const\":\"get\"}}}"
100+ #schema = jsonencode({
101+ # "required" = [
102+ # "client",
103+ # "uri",
104+ # "request-method" ]
105+ # "properties" = {
106+ # "uri" = {
107+ # "type" = "string"
108+ # "pattern" = "^/(fhir|ValueSet)(/.*|$)"
109+ # }
110+ # "client" = {
111+ # "required" = ["id"]
112+ # "properties" = {
113+ # "id" = {
114+ # const = "postman"
115+ # }
116+ # }
117+ # }
118+ # "request-method" = {
119+ # "const" = "get"
120+ # }
121+ # }
122+ #})
123+ }
124+ `
125+
72126const testAccResourceAccessPolicy_allow = `
73127resource "aidbox_client" "client" {
74128 name = "client-id"
0 commit comments