9
9
universes_count 1
10
10
"""
11
11
12
+
12
13
@pytest .mark .django_db
13
14
def test_e2e (client ):
14
15
resp = client .get ("/metrics" )
15
- assert (
16
- resp .content .decode ()
17
- == expected_output
18
- )
16
+ assert resp .content .decode () == expected_output
17
+
19
18
20
- @override_settings (AETOS_ENABLE_IP_ALLOWLIST = True , AETOS_IP_ALLOWLIST = ["127.0.0.1" ], AETOS_ENABLE_AUTH = True , AETOS_AUTH_TOKENLIST = ["AhGei6ohghooDae" ])
19
+ @override_settings (
20
+ AETOS_ENABLE_IP_ALLOWLIST = True ,
21
+ AETOS_IP_ALLOWLIST = ["127.0.0.1" ],
22
+ AETOS_ENABLE_AUTH = True ,
23
+ AETOS_AUTH_TOKENLIST = ["AhGei6ohghooDae" ],
24
+ )
21
25
def test_settings ():
22
26
from django_aetos import app_settings
27
+
23
28
assert app_settings .ENABLE_IP_ALLOWLIST == True
24
29
assert app_settings .IP_ALLOWLIST == ["127.0.0.1" ]
25
30
assert app_settings .ENABLE_AUTH == True
26
31
assert app_settings .AUTH_TOKENLIST == ["AhGei6ohghooDae" ]
27
-
32
+
33
+
28
34
def test_settings_defaults ():
29
35
from django_aetos import app_settings
36
+
30
37
assert app_settings .ENABLE_IP_ALLOWLIST == False
31
38
assert app_settings .IP_ALLOWLIST == []
32
39
assert app_settings .ENABLE_AUTH == False
33
40
assert app_settings .AUTH_TOKENLIST == []
34
41
42
+
35
43
@pytest .mark .django_db
36
44
@override_settings (AETOS_ENABLE_IP_ALLOWLIST = True , AETOS_IP_ALLOWLIST = ["127.0.0.1" ])
37
45
def test_enable_allowed_ips (client ):
38
46
resp = client .get ("/metrics" )
39
- assert (
40
- resp .content .decode ()
41
- == expected_output
42
- )
47
+ assert resp .content .decode () == expected_output
48
+
43
49
44
50
@pytest .mark .django_db
45
51
@override_settings (AETOS_ENABLE_IP_ALLOWLIST = True , AETOS_IP_ALLOWLIST = ["255.0.0.1" ])
46
52
def test_enable_allowed_ips_not_allowed (client ):
47
53
resp = client .get ("/metrics" )
48
54
assert resp .status_code == 401
49
55
56
+
50
57
@pytest .mark .django_db
51
58
@override_settings (AETOS_ENABLE_AUTH = True , AETOS_AUTH_TOKENLIST = ["aquee4ro4Theeth" ])
52
59
def test_enable_auth (client ):
53
60
resp = client .get ("/metrics" , headers = {"Authorization" : "Bearer aquee4ro4Theeth" })
54
- assert (
55
- resp .content .decode ()
56
- == expected_output
57
- )
61
+ assert resp .content .decode () == expected_output
62
+
58
63
59
64
@pytest .mark .django_db
60
65
@override_settings (AETOS_ENABLE_AUTH = True , AETOS_AUTH_TOKENLIST = ["aquee4ro4Theeth" ])
61
66
def test_enable_auth_token_not_allowed (client ):
62
67
resp = client .get ("/metrics" , headers = {"Authorization" : "Bearer wr0ngt0kenf" })
63
68
assert resp .status_code == 401
64
69
70
+
65
71
@pytest .mark .django_db
66
- @override_settings (AETOS_ENABLE_IP_ALLOWLIST = True , AETOS_IP_ALLOWLIST = ["127.0.0.1" ], AETOS_ENABLE_AUTH = True , AETOS_AUTH_TOKENLIST = ["aquee4ro4Theeth" ])
72
+ @override_settings (
73
+ AETOS_ENABLE_IP_ALLOWLIST = True ,
74
+ AETOS_IP_ALLOWLIST = ["127.0.0.1" ],
75
+ AETOS_ENABLE_AUTH = True ,
76
+ AETOS_AUTH_TOKENLIST = ["aquee4ro4Theeth" ],
77
+ )
67
78
def test_enable_all (client ):
68
79
resp = client .get ("/metrics" , headers = {"Authorization" : "Bearer aquee4ro4Theeth" })
69
- assert (
70
- resp .content .decode ()
71
- == expected_output
72
- )
80
+ assert resp .content .decode () == expected_output
81
+
73
82
74
83
@pytest .mark .django_db
75
- @override_settings (AETOS_ENABLE_IP_ALLOWLIST = True , AETOS_IP_ALLOWLIST = ["255.0.0.1" ], AETOS_ENABLE_AUTH = True , AETOS_AUTH_TOKENLIST = ["aquee4ro4Theeth" ])
84
+ @override_settings (
85
+ AETOS_ENABLE_IP_ALLOWLIST = True ,
86
+ AETOS_IP_ALLOWLIST = ["255.0.0.1" ],
87
+ AETOS_ENABLE_AUTH = True ,
88
+ AETOS_AUTH_TOKENLIST = ["aquee4ro4Theeth" ],
89
+ )
76
90
def test_enable_all_wrong_ip (client ):
77
91
resp = client .get ("/metrics" , headers = {"Authorization" : "Bearer aquee4ro4Theeth" })
78
92
assert resp .status_code == 401
79
93
94
+
80
95
@pytest .mark .django_db
81
- @override_settings (AETOS_ENABLE_IP_ALLOWLIST = True , AETOS_IP_ALLOWLIST = ["127.0.0.1" ], AETOS_ENABLE_AUTH = True , AETOS_AUTH_TOKENLIST = ["aquee4ro4Theeth" ])
96
+ @override_settings (
97
+ AETOS_ENABLE_IP_ALLOWLIST = True ,
98
+ AETOS_IP_ALLOWLIST = ["127.0.0.1" ],
99
+ AETOS_ENABLE_AUTH = True ,
100
+ AETOS_AUTH_TOKENLIST = ["aquee4ro4Theeth" ],
101
+ )
82
102
def test_enable_all_wrong_token (client ):
83
103
resp = client .get ("/metrics" , headers = {"Authorization" : "Bearer wr0ngt0ken" })
84
104
assert resp .status_code == 401
85
105
106
+
86
107
@pytest .mark .django_db
87
- @override_settings (AETOS_ENABLE_IP_ALLOWLIST = True , AETOS_IP_ALLOWLIST = ["255.0.0.1" ], AETOS_ENABLE_AUTH = True , AETOS_AUTH_TOKENLIST = ["aquee4ro4Theeth" ])
108
+ @override_settings (
109
+ AETOS_ENABLE_IP_ALLOWLIST = True ,
110
+ AETOS_IP_ALLOWLIST = ["255.0.0.1" ],
111
+ AETOS_ENABLE_AUTH = True ,
112
+ AETOS_AUTH_TOKENLIST = ["aquee4ro4Theeth" ],
113
+ )
88
114
def test_enable_all_wrong_token_ip (client ):
89
115
resp = client .get ("/metrics" , headers = {"Authorization" : "Bearer wr0ngt0ken" })
90
116
assert resp .status_code == 401
91
117
118
+
92
119
@pytest .mark .django_db
93
- @override_settings (AETOS_ENABLE_IP_ALLOWLIST = True , AETOS_ENABLE_AUTH = True , AETOS_AUTH_TOKENLIST = ["aquee4ro4Theeth" ])
120
+ @override_settings (
121
+ AETOS_ENABLE_IP_ALLOWLIST = True , AETOS_ENABLE_AUTH = True , AETOS_AUTH_TOKENLIST = ["aquee4ro4Theeth" ]
122
+ )
94
123
def test_enable_all_empty_ip (client ):
95
124
resp = client .get ("/metrics" , headers = {"Authorization" : "Bearer aquee4ro4Theeth" })
96
125
assert resp .status_code == 401
97
126
127
+
98
128
@pytest .mark .django_db
99
- @override_settings (AETOS_ENABLE_IP_ALLOWLIST = True , AETOS_IP_ALLOWLIST = ["127.0.0.1" ], AETOS_ENABLE_AUTH = True )
129
+ @override_settings (
130
+ AETOS_ENABLE_IP_ALLOWLIST = True , AETOS_IP_ALLOWLIST = ["127.0.0.1" ], AETOS_ENABLE_AUTH = True
131
+ )
100
132
def test_enable_all_empty_token (client ):
101
133
resp = client .get ("/metrics" , headers = {"Authorization" : "Bearer aquee4ro4Theeth" })
102
134
assert resp .status_code == 401
103
135
136
+
104
137
@pytest .mark .django_db
105
138
@override_settings (AETOS_ENABLE_IP_ALLOWLIST = True , AETOS_ENABLE_AUTH = True )
106
139
def test_enable_all_empty_token_ip (client ):
107
140
resp = client .get ("/metrics" , headers = {"Authorization" : "Bearer aquee4ro4Theeth" })
108
141
assert resp .status_code == 401
109
142
143
+
110
144
@pytest .mark .django_db
111
- @override_settings (AETOS_ENABLE_IP_ALLOWLIST = True , AETOS_IP_ALLOWLIST = ["127.0.0.1" ], AETOS_ENABLE_AUTH = True , AETOS_AUTH_TOKENLIST = ["aquee4ro4Theeth" ])
145
+ @override_settings (
146
+ AETOS_ENABLE_IP_ALLOWLIST = True ,
147
+ AETOS_IP_ALLOWLIST = ["127.0.0.1" ],
148
+ AETOS_ENABLE_AUTH = True ,
149
+ AETOS_AUTH_TOKENLIST = ["aquee4ro4Theeth" ],
150
+ )
112
151
def test_enable_all_wrong_auth_header (client ):
113
152
resp = client .get ("/metrics" , headers = {"Authorization" : "Basic aquee4ro4Theeth" })
114
- assert resp .status_code == 401
153
+ assert resp .status_code == 401
0 commit comments