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.

Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/actions.yml +35 -0
  3. data/CHANGELOG.md +37 -0
  4. data/README.md +155 -37
  5. data/RELEASING.md +3 -1
  6. data/kubeclient.gemspec +5 -4
  7. data/lib/kubeclient.rb +1 -1
  8. data/lib/kubeclient/common.rb +35 -6
  9. data/lib/kubeclient/config.rb +17 -4
  10. data/lib/kubeclient/exec_credentials.rb +33 -4
  11. data/lib/kubeclient/google_application_default_credentials.rb +6 -1
  12. data/lib/kubeclient/version.rb +1 -1
  13. metadata +13 -217
  14. data/.travis.yml +0 -26
  15. data/test/cassettes/kubernetes_guestbook.yml +0 -879
  16. data/test/config/allinone.kubeconfig +0 -20
  17. data/test/config/execauth.kubeconfig +0 -62
  18. data/test/config/external-ca.pem +0 -18
  19. data/test/config/external-cert.pem +0 -19
  20. data/test/config/external-key.rsa +0 -27
  21. data/test/config/external.kubeconfig +0 -20
  22. data/test/config/gcpauth.kubeconfig +0 -22
  23. data/test/config/gcpcmdauth.kubeconfig +0 -26
  24. data/test/config/nouser.kubeconfig +0 -16
  25. data/test/config/oidcauth.kubeconfig +0 -25
  26. data/test/config/timestamps.kubeconfig +0 -25
  27. data/test/config/userauth.kubeconfig +0 -28
  28. data/test/json/bindings_list.json +0 -10
  29. data/test/json/component_status.json +0 -17
  30. data/test/json/component_status_list.json +0 -52
  31. data/test/json/config.istio.io_api_resource_list.json +0 -679
  32. data/test/json/config_map_list.json +0 -9
  33. data/test/json/core_api_resource_list.json +0 -181
  34. data/test/json/core_api_resource_list_without_kind.json +0 -129
  35. data/test/json/core_oapi_resource_list_without_kind.json +0 -197
  36. data/test/json/created_endpoint.json +0 -28
  37. data/test/json/created_namespace.json +0 -20
  38. data/test/json/created_secret.json +0 -16
  39. data/test/json/created_security_context_constraint.json +0 -65
  40. data/test/json/created_service.json +0 -31
  41. data/test/json/empty_pod_list.json +0 -9
  42. data/test/json/endpoint_list.json +0 -48
  43. data/test/json/entity_list.json +0 -56
  44. data/test/json/event_list.json +0 -35
  45. data/test/json/extensions_v1beta1_api_resource_list.json +0 -217
  46. data/test/json/limit_range.json +0 -23
  47. data/test/json/limit_range_list.json +0 -31
  48. data/test/json/namespace.json +0 -13
  49. data/test/json/namespace_exception.json +0 -8
  50. data/test/json/namespace_list.json +0 -32
  51. data/test/json/node.json +0 -29
  52. data/test/json/node_list.json +0 -37
  53. data/test/json/node_notice.json +0 -160
  54. data/test/json/persistent_volume.json +0 -37
  55. data/test/json/persistent_volume_claim.json +0 -32
  56. data/test/json/persistent_volume_claim_list.json +0 -40
  57. data/test/json/persistent_volume_claims_nil_items.json +0 -8
  58. data/test/json/persistent_volume_list.json +0 -45
  59. data/test/json/pod.json +0 -92
  60. data/test/json/pod_list.json +0 -79
  61. data/test/json/pod_template_list.json +0 -9
  62. data/test/json/pods_1.json +0 -265
  63. data/test/json/pods_2.json +0 -102
  64. data/test/json/pods_410.json +0 -9
  65. data/test/json/processed_template.json +0 -27
  66. data/test/json/replication_controller.json +0 -57
  67. data/test/json/replication_controller_list.json +0 -66
  68. data/test/json/resource_quota.json +0 -46
  69. data/test/json/resource_quota_list.json +0 -54
  70. data/test/json/secret_list.json +0 -44
  71. data/test/json/security.openshift.io_api_resource_list.json +0 -69
  72. data/test/json/security_context_constraint_list.json +0 -375
  73. data/test/json/service.json +0 -33
  74. data/test/json/service_account.json +0 -25
  75. data/test/json/service_account_list.json +0 -82
  76. data/test/json/service_illegal_json_404.json +0 -1
  77. data/test/json/service_json_patch.json +0 -26
  78. data/test/json/service_list.json +0 -97
  79. data/test/json/service_merge_patch.json +0 -26
  80. data/test/json/service_patch.json +0 -25
  81. data/test/json/service_update.json +0 -22
  82. data/test/json/template.json +0 -27
  83. data/test/json/template.openshift.io_api_resource_list.json +0 -75
  84. data/test/json/template_list.json +0 -35
  85. data/test/json/versions_list.json +0 -6
  86. data/test/json/watch_stream.json +0 -3
  87. data/test/test_common.rb +0 -95
  88. data/test/test_component_status.rb +0 -29
  89. data/test/test_config.rb +0 -222
  90. data/test/test_endpoint.rb +0 -54
  91. data/test/test_exec_credentials.rb +0 -125
  92. data/test/test_gcp_command_credentials.rb +0 -27
  93. data/test/test_google_application_default_credentials.rb +0 -15
  94. data/test/test_guestbook_go.rb +0 -235
  95. data/test/test_helper.rb +0 -18
  96. data/test/test_kubeclient.rb +0 -881
  97. data/test/test_limit_range.rb +0 -25
  98. data/test/test_missing_methods.rb +0 -80
  99. data/test/test_namespace.rb +0 -59
  100. data/test/test_node.rb +0 -70
  101. data/test/test_oidc_auth_provider.rb +0 -103
  102. data/test/test_persistent_volume.rb +0 -29
  103. data/test/test_persistent_volume_claim.rb +0 -28
  104. data/test/test_pod.rb +0 -81
  105. data/test/test_pod_log.rb +0 -157
  106. data/test/test_process_template.rb +0 -80
  107. data/test/test_replication_controller.rb +0 -47
  108. data/test/test_resource_list_without_kind.rb +0 -78
  109. data/test/test_resource_quota.rb +0 -23
  110. data/test/test_secret.rb +0 -62
  111. data/test/test_security_context_constraint.rb +0 -62
  112. data/test/test_service.rb +0 -330
  113. data/test/test_service_account.rb +0 -26
  114. data/test/test_watch.rb +0 -195
  115. data/test/txt/pod_log.txt +0 -6
  116. data/test/valid_token_file +0 -1
