Skip to content

Commit

Permalink
Fix loading policies in subdirectories.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaul Kremer committed May 10, 2023
1 parent c060687 commit 981dbc4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/opal-client/opal_client/policy_store/cedar_client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncio
import json
from typing import Dict, List, Optional, Set, Union
from urllib.parse import quote_plus

import aiohttp
from aiofiles.threadpool.text import AsyncTextIOWrapper
Expand Down Expand Up @@ -77,9 +78,8 @@ async def set_policy(
async with aiohttp.ClientSession() as session:
try:
headers = await self._get_auth_headers()

async with session.put(
f"{self._cedar_url}/policies/{policy_id}",
f"{self._cedar_url}/policies/{quote_plus(policy_id)}",
json={
"content": policy_code,
},
Expand All @@ -104,7 +104,7 @@ async def get_policy(self, policy_id: str) -> Optional[str]:
headers = await self._get_auth_headers()

async with session.get(
f"{self._cedar_url}/policies/{policy_id}", headers=headers
f"{self._cedar_url}/policies/{quote_plus(policy_id)}", headers=headers
) as cedar_response:
result = await cedar_response.json()
return result.get("result", {}).get("raw", None)
Expand Down Expand Up @@ -145,7 +145,7 @@ async def delete_policy(self, policy_id: str, transaction_id: Optional[str] = No
headers = await self._get_auth_headers()

async with session.delete(
f"{self._cedar_url}/policies/{policy_id}", headers=headers
f"{self._cedar_url}/policies/{quote_plus(policy_id)}", headers=headers
) as cedar_response:
return await proxy_response_unless_invalid(
cedar_response,
Expand Down

0 comments on commit 981dbc4

Please sign in to comment.