kubeclient 4.6.0 → 4.9.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of kubeclient might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.github/workflows/actions.yml +35 -0
- data/CHANGELOG.md +37 -0
- data/README.md +155 -37
- data/RELEASING.md +3 -1
- data/kubeclient.gemspec +5 -4
- data/lib/kubeclient.rb +1 -1
- data/lib/kubeclient/common.rb +35 -6
- data/lib/kubeclient/config.rb +17 -4
- data/lib/kubeclient/exec_credentials.rb +33 -4
- data/lib/kubeclient/google_application_default_credentials.rb +6 -1
- data/lib/kubeclient/version.rb +1 -1
- metadata +13 -217
- data/.travis.yml +0 -26
- data/test/cassettes/kubernetes_guestbook.yml +0 -879
- data/test/config/allinone.kubeconfig +0 -20
- data/test/config/execauth.kubeconfig +0 -62
- data/test/config/external-ca.pem +0 -18
- data/test/config/external-cert.pem +0 -19
- data/test/config/external-key.rsa +0 -27
- data/test/config/external.kubeconfig +0 -20
- data/test/config/gcpauth.kubeconfig +0 -22
- data/test/config/gcpcmdauth.kubeconfig +0 -26
- data/test/config/nouser.kubeconfig +0 -16
- data/test/config/oidcauth.kubeconfig +0 -25
- data/test/config/timestamps.kubeconfig +0 -25
- data/test/config/userauth.kubeconfig +0 -28
- data/test/json/bindings_list.json +0 -10
- data/test/json/component_status.json +0 -17
- data/test/json/component_status_list.json +0 -52
- data/test/json/config.istio.io_api_resource_list.json +0 -679
- data/test/json/config_map_list.json +0 -9
- data/test/json/core_api_resource_list.json +0 -181
- data/test/json/core_api_resource_list_without_kind.json +0 -129
- data/test/json/core_oapi_resource_list_without_kind.json +0 -197
- data/test/json/created_endpoint.json +0 -28
- data/test/json/created_namespace.json +0 -20
- data/test/json/created_secret.json +0 -16
- data/test/json/created_security_context_constraint.json +0 -65
- data/test/json/created_service.json +0 -31
- data/test/json/empty_pod_list.json +0 -9
- data/test/json/endpoint_list.json +0 -48
- data/test/json/entity_list.json +0 -56
- data/test/json/event_list.json +0 -35
- data/test/json/extensions_v1beta1_api_resource_list.json +0 -217
- data/test/json/limit_range.json +0 -23
- data/test/json/limit_range_list.json +0 -31
- data/test/json/namespace.json +0 -13
- data/test/json/namespace_exception.json +0 -8
- data/test/json/namespace_list.json +0 -32
- data/test/json/node.json +0 -29
- data/test/json/node_list.json +0 -37
- data/test/json/node_notice.json +0 -160
- data/test/json/persistent_volume.json +0 -37
- data/test/json/persistent_volume_claim.json +0 -32
- data/test/json/persistent_volume_claim_list.json +0 -40
- data/test/json/persistent_volume_claims_nil_items.json +0 -8
- data/test/json/persistent_volume_list.json +0 -45
- data/test/json/pod.json +0 -92
- data/test/json/pod_list.json +0 -79
- data/test/json/pod_template_list.json +0 -9
- data/test/json/pods_1.json +0 -265
- data/test/json/pods_2.json +0 -102
- data/test/json/pods_410.json +0 -9
- data/test/json/processed_template.json +0 -27
- data/test/json/replication_controller.json +0 -57
- data/test/json/replication_controller_list.json +0 -66
- data/test/json/resource_quota.json +0 -46
- data/test/json/resource_quota_list.json +0 -54
- data/test/json/secret_list.json +0 -44
- data/test/json/security.openshift.io_api_resource_list.json +0 -69
- data/test/json/security_context_constraint_list.json +0 -375
- data/test/json/service.json +0 -33
- data/test/json/service_account.json +0 -25
- data/test/json/service_account_list.json +0 -82
- data/test/json/service_illegal_json_404.json +0 -1
- data/test/json/service_json_patch.json +0 -26
- data/test/json/service_list.json +0 -97
- data/test/json/service_merge_patch.json +0 -26
- data/test/json/service_patch.json +0 -25
- data/test/json/service_update.json +0 -22
- data/test/json/template.json +0 -27
- data/test/json/template.openshift.io_api_resource_list.json +0 -75
- data/test/json/template_list.json +0 -35
- data/test/json/versions_list.json +0 -6
- data/test/json/watch_stream.json +0 -3
- data/test/test_common.rb +0 -95
- data/test/test_component_status.rb +0 -29
- data/test/test_config.rb +0 -222
- data/test/test_endpoint.rb +0 -54
- data/test/test_exec_credentials.rb +0 -125
- data/test/test_gcp_command_credentials.rb +0 -27
- data/test/test_google_application_default_credentials.rb +0 -15
- data/test/test_guestbook_go.rb +0 -235
- data/test/test_helper.rb +0 -18
- data/test/test_kubeclient.rb +0 -881
- data/test/test_limit_range.rb +0 -25
- data/test/test_missing_methods.rb +0 -80
- data/test/test_namespace.rb +0 -59
- data/test/test_node.rb +0 -70
- data/test/test_oidc_auth_provider.rb +0 -103
- data/test/test_persistent_volume.rb +0 -29
- data/test/test_persistent_volume_claim.rb +0 -28
- data/test/test_pod.rb +0 -81
- data/test/test_pod_log.rb +0 -157
- data/test/test_process_template.rb +0 -80
- data/test/test_replication_controller.rb +0 -47
- data/test/test_resource_list_without_kind.rb +0 -78
- data/test/test_resource_quota.rb +0 -23
- data/test/test_secret.rb +0 -62
- data/test/test_security_context_constraint.rb +0 -62
- data/test/test_service.rb +0 -330
- data/test/test_service_account.rb +0 -26
- data/test/test_watch.rb +0 -195
- data/test/txt/pod_log.txt +0 -6
- data/test/valid_token_file +0 -1
data/test/test_pod_log.rb
DELETED
@@ -1,157 +0,0 @@
|
|
1
|
-
require_relative 'test_helper'
|
2
|
-
|
3
|
-
# Pod log tests
|
4
|
-
class TestPodLog < MiniTest::Test
|
5
|
-
def test_get_pod_log
|
6
|
-
stub_request(:get, %r{/namespaces/default/pods/[a-z0-9-]+/log})
|
7
|
-
.to_return(body: open_test_file('pod_log.txt'),
|
8
|
-
status: 200)
|
9
|
-
|
10
|
-
client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
|
11
|
-
retrieved_log = client.get_pod_log('redis-master-pod', 'default')
|
12
|
-
|
13
|
-
assert_equal(open_test_file('pod_log.txt').read, retrieved_log)
|
14
|
-
|
15
|
-
assert_requested(:get,
|
16
|
-
'http://localhost:8080/api/v1/namespaces/default/pods/redis-master-pod/log',
|
17
|
-
times: 1)
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_get_pod_log_container
|
21
|
-
stub_request(:get, %r{/namespaces/default/pods/[a-z0-9-]+/log})
|
22
|
-
.to_return(body: open_test_file('pod_log.txt'),
|
23
|
-
status: 200)
|
24
|
-
|
25
|
-
client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
|
26
|
-
retrieved_log = client.get_pod_log('redis-master-pod', 'default', container: 'ruby')
|
27
|
-
|
28
|
-
assert_equal(open_test_file('pod_log.txt').read, retrieved_log)
|
29
|
-
|
30
|
-
assert_requested(:get,
|
31
|
-
'http://localhost:8080/api/v1/namespaces/default/pods/redis-master-pod/log?container=ruby',
|
32
|
-
times: 1)
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_get_pod_log_since_time
|
36
|
-
stub_request(:get, %r{/namespaces/default/pods/[a-z0-9-]+/log})
|
37
|
-
.to_return(body: open_test_file('pod_log.txt'),
|
38
|
-
status: 200)
|
39
|
-
|
40
|
-
client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
|
41
|
-
retrieved_log = client.get_pod_log('redis-master-pod',
|
42
|
-
'default',
|
43
|
-
timestamps: true,
|
44
|
-
since_time: '2018-04-27T18:30:17.480321984Z')
|
45
|
-
|
46
|
-
assert_equal(open_test_file('pod_log.txt').read, retrieved_log)
|
47
|
-
|
48
|
-
assert_requested(:get,
|
49
|
-
'http://localhost:8080/api/v1/namespaces/default/pods/redis-master-pod/log?sinceTime=2018-04-27T18:30:17.480321984Z×tamps=true',
|
50
|
-
times: 1)
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_get_pod_log_tail_lines
|
54
|
-
selected_lines = open_test_file('pod_log.txt').to_a[-2..1].join
|
55
|
-
|
56
|
-
stub_request(:get, %r{/namespaces/default/pods/[a-z0-9-]+/log})
|
57
|
-
.to_return(body: selected_lines,
|
58
|
-
status: 200)
|
59
|
-
|
60
|
-
client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
|
61
|
-
retrieved_log = client.get_pod_log('redis-master-pod',
|
62
|
-
'default',
|
63
|
-
tail_lines: 2)
|
64
|
-
|
65
|
-
assert_equal(selected_lines, retrieved_log)
|
66
|
-
|
67
|
-
assert_requested(:get,
|
68
|
-
'http://localhost:8080/api/v1/namespaces/default/pods/redis-master-pod/log?tailLines=2',
|
69
|
-
times: 1)
|
70
|
-
end
|
71
|
-
|
72
|
-
def test_get_pod_limit_bytes
|
73
|
-
selected_bytes = open_test_file('pod_log.txt').read(10)
|
74
|
-
|
75
|
-
stub_request(:get, %r{/namespaces/default/pods/[a-z0-9-]+/log})
|
76
|
-
.to_return(body: selected_bytes,
|
77
|
-
status: 200)
|
78
|
-
|
79
|
-
client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
|
80
|
-
retrieved_log = client.get_pod_log('redis-master-pod',
|
81
|
-
'default',
|
82
|
-
limit_bytes: 10)
|
83
|
-
|
84
|
-
assert_equal(selected_bytes, retrieved_log)
|
85
|
-
|
86
|
-
assert_requested(:get,
|
87
|
-
'http://localhost:8080/api/v1/namespaces/default/pods/redis-master-pod/log?limitBytes=10',
|
88
|
-
times: 1)
|
89
|
-
end
|
90
|
-
|
91
|
-
def test_watch_pod_log
|
92
|
-
file = open_test_file('pod_log.txt')
|
93
|
-
expected_lines = file.read.split("\n")
|
94
|
-
|
95
|
-
stub_request(:get, %r{/namespaces/default/pods/[a-z0-9-]+/log\?.*follow})
|
96
|
-
.to_return(body: file, status: 200)
|
97
|
-
|
98
|
-
client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
|
99
|
-
|
100
|
-
stream = client.watch_pod_log('redis-master-pod', 'default')
|
101
|
-
stream.to_enum.with_index do |notice, index|
|
102
|
-
assert_instance_of(String, notice)
|
103
|
-
assert_equal(expected_lines[index], notice)
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
def test_watch_pod_log_with_block
|
108
|
-
file = open_test_file('pod_log.txt')
|
109
|
-
first = file.readlines.first.chomp
|
110
|
-
|
111
|
-
stub_request(:get, %r{/namespaces/default/pods/[a-z0-9-]+/log\?.*follow})
|
112
|
-
.to_return(body: file, status: 200)
|
113
|
-
|
114
|
-
client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
|
115
|
-
|
116
|
-
client.watch_pod_log('redis-master-pod', 'default') do |line|
|
117
|
-
assert_equal first, line
|
118
|
-
break
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
def test_watch_pod_log_follow_redirect
|
123
|
-
expected_lines = open_test_file('pod_log.txt').read.split("\n")
|
124
|
-
redirect = 'http://localhost:1234/api/namespaces/default/pods/redis-master-pod/log'
|
125
|
-
|
126
|
-
stub_request(:get, %r{/namespaces/default/pods/[a-z0-9-]+/log\?.*follow})
|
127
|
-
.to_return(status: 302, headers: { location: redirect })
|
128
|
-
|
129
|
-
stub_request(:get, redirect)
|
130
|
-
.to_return(body: open_test_file('pod_log.txt'),
|
131
|
-
status: 200)
|
132
|
-
|
133
|
-
client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
|
134
|
-
stream = client.watch_pod_log('redis-master-pod', 'default')
|
135
|
-
stream.to_enum.with_index do |notice, index|
|
136
|
-
assert_instance_of(String, notice)
|
137
|
-
assert_equal(expected_lines[index], notice)
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
def test_watch_pod_log_max_redirect
|
142
|
-
redirect = 'http://localhost:1234/api/namespaces/default/pods/redis-master-pod/log'
|
143
|
-
|
144
|
-
stub_request(:get, %r{/namespaces/default/pods/[a-z0-9-]+/log\?.*follow})
|
145
|
-
.to_return(status: 302, headers: { location: redirect })
|
146
|
-
|
147
|
-
stub_request(:get, redirect)
|
148
|
-
.to_return(body: open_test_file('pod_log.txt'),
|
149
|
-
status: 200)
|
150
|
-
|
151
|
-
client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1', http_max_redirects: 0)
|
152
|
-
assert_raises(Kubeclient::HttpError) do
|
153
|
-
client.watch_pod_log('redis-master-pod', 'default').each do
|
154
|
-
end
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end
|
@@ -1,80 +0,0 @@
|
|
1
|
-
require_relative 'test_helper'
|
2
|
-
|
3
|
-
# Process Template tests
|
4
|
-
class TestProcessTemplate < MiniTest::Test
|
5
|
-
def test_process_template
|
6
|
-
client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
|
7
|
-
template = {}
|
8
|
-
template[:metadata] = {}
|
9
|
-
template[:metadata][:name] = 'my-template'
|
10
|
-
template[:metadata][:namespace] = 'default'
|
11
|
-
template[:kind] = 'Template'
|
12
|
-
template[:apiVersion] = 'v1'
|
13
|
-
service = {}
|
14
|
-
service[:metadata] = {}
|
15
|
-
service[:metadata][:name] = '${NAME_PREFIX}my-service'
|
16
|
-
service[:kind] = 'Service'
|
17
|
-
service[:apiVersion] = 'v1'
|
18
|
-
template[:objects] = [service]
|
19
|
-
param = { name: 'NAME_PREFIX', value: 'test/' }
|
20
|
-
template[:parameters] = [param]
|
21
|
-
|
22
|
-
req_body = '{"metadata":{"name":"my-template","namespace":"default"},' \
|
23
|
-
'"kind":"Template","apiVersion":"v1","objects":[{"metadata":' \
|
24
|
-
'{"name":"${NAME_PREFIX}my-service"},"kind":"Service","apiVersion":"v1"}],' \
|
25
|
-
'"parameters":[{"name":"NAME_PREFIX","value":"test/"}]}'
|
26
|
-
|
27
|
-
expected_url = 'http://localhost:8080/api/v1/namespaces/default/processedtemplates'
|
28
|
-
stub_request(:post, expected_url)
|
29
|
-
.with(body: req_body, headers: { 'Content-Type' => 'application/json' })
|
30
|
-
.to_return(body: open_test_file('processed_template.json'), status: 200)
|
31
|
-
|
32
|
-
processed_template = client.process_template(template)
|
33
|
-
|
34
|
-
assert_equal('test/my-service', processed_template['objects'].first['metadata']['name'])
|
35
|
-
|
36
|
-
assert_requested(:post, expected_url, times: 1) do |req|
|
37
|
-
data = JSON.parse(req.body)
|
38
|
-
data['kind'] == 'Template' &&
|
39
|
-
data['apiVersion'] == 'v1' &&
|
40
|
-
data['metadata']['name'] == 'my-template' &&
|
41
|
-
data['metadata']['namespace'] == 'default'
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
# Ensure _template and _templates methods hit `/templates` rather than
|
46
|
-
# `/processedtemplates` URL.
|
47
|
-
def test_templates_methods
|
48
|
-
stub_request(:get, %r{/apis/template\.openshift\.io/v1$}).to_return(
|
49
|
-
body: open_test_file('template.openshift.io_api_resource_list.json'),
|
50
|
-
status: 200
|
51
|
-
)
|
52
|
-
client = Kubeclient::Client.new('http://localhost:8080/apis/template.openshift.io', 'v1')
|
53
|
-
|
54
|
-
expected_url = 'http://localhost:8080/apis/template.openshift.io/v1/namespaces/default/templates'
|
55
|
-
stub_request(:get, expected_url)
|
56
|
-
.to_return(body: open_test_file('template_list.json'), status: 200)
|
57
|
-
client.get_templates(namespace: 'default')
|
58
|
-
assert_requested(:get, expected_url, times: 1)
|
59
|
-
|
60
|
-
expected_url = 'http://localhost:8080/apis/template.openshift.io/v1/namespaces/default/templates/my-template'
|
61
|
-
stub_request(:get, expected_url)
|
62
|
-
.to_return(body: open_test_file('template.json'), status: 200)
|
63
|
-
client.get_template('my-template', 'default')
|
64
|
-
assert_requested(:get, expected_url, times: 1)
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_no_processedtemplates_methods
|
68
|
-
stub_request(:get, %r{/apis/template\.openshift\.io/v1$}).to_return(
|
69
|
-
body: open_test_file('template.openshift.io_api_resource_list.json'),
|
70
|
-
status: 200
|
71
|
-
)
|
72
|
-
client = Kubeclient::Client.new('http://localhost:8080/apis/template.openshift.io', 'v1')
|
73
|
-
client.discover
|
74
|
-
|
75
|
-
refute_respond_to(client, :get_processedtemplates)
|
76
|
-
refute_respond_to(client, :get_processedtemplate)
|
77
|
-
refute_respond_to(client, :get_processed_templates)
|
78
|
-
refute_respond_to(client, :get_processed_template)
|
79
|
-
end
|
80
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
require_relative 'test_helper'
|
2
|
-
|
3
|
-
# Replication Controller entity tests
|
4
|
-
class TestReplicationController < MiniTest::Test
|
5
|
-
def test_get_from_json_v1
|
6
|
-
stub_core_api_list
|
7
|
-
stub_request(:get, %r{/replicationcontrollers})
|
8
|
-
.to_return(body: open_test_file('replication_controller.json'),
|
9
|
-
status: 200)
|
10
|
-
|
11
|
-
client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
|
12
|
-
rc = client.get_replication_controller('frontendController', 'default')
|
13
|
-
|
14
|
-
assert_instance_of(Kubeclient::Resource, rc)
|
15
|
-
assert_equal('guestbook-controller', rc.metadata.name)
|
16
|
-
assert_equal('c71aa4c0-a240-11e4-a265-3c970e4a436a', rc.metadata.uid)
|
17
|
-
assert_equal('default', rc.metadata.namespace)
|
18
|
-
assert_equal(3, rc.spec.replicas)
|
19
|
-
assert_equal('guestbook', rc.spec.selector.name)
|
20
|
-
|
21
|
-
assert_requested(:get,
|
22
|
-
'http://localhost:8080/api/v1/namespaces/default/replicationcontrollers/frontendController',
|
23
|
-
times: 1)
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_delete_replicaset_cascade
|
27
|
-
stub_core_api_list
|
28
|
-
client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
|
29
|
-
opts = Kubeclient::Resource.new(
|
30
|
-
apiVersion: 'meta/v1',
|
31
|
-
gracePeriodSeconds: 0,
|
32
|
-
kind: 'DeleteOptions',
|
33
|
-
propagationPolicy: 'Foreground'
|
34
|
-
)
|
35
|
-
|
36
|
-
stub_request(:delete,
|
37
|
-
'http://localhost:8080/api/v1/namespaces/default/replicationcontrollers/frontendController')
|
38
|
-
.with(body: opts.to_hash.to_json)
|
39
|
-
.to_return(status: 200, body: open_test_file('replication_controller.json'), headers: {})
|
40
|
-
rc = client.delete_replication_controller('frontendController', 'default', delete_options: opts)
|
41
|
-
assert_kind_of(RecursiveOpenStruct, rc)
|
42
|
-
|
43
|
-
assert_requested(:delete,
|
44
|
-
'http://localhost:8080/api/v1/namespaces/default/replicationcontrollers/frontendController',
|
45
|
-
times: 1)
|
46
|
-
end
|
47
|
-
end
|
@@ -1,78 +0,0 @@
|
|
1
|
-
require_relative 'test_helper'
|
2
|
-
|
3
|
-
# Core api resource list without kind tests
|
4
|
-
class TestResourceListWithoutKind < MiniTest::Test
|
5
|
-
def test_get_from_json_api_v1
|
6
|
-
stub_request(:get, %r{/api/v1$})
|
7
|
-
.to_return(body: open_test_file('core_api_resource_list_without_kind.json'),
|
8
|
-
status: 200)
|
9
|
-
|
10
|
-
client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
|
11
|
-
client.discover
|
12
|
-
|
13
|
-
[
|
14
|
-
{
|
15
|
-
entity: 'pod',
|
16
|
-
type: 'Pod',
|
17
|
-
name: 'pods',
|
18
|
-
methods: %w[pod pods]
|
19
|
-
},
|
20
|
-
{
|
21
|
-
entity: 'node',
|
22
|
-
type: 'Node',
|
23
|
-
name: 'nodes',
|
24
|
-
methods: %w[node nodes]
|
25
|
-
},
|
26
|
-
{
|
27
|
-
entity: 'service',
|
28
|
-
type: 'Service',
|
29
|
-
name: 'services',
|
30
|
-
methods: %w[service services]
|
31
|
-
}
|
32
|
-
].each { |h| assert_entities(client.instance_variable_get(:@entities)[h[:entity]], h) }
|
33
|
-
|
34
|
-
assert_requested(:get,
|
35
|
-
'http://localhost:8080/api/v1',
|
36
|
-
times: 1)
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_get_from_json_oapi_v1
|
40
|
-
stub_request(:get, %r{/oapi/v1$})
|
41
|
-
.to_return(body: open_test_file('core_oapi_resource_list_without_kind.json'),
|
42
|
-
status: 200)
|
43
|
-
|
44
|
-
client = Kubeclient::Client.new('http://localhost:8080/oapi/', 'v1')
|
45
|
-
client.discover
|
46
|
-
|
47
|
-
[
|
48
|
-
{
|
49
|
-
entity: 'template',
|
50
|
-
type: 'Template',
|
51
|
-
name: 'templates',
|
52
|
-
methods: %w[template templates]
|
53
|
-
},
|
54
|
-
{
|
55
|
-
entity: 'build',
|
56
|
-
type: 'Build',
|
57
|
-
name: 'builds',
|
58
|
-
methods: %w[build builds]
|
59
|
-
},
|
60
|
-
{
|
61
|
-
entity: 'project',
|
62
|
-
type: 'Project',
|
63
|
-
name: 'projects',
|
64
|
-
methods: %w[project projects]
|
65
|
-
}
|
66
|
-
].each { |h| assert_entities(client.instance_variable_get(:@entities)[h[:entity]], h) }
|
67
|
-
|
68
|
-
assert_requested(:get,
|
69
|
-
'http://localhost:8080/oapi/v1',
|
70
|
-
times: 1)
|
71
|
-
end
|
72
|
-
|
73
|
-
def assert_entities(entity, h)
|
74
|
-
assert_equal(entity.entity_type, h[:type])
|
75
|
-
assert_equal(entity.resource_name, h[:name])
|
76
|
-
assert_equal(entity.method_names, h[:methods])
|
77
|
-
end
|
78
|
-
end
|
data/test/test_resource_quota.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
require_relative 'test_helper'
|
2
|
-
|
3
|
-
# ResourceQuota tests
|
4
|
-
class TestResourceQuota < MiniTest::Test
|
5
|
-
def test_get_from_json_v1
|
6
|
-
stub_core_api_list
|
7
|
-
stub_request(:get, %r{/resourcequotas})
|
8
|
-
.to_return(body: open_test_file('resource_quota.json'),
|
9
|
-
status: 200)
|
10
|
-
|
11
|
-
client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
|
12
|
-
quota = client.get_resource_quota('quota', 'quota-example')
|
13
|
-
|
14
|
-
assert_instance_of(Kubeclient::Resource, quota)
|
15
|
-
assert_equal('quota', quota.metadata.name)
|
16
|
-
assert_equal('20', quota.spec.hard.cpu)
|
17
|
-
assert_equal('10', quota.spec.hard.secrets)
|
18
|
-
|
19
|
-
assert_requested(:get,
|
20
|
-
'http://localhost:8080/api/v1/namespaces/quota-example/resourcequotas/quota',
|
21
|
-
times: 1)
|
22
|
-
end
|
23
|
-
end
|
data/test/test_secret.rb
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
require_relative 'test_helper'
|
2
|
-
|
3
|
-
# Namespace entity tests
|
4
|
-
class TestSecret < MiniTest::Test
|
5
|
-
def test_get_secret_v1
|
6
|
-
stub_core_api_list
|
7
|
-
stub_request(:get, %r{/secrets})
|
8
|
-
.to_return(body: open_test_file('created_secret.json'),
|
9
|
-
status: 200)
|
10
|
-
|
11
|
-
client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
|
12
|
-
secret = client.get_secret('test-secret', 'dev')
|
13
|
-
|
14
|
-
assert_instance_of(Kubeclient::Resource, secret)
|
15
|
-
assert_equal('4e38a198-2bcb-11e5-a483-0e840567604d', secret.metadata.uid)
|
16
|
-
assert_equal('test-secret', secret.metadata.name)
|
17
|
-
assert_equal('v1', secret.apiVersion)
|
18
|
-
assert_equal('Y2F0J3MgYXJlIGF3ZXNvbWUK', secret.data['super-secret'])
|
19
|
-
|
20
|
-
assert_requested(:get,
|
21
|
-
'http://localhost:8080/api/v1/namespaces/dev/secrets/test-secret',
|
22
|
-
times: 1)
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_delete_secret_v1
|
26
|
-
stub_core_api_list
|
27
|
-
stub_request(:delete, %r{/secrets})
|
28
|
-
.to_return(status: 200, body: open_test_file('created_secret.json'))
|
29
|
-
|
30
|
-
client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
|
31
|
-
secret = client.delete_secret('test-secret', 'dev')
|
32
|
-
assert_kind_of(RecursiveOpenStruct, secret)
|
33
|
-
|
34
|
-
assert_requested(:delete,
|
35
|
-
'http://localhost:8080/api/v1/namespaces/dev/secrets/test-secret',
|
36
|
-
times: 1)
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_create_secret_v1
|
40
|
-
stub_core_api_list
|
41
|
-
stub_request(:post, %r{/secrets})
|
42
|
-
.to_return(body: open_test_file('created_secret.json'),
|
43
|
-
status: 201)
|
44
|
-
|
45
|
-
secret = Kubeclient::Resource.new
|
46
|
-
secret.metadata = {}
|
47
|
-
secret.metadata.name = 'test-secret'
|
48
|
-
secret.metadata.namespace = 'dev'
|
49
|
-
secret.data = {}
|
50
|
-
secret.data['super-secret'] = 'Y2F0J3MgYXJlIGF3ZXNvbWUK'
|
51
|
-
|
52
|
-
client = Kubeclient::Client.new('http://localhost:8080/api/')
|
53
|
-
created_secret = client.create_secret(secret)
|
54
|
-
assert_instance_of(Kubeclient::Resource, created_secret)
|
55
|
-
assert_equal(secret.metadata.name, created_secret.metadata.name)
|
56
|
-
assert_equal(secret.metadata.namespace, created_secret.metadata.namespace)
|
57
|
-
assert_equal(
|
58
|
-
secret.data['super-secret'],
|
59
|
-
created_secret.data['super-secret']
|
60
|
-
)
|
61
|
-
end
|
62
|
-
end
|