def test_cannot_pass_both_bearer_and_basic_auth(self): with self.assertRaises(Exception): kubeclientservice.KubeHardcodedConfig( master_url="http://localhost:8001", namespace="default", verify="/path/to/pem", basicAuth="Bla", bearerToken="Bla")
def createKube(self): self.kube = kubeclientservice.KubeClientService( kubeclientservice.KubeHardcodedConfig(master_url='http://m')) self.http = fakehttp.HTTPClientService('http://m') self.kube.get = self.http.get self.kube.post = self.http.post self.kube.put = self.http.put self.kube.delete = self.http.delete
def test_verify_is_forwarded_to_keywords(self): self.config = config = kubeclientservice.KubeHardcodedConfig( master_url="http://localhost:8001", namespace="default", verify="/path/to/pem") service = kubeclientservice.KubeClientService(config) url, kwargs = yield service._prepareRequest("/test", {}) self.assertEqual('/path/to/pem', kwargs['verify'])
def test_verify_bearerToken_is_expanded(self): self.config = config = kubeclientservice.KubeHardcodedConfig( master_url="http://localhost:8001", namespace="default", verify="/path/to/pem", bearerToken=Interpolate("%(kw:test)s", test=10)) service = kubeclientservice.KubeClientService(config) url, kwargs = yield service._prepareRequest("/test", {}) self.assertEqual("Bearer 10", kwargs['headers']['Authorization'])
def test_verify_headers_are_passed_to_the_query(self): self.config = config = kubeclientservice.KubeHardcodedConfig( master_url="http://localhost:8001", namespace="default", verify="/path/to/pem", headers={'Test': '10'}) service = kubeclientservice.KubeClientService(config) url, kwargs = yield service._prepareRequest("/test", {}) self.assertEqual({'Test': '10'}, kwargs['headers'])
def test_basic(self): self.config = config = kubeclientservice.KubeHardcodedConfig( master_url="http://localhost:8001", namespace="default") self.assertEqual( config.getConfig(), { 'master_url': 'http://localhost:8001', 'namespace': 'default', 'headers': {} })
def test_verify_basicAuth_is_expanded(self): self.config = config = kubeclientservice.KubeHardcodedConfig( master_url="http://localhost:8001", namespace="default", verify="/path/to/pem", basicAuth={'user': '******', 'password': Interpolate("%(kw:test)s", test=10)}) service = kubeclientservice.KubeClientService(config) url, kwargs = yield service._prepareRequest("/test", {}) expected = "Basic {0}".format(base64.b64encode("name:10".encode('utf-8'))) self.assertEqual(expected, kwargs['headers']['Authorization'])
def createKube(self): self.kube = fakekube.KubeClientService( kubeclientservice.KubeHardcodedConfig(master_url='http://m'))
def test_the_configuration_parent_is_set_to_the_service(self): # This is needed to allow secret expansion self.config = config = kubeclientservice.KubeHardcodedConfig( master_url="http://localhost:8001") service = kubeclientservice.KubeClientService(config) self.assertEqual(service, self.config.parent)