-
Notifications
You must be signed in to change notification settings - Fork 88
Expand file tree
/
Copy pathlogin_client_test.py
More file actions
73 lines (65 loc) · 2.12 KB
/
Copy pathlogin_client_test.py
File metadata and controls
73 lines (65 loc) · 2.12 KB
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
from unittest import TestCase
from linode_api4 import OAuthScopes
class OAuthScopesTest(TestCase):
def test_parse_scopes_none(self):
"""
Tests parsing no scopes
"""
scopes = OAuthScopes.parse("")
self.assertEqual(scopes, [])
def test_parse_scopes_single(self):
"""
Tests parsing a single scope
"""
scopes = OAuthScopes.parse("linodes:read_only")
self.assertEqual(scopes, [OAuthScopes.Linodes.read_only])
def test_parse_scopes_many(self):
"""
Tests parsing many scopes
"""
scopes = OAuthScopes.parse("linodes:read_only domains:read_write")
self.assertEqual(
scopes,
[OAuthScopes.Linodes.read_only, OAuthScopes.Domains.read_write],
)
def test_parse_scopes_many_comma_delimited(self):
"""
Tests parsing many scopes that are comma-delimited (which preserves old behavior)
"""
scopes = OAuthScopes.parse(
"nodebalancers:read_write,stackscripts:*,events:read_only"
)
self.assertEqual(
scopes,
[
OAuthScopes.NodeBalancers.read_write,
OAuthScopes.StackScripts.all,
OAuthScopes.Events.read_only,
],
)
def test_parse_scopes_all(self):
"""
Tests parsing * scopes
"""
scopes = OAuthScopes.parse("*")
self.assertEqual(
scopes,
[getattr(c, "all") for c in OAuthScopes._scope_families.values()],
)
def test_parse_scopes_databases_and_vpc(self):
"""
Tests parsing documented databases and vpc scopes
"""
scopes = OAuthScopes.parse(
"databases:read_only,databases:read_write,vpc:read_write,vpc:*"
)
self.assertEqual(
scopes,
[
OAuthScopes.Databases.read_only,
OAuthScopes.Databases.read_write,
OAuthScopes.VPC.read_write,
OAuthScopes.VPC.all,
],
)
self.assertEqual(OAuthScopes.parse("vpc:read_only"), [])