infobloxopen / seal

Apache License 2.0
16 stars 11 forks source link

GH-90: replaced petstore.com with petstore.swagger.io; generate jwt in rego tests #89

Closed wplu closed 4 years ago

wplu commented 4 years ago

DEMO:

old hardcoded jwt was used:

test_use_petstore_jwt {
        in := {
...
              "jwt": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJub3RfcGV0c3RvcmUuY29tIn0.iEsWURIWWbd4LV4UAyU7SPufo9pD5qcGLnCmqxxQExo",

generate jwt from claims for use in tests:

                "jwt": sealtest_jwt_encode_sign({
                        "iss": "not_petstore.swagger.io",
                        "sub": "wiley-e-coyote@acme.com",
                        "groups": ["everyone", "test"],
                }),

tests pass:

# wlu@rm-ml-wlu: make demo
...
data.petstore.all.test_use_petstore_jwt: PASS (910.2µs)
data.petstore.all.test_use_petstore_jwt_negative: PASS (552µs)
...
### petstore example passed REGO OPA tests