File: test_basics.py

package info (click to toggle)
custodia 0.6.0-5.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 880 kB
  • sloc: python: 6,074; makefile: 317; sh: 62
file content (49 lines) | stat: -rw-r--r-- 2,009 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Copyright (C) 2017  Custodia Project Contributors - see LICENSE file

from __future__ import absolute_import

import json

from .base import CustodiaServerRunner


class TestBasics(CustodiaServerRunner):
    def test_default_answer(self, custodia_server):
        resp = custodia_server.get('http://localhost/',
                                   headers=self.request_headers)
        assert resp.status_code == 200
        data = json.loads(resp.text)
        assert 'message' in data
        assert data['message'] == 'Quis custodiet ipsos custodes?'

    def test_server_string(self, custodia_server):
        resp = custodia_server.get('http://localhost/',
                                   headers=self.request_headers)
        assert resp.status_code == 200
        assert 'Server' in resp.headers
        assert resp.headers['Server'] == 'Test_Custodia_Server'
        data = json.loads(resp.text)
        assert 'message' in data
        assert data['message'] == 'Quis custodiet ipsos custodes?'

    def test_raw_data_method(self, custodia_server):
        resp = custodia_server.post('secrets/bucket/',
                                    headers=self.request_headers)
        assert resp.status_code == 201

        resp = custodia_server.put('secrets/bucket/mykey',
                                   json={"type": "simple",
                                         "value": 'P@ssw0rd'},
                                   headers={'Content-Type':
                                            'application/octet-stream',
                                            'REMOTE_USER': 'me'})
        assert resp.status_code == 201

        resp = custodia_server.get('secrets/bucket/mykey', headers={
            'Content-Type': 'application/octet-stream', 'REMOTE_USER': 'me'})
        assert resp.status_code == 200
        data = json.loads(resp.text)
        assert 'type' in data
        assert data['type'] == 'simple'
        assert 'value' in data
        assert data['value'] == 'P@ssw0rd'