mirror of
https://github.com/logos-messaging/logos-messaging-interop-tests.git
synced 2026-01-02 14:03:08 +00:00
adding content topic & pubsubtopic tests
This commit is contained in:
parent
684d14c050
commit
2c3d84d833
@ -2,6 +2,10 @@ import pytest
|
||||
from src.env_vars import NODE_2
|
||||
from src.steps.store import StepsStore
|
||||
from src.test_data import CONTENT_TOPICS_DIFFERENT_SHARDS
|
||||
from src.libs.custom_logger import get_custom_logger
|
||||
from src.test_data import PUBSUB_TOPICS_STORE
|
||||
|
||||
logger = get_custom_logger(__name__)
|
||||
|
||||
|
||||
@pytest.mark.xfail("go-waku" in NODE_2, reason="Bug reported: https://github.com/waku-org/go-waku/issues/1108")
|
||||
@ -79,3 +83,69 @@ class TestTopics(StepsStore):
|
||||
for node in self.store_nodes:
|
||||
store_response = node.get_store_messages(page_size=20, ascending="true")
|
||||
assert len(store_response["messages"]) == len(CONTENT_TOPICS_DIFFERENT_SHARDS), "Message count mismatch"
|
||||
|
||||
def test_store_with_not_valid_content_topic(self):
|
||||
empty_content_topic = ""
|
||||
for node in self.store_nodes:
|
||||
store_response = node.get_store_messages(page_size=20, include_data="true", ascending="true", content_topics=empty_content_topic)
|
||||
assert len(store_response["messages"]) == len(CONTENT_TOPICS_DIFFERENT_SHARDS), "Message count mismatch"
|
||||
# test with space string content topic
|
||||
space_content_topic = " "
|
||||
try:
|
||||
store_response = self.store_nodes[0].get_store_messages(
|
||||
page_size=20, include_data="true", ascending="true", content_topics=space_content_topic
|
||||
)
|
||||
logger.debug(f" response for empty content_topic {store_response}")
|
||||
assert store_response["messages"] == [], "message stored with wrong topic "
|
||||
except Exception as e:
|
||||
raise Exception("couldn't get stored message")
|
||||
|
||||
def test_store_with_wrong_url_content_topic(self):
|
||||
# test with wrong url
|
||||
wrong_content_topic = "myapp/1/latest/proto"
|
||||
try:
|
||||
store_response = self.store_nodes[0].get_store_messages(
|
||||
page_size=20, include_data="true", ascending="true", content_topics=wrong_content_topic
|
||||
)
|
||||
logger.debug(f" response for wrong url content topic is {store_response}")
|
||||
assert store_response["messages"] == [], "message stored with wrong topic "
|
||||
except Exception as e:
|
||||
raise Exception("couldn't get stored message")
|
||||
|
||||
def test_store_with_empty_pubsub_topics(self):
|
||||
# empty pubsub topic
|
||||
empty_topic = ""
|
||||
index = iter(self.store_nodes)
|
||||
logger.debug(f"Trying to get stored msg with empty pubsub topic")
|
||||
store_response = self.store_nodes[0].get_store_messages(pubsub_topic=empty_topic, include_data="true", page_size=20, ascending="true")
|
||||
logger.debug(f"getting the following response when sending empty pubsub_topic {store_response}")
|
||||
for msg in store_response["messages"]:
|
||||
assert msg["pubsubTopic"] == self.test_pubsub_topic, "wrong pubsub topic"
|
||||
logger.debug(f"messages successfully queried with empty pubsub topic ")
|
||||
|
||||
def test_store_with_wrong_url_pubsub_topic(self):
|
||||
# wrong url pubsub topic
|
||||
wrong_url_topic = PUBSUB_TOPICS_STORE[0][1:]
|
||||
logger.debug(f"Trying to get stored msg with wrong url topic {wrong_url_topic}")
|
||||
try:
|
||||
self.publish_message(pubsub_topic=PUBSUB_TOPICS_STORE[0])
|
||||
self.check_published_message_is_stored(pubsub_topic=wrong_url_topic)
|
||||
raise Exception("getting stored message with wrong url pubsub topic")
|
||||
except Exception as e:
|
||||
logger.error(f"Topic {wrong_url_topic} is wrong ''n: {str(e)}")
|
||||
assert e.args[0].find("messages': []") != -1, "Message shall not be stored for wrong topic"
|
||||
|
||||
def test_store_with_long_string_pubsub_topic(self):
|
||||
# long topic string
|
||||
long_url_topic = PUBSUB_TOPICS_STORE[0][:-1]
|
||||
million = 1000000
|
||||
for i in range(million):
|
||||
long_url_topic += str(i)
|
||||
logger.debug(f"Trying to get stored msg with url topic size million ")
|
||||
self.publish_message(pubsub_topic=PUBSUB_TOPICS_STORE[0])
|
||||
try:
|
||||
self.check_published_message_is_stored(pubsub_topic=long_url_topic)
|
||||
raise Exception("request stored message with very long topic string shouldn't be accepted")
|
||||
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"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user