Skip to content
This repository has been archived by the owner on Mar 7, 2023. It is now read-only.

tests: Add unit test for the '/admin/metadata/user' AdminOps API endpoint. #153

Merged
merged 1 commit into from
Aug 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion tests/s3gw-users-rest-api-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,21 @@ def setUp(self):
self.auth = S3Auth(UserRestAPITests.ACCESS_KEY, UserRestAPITests.SECRET_KEY, self.URL)

def test_smoke_test(self):
# list users using the metadata endpoint.
response = requests.get(self.URL + '/admin/metadata/user', auth=self.auth)
self.assertEqual(200, response.status_code)
json_response = json.loads(response.content)
self.assertIsInstance(json_response, list)
self.assertIn("testid", json_response)

# list users (we should get only testid (user created at startup))
response = requests.get(self.URL + '/admin/user?list', auth=self.auth)
self.assertEqual(200, response.status_code)
json_response = json.loads(response.content)
self.assertIsInstance(json_response, dict)
self.assertIsInstance(json_response["keys"], list)
self.assertEqual(1, len(json_response["keys"]))
self.assertEqual("testid", json_response["keys"][0])
self.assertIn("testid", json_response["keys"])

# add a user
response = requests.put(self.URL + '/admin/user?uid=user2&display-name=TEST+NAME', auth=self.auth)
Expand Down