diff --git a/test/json/extensions_v1beta1_api_resource_list.json b/test/json/extensions_v1beta1_api_resource_list.json new file mode 100644 index 00000000..16fc80cf --- /dev/null +++ b/test/json/extensions_v1beta1_api_resource_list.json @@ -0,0 +1,217 @@ +{ + "kind": "APIResourceList", + "groupVersion": "extensions/v1beta1", + "resources": [ + { + "name": "daemonsets", + "singularName": "", + "namespaced": true, + "kind": "DaemonSet", + "verbs": [ + "create", + "delete", + "deletecollection", + "get", + "list", + "patch", + "update", + "watch" + ], + "shortNames": [ + "ds" + ] + }, + { + "name": "daemonsets/status", + "singularName": "", + "namespaced": true, + "kind": "DaemonSet", + "verbs": [ + "get", + "patch", + "update" + ] + }, + { + "name": "deployments", + "singularName": "", + "namespaced": true, + "kind": "Deployment", + "verbs": [ + "create", + "delete", + "deletecollection", + "get", + "list", + "patch", + "update", + "watch" + ], + "shortNames": [ + "deploy" + ] + }, + { + "name": "deployments/rollback", + "singularName": "", + "namespaced": true, + "kind": "DeploymentRollback", + "verbs": [ + "create" + ] + }, + { + "name": "deployments/scale", + "singularName": "", + "namespaced": true, + "group": "extensions", + "version": "v1beta1", + "kind": "Scale", + "verbs": [ + "get", + "patch", + "update" + ] + }, + { + "name": "deployments/status", + "singularName": "", + "namespaced": true, + "kind": "Deployment", + "verbs": [ + "get", + "patch", + "update" + ] + }, + { + "name": "ingresses", + "singularName": "", + "namespaced": true, + "kind": "Ingress", + "verbs": [ + "create", + "delete", + "deletecollection", + "get", + "list", + "patch", + "update", + "watch" + ], + "shortNames": [ + "ing" + ] + }, + { + "name": "ingresses/status", + "singularName": "", + "namespaced": true, + "kind": "Ingress", + "verbs": [ + "get", + "patch", + "update" + ] + }, + { + "name": "networkpolicies", + "singularName": "", + "namespaced": true, + "kind": "NetworkPolicy", + "verbs": [ + "create", + "delete", + "deletecollection", + "get", + "list", + "patch", + "update", + "watch" + ], + "shortNames": [ + "netpol" + ] + }, + { + "name": "podsecuritypolicies", + "singularName": "", + "namespaced": false, + "kind": "PodSecurityPolicy", + "verbs": [ + "create", + "delete", + "deletecollection", + "get", + "list", + "patch", + "update", + "watch" + ], + "shortNames": [ + "psp" + ] + }, + { + "name": "replicasets", + "singularName": "", + "namespaced": true, + "kind": "ReplicaSet", + "verbs": [ + "create", + "delete", + "deletecollection", + "get", + "list", + "patch", + "update", + "watch" + ], + "shortNames": [ + "rs" + ] + }, + { + "name": "replicasets/scale", + "singularName": "", + "namespaced": true, + "group": "extensions", + "version": "v1beta1", + "kind": "Scale", + "verbs": [ + "get", + "patch", + "update" + ] + }, + { + "name": "replicasets/status", + "singularName": "", + "namespaced": true, + "kind": "ReplicaSet", + "verbs": [ + "get", + "patch", + "update" + ] + }, + { + "name": "replicationcontrollers", + "singularName": "", + "namespaced": true, + "kind": "ReplicationControllerDummy", + "verbs": [] + }, + { + "name": "replicationcontrollers/scale", + "singularName": "", + "namespaced": true, + "kind": "Scale", + "verbs": [ + "get", + "patch", + "update" + ] + } + ] +} \ No newline at end of file diff --git a/test/test_missing_methods.rb b/test/test_missing_methods.rb index a52181a4..67614c95 100644 --- a/test/test_missing_methods.rb +++ b/test/test_missing_methods.rb @@ -41,6 +41,18 @@ def test_missing end end + def test_nonsuffix_plurals + stub_request(:get, %r{/apis/extensions/v1beta1$}).to_return( + body: open_test_file('extensions_v1beta1_api_resource_list.json'), + status: 200 + ) + client = Kubeclient::Client.new('http://localhost:8080/apis/extensions', 'v1beta1') + assert_equal(true, client.respond_to?(:get_network_policy)) + assert_equal(true, client.respond_to?(:get_network_policies)) + assert_equal(true, client.respond_to?(:get_pod_security_policy)) + assert_equal(true, client.respond_to?(:get_pod_security_policies)) + end + def test_irregular_names stub_core_api_list client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')