adding test cases for wrong encoding 7 no encoding of pubsub topic

This commit is contained in:
aya 2024-10-17 13:39:13 +03:00
parent 2c3d84d833
commit 7f397bad82
2 changed files with 37 additions and 2 deletions

View File

@ -93,7 +93,20 @@ class REST(BaseClient):
return get_messages_response.json()
def get_store_messages(
self, peer_addr, include_data, pubsub_topic, content_topics, start_time, end_time, hashes, cursor, page_size, ascending, store_v, **kwargs
self,
peer_addr,
include_data,
pubsub_topic,
content_topics,
start_time,
end_time,
hashes,
cursor,
page_size,
ascending,
store_v,
encode_pubsubtopic=True,
**kwargs,
):
base_url = f"store/{store_v}/messages"
params = []
@ -103,7 +116,10 @@ class REST(BaseClient):
if include_data is not None:
params.append(f"includeData={include_data}")
if pubsub_topic is not None:
params.append(f"pubsubTopic={quote(pubsub_topic, safe='')}")
if encode_pubsubtopic:
params.append(f"pubsubTopic={quote(pubsub_topic, safe='')}")
else:
params.append(f"pubsubTopic={pubsub_topic}")
if content_topics is not None:
params.append(f"contentTopics={quote(content_topics, safe='')}")
if start_time is not None:

View File

@ -149,3 +149,22 @@ class TestTopics(StepsStore):
except Exception as e:
logger.error(f"store request with very long pubsub topic wasn't accepted ")
assert e.args[0].find("Client Error: Request Header Fields Too Large for url") != -1, "error isn't for large url"
def test_store_with_wrong_encoding_pubsubtopic(self):
wrong_encoidng_topic = "%23waku%2F2%2Frs%2F3%2F0"
empty_response = []
logger.debug(f"trying get message with wrong encoded pubsub topic {wrong_encoidng_topic}")
store_response = self.store_nodes[0].get_store_messages(
pubsub_topic=wrong_encoidng_topic, encode_pubsubtopic=False, include_data="true", page_size=20, ascending="true"
)
logger.debug(f"response for getting message with wrong encoded pubsub topic {store_response}")
assert store_response["messages"] == empty_response, "Error !! message retrieved with wrong encoding pubsub_topic"
def test_store_without_encoding_pubsubtopic(self):
topic = PUBSUB_TOPICS_STORE[0]
logger.debug(f"trying get message with wrong encoded pubsub topic {topic}")
store_response = self.store_nodes[0].get_store_messages(
pubsub_topic=topic, encode_pubsubtopic=False, include_data="true", page_size=20, ascending="true"
)
logger.debug(f"response for getting message without encoding pubsub topic {store_response}")
assert store_response["messages"][0]["pubsubTopic"] == PUBSUB_TOPICS_STORE[0], "topics Don't match !!"