Commit 237e5ab1 authored by Lukas Burgey's avatar Lukas Burgey
Browse files

Add more tests for the client API

parent 613b2c56
......@@ -155,14 +155,6 @@ class APIClientTest(TestCase):
def setupUp(self):
self.client = Client()
logged_in_client = authenticate(
username=self.API_CLIENT_NAME,
password=self.API_CLIENT_PASSWORD,
)
self.assertIsNotNone(logged_in_client)
self.client.force_login(
user=logged_in_client,
)
def auth_headers(self):
auth_str = '{}:{}'.format(
......
import logging
from feudal.backend import tests
from feudal.backend import tests, models
from feudal.backend.models import deployments
LOGGER = logging.getLogger(__name__)
class ConfigurationViewTest(tests.APIClientTest):
class ClientViewTest(tests.APIClientTest):
def test_configuration_entitlement(self):
response = self.client.put(
......@@ -55,3 +56,62 @@ class ConfigurationViewTest(tests.APIClientTest):
LOGGER.debug('response: %s', response)
LOGGER.debug('response json: %s', response.json())
self.assertEqual(response.status_code, 200)
def test_configuration_error(self):
services = {
"CVMFS": {
"name": "CERN VM FS",
"command": "xxxxxxxxxxxx",
"description": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
}
invalid_configs = [
{
"services": services,
"group_to_service_ids": None,
},
{
"services": services,
"group_to_service_ids": "",
},
{
"services": services,
"entitlement_to_service_ids": None,
},
{
"services": services,
"entitlement_to_service_ids": "",
},
]
for invalid_config in invalid_configs:
response = self.client.put(
'/backend/clientapi/config',
invalid_config,
content_type='application/json',
**self.auth_headers(),
)
LOGGER.debug('response: %s', response)
LOGGER.debug('response json: %s', response.json())
self.assertEqual(response.status_code, 200)
def test_deregister(self):
response = self.client.put(
'/backend/clientapi/deregister',
{
},
content_type='application/json',
**self.auth_headers(),
)
LOGGER.debug('response: %s', response)
LOGGER.debug('response json: %s', response.json())
self.assertEqual(response.status_code, 200)
def test_get_states(self):
response = self.client.get(
'/backend/clientapi/dep-states',
**self.auth_headers(),
)
LOGGER.debug('response: %s', response)
LOGGER.debug('response json: %s', response.json())
self.assertEqual(response.status_code, 200)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment