-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
api_secret_test.py
71 lines (59 loc) · 2.25 KB
/
api_secret_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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import pytest
import docker
from ..helpers import force_leave_swarm, requires_api_version
from .base import BaseAPIIntegrationTest
@requires_api_version('1.25')
class SecretAPITest(BaseAPIIntegrationTest):
@classmethod
def setup_class(cls):
client = cls.get_client_instance()
force_leave_swarm(client)
cls._init_swarm(client)
@classmethod
def teardown_class(cls):
client = cls.get_client_instance()
force_leave_swarm(client)
def test_create_secret(self):
secret_id = self.client.create_secret(
'favorite_character', 'sakuya izayoi'
)
self.tmp_secrets.append(secret_id)
assert 'ID' in secret_id
data = self.client.inspect_secret(secret_id)
assert data['Spec']['Name'] == 'favorite_character'
def test_create_secret_unicode_data(self):
secret_id = self.client.create_secret(
'favorite_character', 'いざよいさくや'
)
self.tmp_secrets.append(secret_id)
assert 'ID' in secret_id
data = self.client.inspect_secret(secret_id)
assert data['Spec']['Name'] == 'favorite_character'
def test_inspect_secret(self):
secret_name = 'favorite_character'
secret_id = self.client.create_secret(
secret_name, 'sakuya izayoi'
)
self.tmp_secrets.append(secret_id)
data = self.client.inspect_secret(secret_id)
assert data['Spec']['Name'] == secret_name
assert 'ID' in data
assert 'Version' in data
def test_remove_secret(self):
secret_name = 'favorite_character'
secret_id = self.client.create_secret(
secret_name, 'sakuya izayoi'
)
self.tmp_secrets.append(secret_id)
assert self.client.remove_secret(secret_id)
with pytest.raises(docker.errors.NotFound):
self.client.inspect_secret(secret_id)
def test_list_secrets(self):
secret_name = 'favorite_character'
secret_id = self.client.create_secret(
secret_name, 'sakuya izayoi'
)
self.tmp_secrets.append(secret_id)
data = self.client.secrets(filters={'names': ['favorite_character']})
assert len(data) == 1
assert data[0]['ID'] == secret_id['ID']