@@ -1,25 +0,0 @@
1
- require_relative 'test_helper'
2
-
3
- # LimitRange tests
4
- class TestLimitRange < MiniTest::Test
5
- def test_get_from_json_v1
6
- stub_core_api_list
7
- stub_request(:get, %r{/limitranges})
8
- .to_return(body: open_test_file('limit_range.json'), status: 200)
9
-
10
- client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
11
- limit_range = client.get_limit_range('limits', 'quota-example')
12
-
13
- assert_instance_of(Kubeclient::Resource, limit_range)
14
- assert_equal('limits', limit_range.metadata.name)
15
- assert_equal('Container', limit_range.spec.limits[0].type)
16
- assert_equal('100m', limit_range.spec.limits[0].default.cpu)
17
- assert_equal('512Mi', limit_range.spec.limits[0].default.memory)
18
-
19
- assert_requested(
20
- :get,
21
- 'http://localhost:8080/api/v1/namespaces/quota-example/limitranges/limits',
22
- times: 1
23
- )
24
- end
25
- end
@@ -1,80 +0,0 @@
1
- require_relative 'test_helper'
2
-
3
- # Test method_missing, respond_to? and respond_to_missing behaviour
4
- class TestMissingMethods < MiniTest::Test
5
- def test_missing
6
- stub_core_api_list
7
- client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
8
- assert_equal(true, client.respond_to?(:get_pod))
9
- assert_equal(true, client.respond_to?(:get_pods))
10
- assert_equal(false, client.respond_to?(:get_pie))
11
- client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1') # Reset discovery
12
- assert_equal(false, client.respond_to?(:get_pie))
13
- assert_equal(true, client.respond_to?(:get_pods))
14
- assert_equal(true, client.respond_to?(:get_pod))
15
- client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1') # Reset discovery
16
- assert_instance_of(Method, client.method(:get_pods))
17
- assert_raises(NameError) do
18
- client.method(:get_pies)
19
- end
20
- client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1') # Reset discovery
21
- assert_raises(NameError) do
22
- client.method(:get_pies)
23
- end
24
- assert_instance_of(Method, client.method(:get_pods))
25
-
26
- stub_request(:get, %r{/api/v1$}).to_return(
27
- body: '',
28
- status: 404
29
- ) # If discovery fails we expect the below raise an exception
30
- client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
31
- assert_raises(Kubeclient::HttpError) do
32
- client.discover
33
- end
34
- client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
35
- assert_raises(Kubeclient::HttpError) do
36
- client.method(:get_pods)
37
- end
38
- client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
39
- assert_raises(Kubeclient::HttpError) do
40
- client.respond_to?(:get_pods)
41
- end
42
- end
43
-
44
- def test_nonsuffix_plurals
45
- stub_request(:get, %r{/apis/extensions/v1beta1$}).to_return(
46
- body: open_test_file('extensions_v1beta1_api_resource_list.json'),
47
- status: 200
48
- )
49
- client = Kubeclient::Client.new('http://localhost:8080/apis/extensions', 'v1beta1')
50
- assert_equal(true, client.respond_to?(:get_network_policy))
51
- assert_equal(true, client.respond_to?(:get_network_policies))
52
- assert_equal(true, client.respond_to?(:get_pod_security_policy))
53
- assert_equal(true, client.respond_to?(:get_pod_security_policies))
54
- end
55
-
56
- def test_irregular_names
57
- stub_core_api_list
58
- client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
59
- assert_equal(true, client.respond_to?(:get_endpoint))
60
- assert_equal(true, client.respond_to?(:get_endpoints))
61
-
62
- stub_request(:get, %r{/apis/security.openshift.io/v1$}).to_return(
63
- body: open_test_file('security.openshift.io_api_resource_list.json'),
64
- status: 200
65
- )
66
- client = Kubeclient::Client.new('http://localhost:8080/apis/security.openshift.io', 'v1')
67
- assert_equal(true, client.respond_to?(:get_security_context_constraint))
68
- assert_equal(true, client.respond_to?(:get_security_context_constraints))
69
- end
70
-
71
- def test_lowercase_kind
72
- stub_request(:get, %r{/apis/config.istio.io/v1alpha2$}).to_return(
73
- body: open_test_file('config.istio.io_api_resource_list.json'),
74
- status: 200
75
- )
76
- client = Kubeclient::Client.new('http://localhost:8080/apis/config.istio.io', 'v1alpha2')
77
- assert_equal(true, client.respond_to?(:get_servicecontrolreport))
78
- assert_equal(true, client.respond_to?(:get_servicecontrolreports))
79
- end
80
- end
@@ -1,59 +0,0 @@
1
- require_relative 'test_helper'
2
-
3
- # Namespace entity tests
4
- class TestNamespace < MiniTest::Test
5
- def test_get_namespace_v1
6
- stub_core_api_list
7
- stub_request(:get, %r{/namespaces})
8
- .to_return(body: open_test_file('namespace.json'), status: 200)
9
-
10
- client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
11
- namespace = client.get_namespace('staging')
12
-
13
- assert_instance_of(Kubeclient::Resource, namespace)
14
- assert_equal('e388bc10-c021-11e4-a514-3c970e4a436a', namespace.metadata.uid)
15
- assert_equal('staging', namespace.metadata.name)
16
- assert_equal('1168', namespace.metadata.resourceVersion)
17
- assert_equal('v1', namespace.apiVersion)
18
-
19
- assert_requested(
20
- :get,
21
- 'http://localhost:8080/api/v1/namespaces/staging',
22
- times: 1
23
- )
24
- end
25
-
26
- def test_delete_namespace_v1
27
- our_namespace = Kubeclient::Resource.new
28
- our_namespace.metadata = {}
29
- our_namespace.metadata.name = 'staging'
30
-
31
- stub_core_api_list
32
- stub_request(:delete, %r{/namespaces})
33
- .to_return(body: open_test_file('namespace.json'), status: 200)
34
- client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
35
- our_namespace = client.delete_namespace(our_namespace.metadata.name)
36
- assert_kind_of(RecursiveOpenStruct, our_namespace)
37
-
38
- assert_requested(
39
- :delete,
40
- 'http://localhost:8080/api/v1/namespaces/staging',
41
- times: 1
42
- )
43
- end
44
-
45
- def test_create_namespace
46
- stub_core_api_list
47
- stub_request(:post, %r{/namespaces})
48
- .to_return(body: open_test_file('created_namespace.json'), status: 201)
49
-
50
- namespace = Kubeclient::Resource.new
51
- namespace.metadata = {}
52
- namespace.metadata.name = 'development'
53
-
54
- client = Kubeclient::Client.new('http://localhost:8080/api/')
55
- created_namespace = client.create_namespace(namespace)
56
- assert_instance_of(Kubeclient::Resource, created_namespace)
57
- assert_equal(namespace.metadata.name, created_namespace.metadata.name)
58
- end
59
- end
data/test/test_node.rb DELETED
@@ -1,70 +0,0 @@
1
- require_relative 'test_helper'
2
-
3
- # Node entity tests
4
- class TestNode < MiniTest::Test
5
- def test_get_from_json_v1
6
- stub_core_api_list
7
- stub_request(:get, %r{/nodes})
8
- .to_return(body: open_test_file('node.json'), status: 200)
9
-
10
- client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
11
- node = client.get_node('127.0.0.1')
12
-
13
- assert_instance_of(Kubeclient::Resource, node)
14
-
15
- assert_equal('041143c5-ce39-11e4-ac24-3c970e4a436a', node.metadata.uid)
16
- assert_equal('127.0.0.1', node.metadata.name)
17
- assert_equal('1724', node.metadata.resourceVersion)
18
- assert_equal('v1', node.apiVersion)
19
- assert_equal('2015-03-19T15:08:20+02:00', node.metadata.creationTimestamp)
20
-
21
- assert_requested(
22
- :get,
23
- 'http://localhost:8080/api/v1',
24
- times: 1
25
- )
26
- assert_requested(
27
- :get,
28
- 'http://localhost:8080/api/v1/nodes/127.0.0.1',
29
- times: 1
30
- )
31
- end
32
-
33
- def test_get_from_json_v1_raw
34
- stub_core_api_list
35
- stub_request(:get, %r{/nodes})
36
- .to_return(body: open_test_file('node.json'), status: 200)
37
-
38
- client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
39
- response = client.get_node('127.0.0.1', nil, as: :raw)
40
-
41
- assert_equal(open_test_file('node.json').read, response)
42
-
43
- assert_requested(
44
- :get,
45
- 'http://localhost:8080/api/v1',
46
- times: 1
47
- )
48
- assert_requested(
49
- :get,
50
- 'http://localhost:8080/api/v1/nodes/127.0.0.1',
51
- times: 1
52
- )
53
- end
54
-
55
- def test_get_from_json_v1_raw_error
56
- stub_request(:get, %r{/nodes})
57
- .to_return(body: open_test_file('node.json'), status: 200)
58
- stub_request(:get, %r{/api/v1$})
59
- .to_return(body: open_test_file('core_api_resource_list.json'), status: 500)
60
-
61
- client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
62
-
63
- exception = assert_raises(Kubeclient::HttpError) do
64
- client.get_node('127.0.0.1', nil, as: :raw)
65
- end
66
-
67
- assert_instance_of(Kubeclient::HttpError, exception)
68
- assert_equal('500 Internal Server Error', exception.message)
69
- end
70
- end
@@ -1,103 +0,0 @@
1
- require_relative 'test_helper'
2
- require 'openid_connect'
3
-
4
- class OIDCAuthProviderTest < MiniTest::Test
5
- def setup
6
- @client_id = 'client_id'
7
- @client_secret = 'client_secret'
8
- @idp_issuer_url = 'idp_issuer_url'
9
- @refresh_token = 'refresh_token'
10
- @id_token = 'id_token'
11
- @new_id_token = 'new_id_token'
12
- end
13
-
14
- def test_expired_token
15
- OpenIDConnect::Discovery::Provider::Config.stub(:discover!, discovery_mock) do
16
- OpenIDConnect::ResponseObject::IdToken.stub(:decode, id_token_mock(Time.now.to_i - 7200)) do
17
- OpenIDConnect::Client.stub(:new, openid_client_mock) do
18
- retrieved_id_token = Kubeclient::OIDCAuthProvider.token(
19
- 'client-id' => @client_id,
20
- 'client-secret' => @client_secret,
21
- 'id-token' => @id_token,
22
- 'idp-issuer-url' => @idp_issuer_url,
23
- 'refresh-token' => @refresh_token
24
- )
25
- assert_equal(@new_id_token, retrieved_id_token)
26
- end
27
- end
28
- end
29
- end
30
-
31
- def test_valid_token
32
- OpenIDConnect::Discovery::Provider::Config.stub(:discover!, discovery_mock) do
33
- OpenIDConnect::ResponseObject::IdToken.stub(:decode, id_token_mock(Time.now.to_i + 7200)) do
34
- retrieved_id_token = Kubeclient::OIDCAuthProvider.token(
35
- 'client-id' => @client_id,
36
- 'client-secret' => @client_secret,
37
- 'id-token' => @id_token,
38
- 'idp-issuer-url' => @idp_issuer_url,
39
- 'refresh-token' => @refresh_token
40
- )
41
- assert_equal(@id_token, retrieved_id_token)
42
- end
43
- end
44
- end
45
-
46
- def test_missing_id_token
47
- OpenIDConnect::Discovery::Provider::Config.stub(:discover!, discovery_mock) do
48
- OpenIDConnect::Client.stub(:new, openid_client_mock) do
49
- retrieved_id_token = Kubeclient::OIDCAuthProvider.token(
50
- 'client-id' => @client_id,
51
- 'client-secret' => @client_secret,
52
- 'idp-issuer-url' => @idp_issuer_url,
53
- 'refresh-token' => @refresh_token
54
- )
55
- assert_equal(@new_id_token, retrieved_id_token)
56
- end
57
- end
58
- end
59
-
60
- def test_token_with_unknown_kid
61
- OpenIDConnect::Discovery::Provider::Config.stub(:discover!, discovery_mock) do
62
- OpenIDConnect::ResponseObject::IdToken.stub(
63
- :decode, ->(_token, _jwks) { raise JSON::JWK::Set::KidNotFound }
64
- ) do
65
- OpenIDConnect::Client.stub(:new, openid_client_mock) do
66
- retrieved_id_token = Kubeclient::OIDCAuthProvider.token(
67
- 'client-id' => @client_id,
68
- 'client-secret' => @client_secret,
69
- 'id-token' => @id_token,
70
- 'idp-issuer-url' => @idp_issuer_url,
71
- 'refresh-token' => @refresh_token
72
- )
73
- assert_equal(@new_id_token, retrieved_id_token)
74
- end
75
- end
76
- end
77
- end
78
-
79
- private
80
-
81
- def openid_client_mock
82
- access_token = Minitest::Mock.new
83
- access_token.expect(@id_token, @new_id_token)
84
-
85
- openid_client = Minitest::Mock.new
86
- openid_client.expect(:refresh_token=, nil, [@refresh_token])
87
- openid_client.expect(:access_token!, access_token)
88
- end
89
-
90
- def id_token_mock(expiry)
91
- id_token_mock = Minitest::Mock.new
92
- id_token_mock.expect(:exp, expiry)
93
- end
94
-
95
- def discovery_mock
96
- discovery = Minitest::Mock.new
97
- discovery.expect(:jwks, 'jwks')
98
- discovery.expect(:authorization_endpoint, 'authz_endpoint')
99
- discovery.expect(:token_endpoint, 'token_endpoint')
100
- discovery.expect(:userinfo_endpoint, 'userinfo_endpoint')
101
- discovery
102
- end
103
- end
@@ -1,29 +0,0 @@
1
- require_relative 'test_helper'
2
-
3
- # PersistentVolume tests
4
- class TestPersistentVolume < MiniTest::Test
5
- def test_get_from_json_v1
6
- stub_core_api_list
7
- stub_request(:get, %r{/persistentvolumes})
8
- .to_return(body: open_test_file('persistent_volume.json'), status: 200)
9
-
10
- client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
11
- volume = client.get_persistent_volume('pv0001')
12
-
13
- assert_instance_of(Kubeclient::Resource, volume)
14
- assert_equal('pv0001', volume.metadata.name)
15
- assert_equal('10Gi', volume.spec.capacity.storage)
16
- assert_equal('/tmp/data01', volume.spec.hostPath.path)
17
-
18
- assert_requested(
19
- :get,
20
- 'http://localhost:8080/api/v1',
21
- times: 1
22
- )
23
- assert_requested(
24
- :get,
25
- 'http://localhost:8080/api/v1/persistentvolumes/pv0001',
26
- times: 1
27
- )
28
- end
29
- end
@@ -1,28 +0,0 @@
1
- require_relative 'test_helper'
2
-
3
- # PersistentVolumeClaim tests
4
- class TestPersistentVolumeClaim < MiniTest::Test
5
- def test_get_from_json_v1
6
- stub_core_api_list
7
- stub_request(:get, %r{/persistentvolumeclaims})
8
- .to_return(body: open_test_file('persistent_volume_claim.json'), status: 200)
9
- client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
10
- claim = client.get_persistent_volume_claim('myclaim-1', 'default')
11
-
12
- assert_instance_of(Kubeclient::Resource, claim)
13
- assert_equal('myclaim-1', claim.metadata.name)
14
- assert_equal('3Gi', claim.spec.resources.requests.storage)
15
- assert_equal('pv0001', claim.spec.volumeName)
16
-
17
- assert_requested(
18
- :get,
19
- 'http://localhost:8080/api/v1',
20
- times: 1
21
- )
22
- assert_requested(
23
- :get,
24
- 'http://localhost:8080/api/v1/namespaces/default/persistentvolumeclaims/myclaim-1',
25
- times: 1
26
- )
27
- end
28
- end
data/test/test_pod.rb DELETED
@@ -1,81 +0,0 @@
1
- require_relative 'test_helper'
2
-
3
- # Pod entity tests
4
- class TestPod < MiniTest::Test
5
- def test_get_from_json_v1
6
- stub_core_api_list
7
- stub_request(:get, %r{/pods})
8
- .to_return(body: open_test_file('pod.json'), status: 200)
9
-
10
- client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
11
- pod = client.get_pod('redis-master-pod', 'default')
12
-
13
- assert_instance_of(Kubeclient::Resource, pod)
14
- assert_equal('redis-master3', pod.metadata.name)
15
- assert_equal('dockerfile/redis', pod.spec.containers[0]['image'])
16
-
17
- assert_requested(
18
- :get,
19
- 'http://localhost:8080/api/v1',
20
- times: 1
21
- )
22
- assert_requested(
23
- :get,
24
- 'http://localhost:8080/api/v1/namespaces/default/pods/redis-master-pod',
25
- times: 1
26
- )
27
- end
28
-
29
- def test_get_chunks
30
- stub_core_api_list
31
- stub_request(:get, %r{/pods})
32
- .to_return(body: open_test_file('pods_1.json'), status: 200)
33
-
34
- client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
35
- pods = client.get_pods(limit: 2)
36
-
37
- assert_equal(2, pods.count)
38
- assert_equal('eyJ2IjoibWV0YS5rOHMua', pods.continue)
39
-
40
- continue = pods.continue
41
-
42
- stub_request(:get, %r{/pods})
43
- .to_return(body: open_test_file('pods_2.json'), status: 200)
44
-
45
- pods = client.get_pods(limit: 2, continue: continue)
46
- assert_equal(2, pods.count)
47
- assert_nil(pods.continue)
48
-
49
- assert_requested(
50
- :get,
51
- 'http://localhost:8080/api/v1',
52
- times: 1
53
- )
54
- assert_requested(
55
- :get,
56
- 'http://localhost:8080/api/v1/pods?limit=2',
57
- times: 1
58
- )
59
- assert_requested(
60
- :get,
61
- "http://localhost:8080/api/v1/pods?continue=#{continue}&limit=2",
62
- times: 1
63
- )
64
- end
65
-
66
- def test_get_chunks_410_gone
67
- stub_core_api_list
68
- stub_request(:get, %r{/pods})
69
- .to_return(body: open_test_file('pods_410.json'), status: 410)
70
-
71
- client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
72
-
73
- err = assert_raises Kubeclient::HttpError do
74
- client.get_pods(limit: 2, continue: 'eyJ2IjoibWV0YS5')
75
- end
76
-
77
- assert_equal(err.message,
78
- "The provided from parameter is too old to display a consistent list result. \
79
- You must start a new list without the from.")
80
- end
81
- end