Skip to content

Commit

Permalink
sr: add subjects referenced-by basic auth test
Browse files Browse the repository at this point in the history
This commit tests HTTP Basic Authentication on the Schema Registry
endpoint GET subjects/{subject}/versions/{version}/referencedBy
  • Loading branch information
NyaliaLui committed Oct 10, 2022
1 parent fa211a4 commit c957334
Showing 1 changed file with 82 additions and 0 deletions.
82 changes: 82 additions & 0 deletions tests/rptest/tests/schema_registry_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1514,3 +1514,85 @@ def test_delete_subject_version(self):
super_password))
self.logger.debug(result_raw)
assert result_raw.status_code == requests.codes.ok

@cluster(num_nodes=3)
def test_protobuf(self):
"""
Verify basic protobuf functionality
"""

super_username, super_password, _ = self.redpanda.SUPERUSER_CREDENTIALS

self.logger.info("Posting failed schema should be 422")
result_raw = self._post_subjects_subject_versions(
subject="imported",
data=json.dumps({
"schema": imported_proto_def,
"schemaType": "PROTOBUF"
}),
auth=(super_username, super_password))
self.logger.info(result_raw)
self.logger.info(result_raw.content)
assert result_raw.status_code == requests.codes.unprocessable_entity

self.logger.info("Posting simple as a subject key")
result_raw = self._post_subjects_subject_versions(
subject="simple",
data=json.dumps({
"schema": simple_proto_def,
"schemaType": "PROTOBUF"
}),
auth=(super_username, super_password))
self.logger.info(result_raw)
self.logger.info(result_raw.content)
assert result_raw.status_code == requests.codes.ok
assert result_raw.json()["id"] == 1

self.logger.info("Posting imported as a subject key")
result_raw = self._post_subjects_subject_versions(
subject="imported",
data=json.dumps({
"schema":
imported_proto_def,
"schemaType":
"PROTOBUF",
"references": [{
"name": "simple",
"subject": "simple",
"version": 1
}]
}),
auth=(super_username, super_password))
self.logger.info(result_raw)
self.logger.info(result_raw.content)
assert result_raw.status_code == requests.codes.ok
assert result_raw.json()["id"] == 2

result_raw = self._request("GET",
f"subjects/simple/versions/1/schema",
headers=HTTP_GET_HEADERS,
auth=(super_username, super_password))
self.logger.info(result_raw)
assert result_raw.status_code == requests.codes.ok
assert result_raw.text.strip() == simple_proto_def.strip()

result_raw = self._request("GET",
f"schemas/ids/1",
headers=HTTP_GET_HEADERS,
auth=(super_username, super_password))
self.logger.info(result_raw)
assert result_raw.status_code == requests.codes.ok
result = result_raw.json()
assert result["schemaType"] == "PROTOBUF"
assert result["schema"].strip() == simple_proto_def.strip()

# Regular user should fail
result_raw = self._get_subjects_subject_versions_version_referenced_by(
"simple", 1, auth=(self.username, self.password))
assert result_raw.json()['error_code'] == 40101

result_raw = self._get_subjects_subject_versions_version_referenced_by(
"simple", 1, auth=(super_username, super_password))
self.logger.info(result_raw)
assert result_raw.status_code == requests.codes.ok
assert result_raw.json() == [2]

0 comments on commit c957334

Please sign in to comment.