def test_secret_create(self): data = h1.copy() data['api_key'] = '123' hosts.create('host_1', data) h = hosts.get('host_1') self.assertNotEqual('123', h.api_key) self.assertTrue(SecretField.verify('123', h.api_key))
def test_container_create(self): h = h1.copy() h['containers'] = [{'name': 'c1', 'template': 'foo'}] hosts.create('host_1', h) h = hosts.get('host_1') self.assertEqual(1, h.containers.count()) self.assertEqual('foo', h.containers.get('c1').template) self.assertEqual('c1', h.to_dict()['containers'][0]['name'])
def host_create(): if "api_key" not in request.json: raise ModelError("Missing required field: api_key") request.json["enlisted"] = settings.AUTO_ENLIST_HOSTS name = request.json["name"] del request.json["name"] hosts.create(name, request.json) resp = jsonify({}) resp.status_code = 201 resp.headers["Location"] = "/api/v1/host/%s/" % name return resp
def host_create(): if 'api_key' not in request.json: raise ModelError('Missing required field: api_key') request.json['enlisted'] = settings.AUTO_ENLIST_HOSTS name = request.json['name'] del request.json['name'] hosts.create(name, request.json) resp = jsonify({}) resp.status_code = 201 resp.headers['Location'] = '/api/v1/host/%s/' % name return resp
def setUp(self): self.modelsdir = tempfile.mkdtemp() self.addCleanup(shutil.rmtree, self.modelsdir) hosts._model_dir = os.path.join(self.modelsdir, 'hosts') container_requests._model_dir = os.path.join(self.modelsdir, 'reqs') os.mkdir(hosts._model_dir) os.mkdir(container_requests._model_dir) hosts.create('host1', h1) hosts.create('host2', h1) self.host1 = hosts.get('host1') self.host2 = hosts.get('host2') self.container_data = { 'template': 'ubuntu', 'release': 'xenial', }
def test_empty_update(self): hosts.create('host_1', h1) self.assertEqual(1, hosts.count()) self.assertEqual('ubuntu', hosts.get('host_1').distro_id)