File: base.py

package info (click to toggle)
python-duo-client 5.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 768 kB
  • sloc: python: 7,105; sh: 6; makefile: 4
file content (54 lines) | stat: -rw-r--r-- 2,059 bytes parent folder | download
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
50
51
52
53
54
import unittest
from .. import util
import duo_client.admin
import os


class TestAdmin(unittest.TestCase):

    TEST_RESOURCES_DIR = dir_path = os.path.join(
        os.path.abspath(os.curdir), 'tests', 'resources')

    def setUp(self):
        self.client = duo_client.admin.Admin(
            'test_ikey', 'test_akey', 'example.com')
        self.client.account_id = 'DA012345678901234567'
        # monkeypatch client's _connect()
        self.client._connect = lambda: util.MockHTTPConnection()

        # if you are wanting to simulate getting lists of objects
        # rather than a single object
        self.client_list = duo_client.admin.Admin(
            'test_ikey', 'test_akey', 'example.com')
        self.client_list.account_id = 'DA012345678901234567'
        self.client_list._connect = \
            lambda: util.MockHTTPConnection(data_response_should_be_list=True)

        # if you are wanting to get a response from a call to get
        # authentication logs
        self.client_authlog = duo_client.admin.Admin(
            'test_ikey', 'test_akey', 'example.com')
        self.client_authlog.account_id = 'DA012345678901234567'
        self.client_authlog._connect = \
            lambda: util.MockHTTPConnection(data_response_from_get_authlog=True)

        # client to simulate basic structure of a call to fetch Duo Trust
        # Monitor events.
        self.client_dtm = duo_client.admin.Admin(
            'test_ikey',
            'test_akey',
            'example.com',
        )
        self.client_dtm.account_id = 'DA012345678901234567'
        self.client_dtm._connect = \
            lambda: util.MockHTTPConnection(data_response_from_get_dtm_events=True)

        self.items_response_client = duo_client.admin.Admin(
            'test_ikey', 'test_akey', 'example.com')
        self.items_response_client.account_id = 'DA012345678901234567'
        self.items_response_client._connect = \
            lambda: util.MockHTTPConnection(data_response_from_get_items=True)


if __name__ == '__main__':
    unittest.main()