# fixtures This directory contains compiled policy WASM for use with the policy engine. The purpose of these files is to support testing units which rely on the PolicyEngine. In order to create a new file, set up a read context and associated rules in a test domain. Then fetch the compiled policy WASM from the describe read context endpoint, as follows. ```bash curl "${API_URL}/v1/domains/${DOMAIN_ID}/control/read-context/test?includePolicyBundle=true" -XGET -H"Authorization: Bearer ${TOKEN}" | jq -r .policyAssembly | base64 -d > ../capsule/fixtures/example.wasm ``` Note that the name given above (`example.wasm`) should be replaced with a name which is indicative of the content of the policy. Then update this file with a description of the policy and how it was generated to allow for independent reproduction. You can then make use of the new bundle in a test as follows. ``` let mut path = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")); path.push("src/capsule/fixtures/example.wasm"); let wasm_bytes = std::fs::read(path).expect("unable to read WASM file"); let policy_engine = RUNTIME .block_on(PolicyEngine::new(&wasm_bytes)) .expect("failed to create PolicyEngine"); ``` ## Generating files Below are steps to recreate the read context needed to generate the relevant policy WASM. ###`allow_all.wasm` * `curl ${API_URL}/v1/domains/${DOMAIN_ID}/control/read-context/test -XPUT -H"Authorization: Bearer ${TOKEN}" -H"Content-Type: application/json" -d'{"summary": "test", "description": "test", "requiredHooks": [], "readParameters": []}'`