-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.py
More file actions
61 lines (42 loc) · 1.29 KB
/
tests.py
File metadata and controls
61 lines (42 loc) · 1.29 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
# pylint: disable=redefined-outer-name
from __future__ import absolute_import
from custodia.compat import configparser
from custodia.openshift.auth import ContainerAuth
from custodia.openshift.authz import OpenShiftHostnameAuthz
import pkg_resources
import pytest
CONFIG = u"""
[auth:container]
handler = ContainerAuth
[authz:openshift]
handler = OpenShiftHostnameAuthz
oc_uri = https://localhost:8443
token = bearertoken
project = test
tls_verify = False
"""
@pytest.fixture
def parser():
parser = configparser.ConfigParser(
interpolation=configparser.ExtendedInterpolation(),
)
parser.read_string(CONFIG)
return parser
@pytest.fixture
def containerauth(parser):
return ContainerAuth(parser, 'auth:container')
@pytest.fixture
def osauthz(parser):
return OpenShiftHostnameAuthz(parser, 'authz:openshift')
def test_auth_ok(containerauth):
pass
def test_authz_ok(osauthz):
pass
@pytest.mark.parametrize('group,name,cls', [
('custodia.authenticators', 'ContainerAuth', ContainerAuth),
('custodia.authorizers', 'OpenShiftHostnameAuthz', OpenShiftHostnameAuthz),
])
def test_plugins(group, name, cls, dist='custodia.openshift'):
ep = pkg_resources.get_entry_info(dist, group, name)
assert ep.dist.project_name == dist
assert ep.resolve() is cls