Skip to content

QuickSign/cotech-opa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Test policies

Disco #1

Adults only

Disco #2

Adult ladies only

Disco #3

VIP adult ladies only

Testing

Unit testing

Run server

opa run --server \
  --addr=0.0.0.0:8080 \
  --log-level=debug \
  disco03/policy.rego \
  disco03/data/vips.rego

List policies

List all policies

curl -s http://localhost:8080/v1/policies | jq ".result[].id"

Check our disco03 policy

curl -s http://localhost:8080/v1/policies/disco03/policy.rego | jq -r ".result.raw"

Check default data

curl -s http://localhost:8080/v1/data/disco03/authorized
curl -s http://localhost:8080/v1/data/vips/names

Query with REST

Eval like testing

Gauthier

curl -s -X POST \
  -H 'Content-Type: application/x-yaml' \
  -H 'Accept: application/json' \
  -d 'input:
  name: Gauthier
  age: 11
  gender: Male' \
  http://localhost:8080/v1/data/disco03?explain=full \
  | jq ".result.authorized"

Arnaud

curl -s -X POST \
  -H 'Content-Type: application/x-yaml' \
  -H 'Accept: application/json' \
  -d 'input:
  name: Arnaud
  age: 40
  gender: Male' \
  http://localhost:8080/v1/data/disco03?explain=full \
  | jq ".result.authorized"

Lorie

curl -s -X POST \
  -H 'Content-Type: application/x-yaml' \
  -H 'Accept: application/json' \
  -d 'input:
  name: Lorie
  age: 40
  gender: Female' \
  http://localhost:8080/v1/data/disco03?explain=full \
  | jq ".result.authorized"

Chantal

curl -s -X POST \
  -H 'Content-Type: application/x-yaml' \
  -H 'Accept: application/json' \
  -d 'input:
  name: Chantal
  age: 79
  gender: Female' \
  http://localhost:8080/v1/data/disco03?explain=full \
  | jq ".result.authorized"