-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
53 lines (42 loc) · 1.36 KB
/
test.py
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
#!/usr/bin/env python
import ssl
from os.path import abspath, dirname, join
from kombu.connection import Connection
import pytest
@pytest.fixture
def certs_dir():
return join(dirname(abspath(__file__)), "certs")
def test_connection():
conn = Connection('amqp://guest:guest@localhost:5672/')
conn.connect()
assert conn.connected
conn.release()
def test_secure_connection(certs_dir):
conn = Connection('amqp://guest:guest@localhost:5671/', ssl={
'ca_certs': join(certs_dir, 'cacert.pem'),
'keyfile': join(certs_dir, 'clientkey.pem'),
'certfile': join(certs_dir, 'clientcert.pem'),
'cert_reqs': ssl.CERT_REQUIRED,
})
conn.connect()
assert conn.connected
conn.release()
def test_secure_connection_without_cert_verification(certs_dir):
conn = Connection('amqp://guest:guest@localhost:5671/', ssl=True)
conn.connect()
assert conn.connected
conn.release()
def test_external_login_method(certs_dir):
conn = Connection(
'amqp://localhost:5671/',
login_method="EXTERNAL",
ssl={
'ca_certs': join(certs_dir, 'cacert.pem'),
'keyfile': join(certs_dir, 'clientkey.pem'),
'certfile': join(certs_dir, 'clientcert.pem'),
'cert_reqs': ssl.CERT_REQUIRED,
},
)
conn.connect()
assert conn.connected
conn.release()