Beispiel #1
0
 def test_get_vcap_service_instance_port_default(self):
     service = CloudFoundryService(
         self._test_legacy_vcap_services_multiple,
         instance_name='Cloudant NoSQL DB 2',
         service_name='cloudantNoSQLDB'
     )
     self.assertEqual('443', service.port)
Beispiel #2
0
 def test_get_vcap_service_instance_password(self):
     service = CloudFoundryService(
         self._test_legacy_vcap_services_multiple,
         instance_name='Cloudant NoSQL DB 1',
         service_name='cloudantNoSQLDB'
     )
     self.assertEqual('pa$$w0rd01', service.password)
Beispiel #3
0
 def test_get_vcap_service_instance_username(self):
     service = CloudFoundryService(
         self._test_legacy_vcap_services_multiple,
         instance_name='Cloudant NoSQL DB 1',
         service_name='cloudantNoSQLDB'
     )
     self.assertEqual('example', service.username)
Beispiel #4
0
 def test_get_vcap_service_instance_url(self):
     service = CloudFoundryService(
         self._test_legacy_vcap_services_multiple,
         instance_name='Cloudant NoSQL DB 1',
         service_name='cloudantNoSQLDB'
     )
     self.assertEqual('https://example.cloudant.com:1234', service.url)
Beispiel #5
0
 def test_get_vcap_service_instance_iam_api_key(self):
     service = CloudFoundryService(
         self._test_legacy_vcap_services_multiple,
         instance_name='Cloudant NoSQL DB 8',
         service_name='cloudantNoSQLDB'
     )
     self.assertEqual('1234api', service.iam_api_key)
Beispiel #6
0
 def test_raise_error_for_missing_host(self):
     with self.assertRaises(CloudantException):
         CloudFoundryService(
             self._test_legacy_vcap_services_multiple,
             instance_name='Cloudant NoSQL DB 3',
             service_name='cloudantNoSQLDB'
         )
Beispiel #7
0
 def test_raise_error_for_invalid_credentials_type(self):
     with self.assertRaises(CloudantException) as cm:
         CloudFoundryService(self._test_vcap_services_multiple,
                             instance_name='Cloudant NoSQL DB 6',
                             service_name='cloudantNoSQLDB')
     self.assertEqual('Failed to decode VCAP_SERVICES service credentials',
                      str(cm.exception))
Beispiel #8
0
 def test_raise_error_for_missing_username(self):
     with self.assertRaises(CloudantException) as cm:
         CloudFoundryService(self._test_vcap_services_multiple,
                             instance_name='Cloudant NoSQL DB 5',
                             service_name='cloudantNoSQLDB')
     self.assertEqual("Invalid service: 'username' missing",
                      str(cm.exception))
Beispiel #9
0
 def test_get_vcap_service_default_failure_multiple_services(self):
     with self.assertRaises(CloudantException) as cm:
         CloudFoundryService(
             self._test_legacy_vcap_services_multiple,
             service_name='cloudantNoSQLDB'
         )
     self.assertEqual('Missing service in VCAP_SERVICES', str(cm.exception))
Beispiel #10
0
 def test_raise_error_for_missing_service(self):
     with self.assertRaises(CloudantException) as cm:
         CloudFoundryService(
             self._test_legacy_vcap_services_multiple,
             instance_name='Cloudant NoSQL DB 9',
             service_name='cloudantNoSQLDB'
         )
     self.assertEqual('Missing service in VCAP_SERVICES', str(cm.exception))
Beispiel #11
0
 def test_get_vcap_service_iam_api_no_creds_success(self):
     service = CloudFoundryService(
         self._test_vcap_services_single,
         service_name='cloudantNoSQLDB'
     )
     self.assertEqual('Cloudant NoSQL DB 1', service.name)
     self.assertEqual('1234api', service.iam_api_key)
     with self.assertRaises(AttributeError) as cm:
         service.password
     self.assertEqual("'CloudFoundryService' object has no attribute '_password'", str(cm.exception))
Beispiel #12
0
 def test_raise_error_for_missing_iam_api_key_and_credentials(self):
     with self.assertRaises(CloudantException) as cm:
         CloudFoundryService(
             self._test_legacy_vcap_services_multiple,
             instance_name='Cloudant NoSQL DB 7',
             service_name='cloudantNoSQLDB'
         )
     self.assertEqual(
         'Invalid service: IAM API key or username/password credentials are required.',
         str(cm.exception)
     )
Beispiel #13
0
 def test_get_vcap_service_default_success_as_dict(self):
     service = CloudFoundryService(
         json.loads(self._test_vcap_services_single_legacy_credentials_enabled),
         service_name='cloudantNoSQLDB'
     )
     self.assertEqual('Cloudant NoSQL DB 1', service.name)
Beispiel #14
0
 def test_get_vcap_service_instance_host(self):
     service = CloudFoundryService(self._test_vcap_services_multiple,
                                   'Cloudant NoSQL DB 1')
     self.assertEqual('example.cloudant.com', service.host)
Beispiel #15
0
 def test_get_vcap_service_instance_port(self):
     service = CloudFoundryService(self._test_vcap_services_multiple,
                                   'Cloudant NoSQL DB 1')
     self.assertEqual('1234', service.port)
Beispiel #16
0
 def test_raise_error_for_missing_host(self):
     with self.assertRaises(CloudantException):
         CloudFoundryService(self._test_vcap_services_multiple,
                             'Cloudant NoSQL DB 3')
Beispiel #17
0
 def test_raise_error_for_missing_password(self):
     with self.assertRaises(CloudantException) as cm:
         CloudFoundryService(self._test_vcap_services_multiple,
                             'Cloudant NoSQL DB 4')
     self.assertEqual("Invalid service: 'password' missing",
                      str(cm.exception))
Beispiel #18
0
 def test_get_vcap_service_default_success_as_dict(self):
     service = CloudFoundryService(
         json.loads(self._test_vcap_services_single))
     self.assertEqual('Cloudant NoSQL DB 1', service.name)
Beispiel #19
0
 def test_get_vcap_service_legacy_creds_success(self):
     service = CloudFoundryService(
         self._test_vcap_services_single_legacy_credentials_enabled,
         service_name='cloudantNoSQLDB'
     )
     self.assertEqual('Cloudant NoSQL DB 1', service.name)
Beispiel #20
0
 def test_raise_error_for_invalid_vcap(self):
     with self.assertRaises(CloudantException) as cm:
         CloudFoundryService('{', 'Cloudant NoSQL DB 1')  # invalid JSON
     self.assertEqual('Failed to decode VCAP_SERVICES JSON', str(cm.exception))
Beispiel #21
0
 def test_get_vcap_service_with_dedicated_service_name_success(self):
     service = CloudFoundryService(
         self._test_vcap_services_dedicated,
         service_name='cloudantNoSQLDB Dedicated'
     )
     self.assertEqual('Cloudant NoSQL DB 1', service.name)
Beispiel #22
0
 def test_get_vcap_service_default_success(self):
     service = CloudFoundryService(self._test_vcap_services_single,
                                   service_name='cloudantNoSQLDB')
     self.assertEqual('Cloudant NoSQL DB 1', service.name)