File: test_user_bypass_codes.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 (98 lines) | stat: -rw-r--r-- 3,606 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
from .. import util
import duo_client.admin
from .base import TestAdmin


class TestUserBypassCodes(TestAdmin):
    def test_get_user_bypass_codes(self):
        """ Test to get bypass codes by user id.
        """
        response = self.client_list.get_user_bypass_codes(
            'DU012345678901234567')[0]
        uri, args = response['uri'].split('?')

        self.assertEqual(response['method'], 'GET')
        self.assertEqual(
            uri,
            '/admin/v1/users/DU012345678901234567/bypass_codes')
        self.assertEqual(
            util.params_to_dict(args),
            {
                'account_id': [self.client.account_id],
                'limit': ['100'],
                'offset': ['0'],
            })

    def test_get_user_bypass_codes_iterator(self):
        """ Test to get bypass codes iterator by user id.
        """
        iterator = self.client_list.get_user_bypass_codes_iterator(
            'DU012345678901234567')
        response = next(iterator)
        uri, args = response['uri'].split('?')

        self.assertEqual(response['method'], 'GET')
        self.assertEqual(
            uri,
            '/admin/v1/users/DU012345678901234567/bypass_codes')
        self.assertEqual(
            util.params_to_dict(args),
            {
                'account_id': [self.client.account_id],
                'limit': ['100'],
                'offset': ['0'],
            })

    def test_get_user_bypass_codes_with_offset(self):
        """ Test to get bypass codes by user id with pagination params.
        """
        response = self.client_list.get_user_bypass_codes(
            'DU012345678901234567', offset=30)[0]
        uri, args = response['uri'].split('?')

        self.assertEqual(response['method'], 'GET')
        self.assertEqual(
            uri,
            '/admin/v1/users/DU012345678901234567/bypass_codes')
        self.assertEqual(util.params_to_dict(args),
                         {
                            'account_id': [self.client.account_id],
                            'limit': ['100'],
                            'offset': ['0'],
                         })

    def test_get_user_bypass_codes_with_limit(self):
        """ Test to get bypass codes by user id with pagination params.
        """
        response = self.client_list.get_user_bypass_codes(
            'DU012345678901234567', limit=10)[0]
        uri, args = response['uri'].split('?')

        self.assertEqual(response['method'], 'GET')
        self.assertEqual(
            uri,
            '/admin/v1/users/DU012345678901234567/bypass_codes')
        self.assertEqual(util.params_to_dict(args),
                         {
                            'account_id': [self.client.account_id],
                            'limit': ['10'],
                            'offset': ['0'],
                         })

    def test_get_user_bypass_codes_with_limit_and_offset(self):
        """ Test to get bypass codes by user id with pagination params.
        """
        response = self.client_list.get_user_bypass_codes(
            'DU012345678901234567', limit=10, offset=30)[0]
        uri, args = response['uri'].split('?')

        self.assertEqual(response['method'], 'GET')
        self.assertEqual(
            uri,
            '/admin/v1/users/DU012345678901234567/bypass_codes')
        self.assertEqual(util.params_to_dict(args),
                         {
                            'account_id': [self.client.account_id],
                            'limit': ['10'],
                            'offset': ['30'],
                         })