testType:=flag.String("type","event","test type: 'event' for write control, 'req' for read control, 'both' for both")
testType:=flag.String("type","event","test type: 'event' for write control, 'req' for read control, 'both' for both, 'publish-and-query' for full test")
eventKind:=flag.Int("kind",4678,"event kind to test")
numEvents:=flag.Int("count",2,"number of events to publish (for publish-and-query)")
1. **Builds** an Ubuntu 22.04.5 Docker image with ORLY relay
2. **Configures** the policy engine with `cs-policy.js`
2. **Configures** the policy engine with `cs-policy-daemon.js`
3. **Starts** the relay with policy engine enabled
4. **Tests EVENT messages** (write control) using the `policytest` tool
5. **Tests REQ messages** (read control) using the `policytest` tool
6. **Verifies** that `cs-policy.js` created `/home/orly/cs-policy-output.txt`
7. **Reports** success or failure
4. **Publishes 2 events** to test write control (EVENT messages)
5. **Queries for those events** to test read control (REQ messages)
6. **Verifies** that:
- Both events were published successfully
- Events can be queried and retrieved
- Policy script processed both write and read operations
- Policy script logged to both file and relay log (stderr)
7. **Reports** detailed results with policy invocation counts
## How cs-policy-daemon.js Works
@ -61,15 +65,39 @@ The `policytest` tool is a command-line utility for testing policy enforcement:
@@ -61,15 +65,39 @@ The `policytest` tool is a command-line utility for testing policy enforcement:
# Test both write and read control
./policytest -url ws://localhost:8777 -type both -kind 1
# Publish multiple events and query for them (full integration test)
echo -e "${YELLOW}Step 11: Waiting for policy script to execute (5 seconds)...${NC}"
sleep 5
echo -e "${YELLOW}Step 11: Waiting for policy script to process (3 seconds)...${NC}"
sleep 3
echo""
echo -e "${YELLOW}Step 12: Checking if cs-policy.js created output file...${NC}"
@ -99,19 +91,28 @@ if docker exec orly-policy-test test -f /home/orly/cs-policy-output.txt; then
@@ -99,19 +91,28 @@ if docker exec orly-policy-test test -f /home/orly/cs-policy-output.txt; then