Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit 29a67ee

Browse filesBrowse files
authored
Merge pull request #498 from cloudant/new-test-server
Update test server config
2 parents 3378146 + 0f031cd commit 29a67ee
Copy full SHA for 29a67ee

File tree

Expand file treeCollapse file tree

4 files changed

+30
-25
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+30
-25
lines changed

‎CHANGES.md

Copy file name to clipboardExpand all lines: CHANGES.md
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
- [FIXED] Fixed the documentation for `bookmarks`.
44
- [FIXED] Also exit `follow_replication` for `failed` state.
55
- [FIXED] Fixed result paging for grouped view queries.
6+
- [FIXED] Incorrect use of username as account name in `Cloudant.bluemix()`.
7+
- [IMPROVED] Documented use of None account name and url override for `Cloudant.iam()`.
68

79
# 2.14.0 (2020-08-17)
810

‎Jenkinsfile

Copy file name to clipboardExpand all lines: Jenkinsfile
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
def getEnvForSuite(suiteName) {
22
// Base environment variables
33
def envVars = [
4-
"CLOUDANT_ACCOUNT=$DB_USER",
4+
"DB_URL=${SDKS_TEST_SERVER_URL}",
55
"RUN_CLOUDANT_TESTS=1",
66
"SKIP_DB_UPDATES=1" // Disable pending resolution of case 71610
77
]
@@ -13,6 +13,7 @@ def getEnvForSuite(suiteName) {
1313
case 'iam':
1414
// Setting IAM_API_KEY forces tests to run using an IAM enabled client.
1515
envVars.add("IAM_API_KEY=$DB_IAM_API_KEY")
16+
envVars.add("IAM_TOKEN_URL=$SDKS_TEST_IAM_URL")
1617
break
1718
case 'cookie':
1819
case 'simplejson':
@@ -28,8 +29,8 @@ def setupPythonAndTest(pythonVersion, testSuite) {
2829
// Unstash the source on this node
2930
unstash name: 'source'
3031
// Set up the environment and test
31-
withCredentials([usernamePassword(credentialsId: 'clientlibs-test', usernameVariable: 'DB_USER', passwordVariable: 'DB_PASSWORD'),
32-
string(credentialsId: 'clientlibs-test-iam', variable: 'DB_IAM_API_KEY')]) {
32+
withCredentials([usernamePassword(credentialsId: 'testServerLegacy', usernameVariable: 'DB_USER', passwordVariable: 'DB_PASSWORD'),
33+
string(credentialsId: 'testServerIamApiKey', variable: 'DB_IAM_API_KEY')]) {
3334
withEnv(getEnvForSuite("${testSuite}")) {
3435
try {
3536
sh """

‎src/cloudant/client.py

Copy file name to clipboardExpand all lines: src/cloudant/client.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python
2-
# Copyright (c) 2015, 2019 IBM Corp. All rights reserved.
2+
# Copyright (c) 2015, 2021 IBM Corp. All rights reserved.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -853,7 +853,7 @@ def bluemix(cls, vcap_services, instance_name=None, service_name=None, **kwargs)
853853
raise CloudantClientException(103)
854854

855855
if hasattr(service, 'iam_api_key'):
856-
return Cloudant.iam(service.username,
856+
return Cloudant.iam(None,
857857
service.iam_api_key,
858858
url=service.url,
859859
**kwargs)
@@ -867,7 +867,7 @@ def iam(cls, account_name, api_key, **kwargs):
867867
"""
868868
Create a Cloudant client that uses IAM authentication.
869869
870-
:param account_name: Cloudant account name.
870+
:param account_name: Cloudant account name; or use None and a url kwarg.
871871
:param api_key: IAM authentication API key.
872872
"""
873873
return cls(None,

‎tests/unit/client_tests.py

Copy file name to clipboardExpand all lines: tests/unit/client_tests.py
+21-19Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python
2-
# Copyright (C) 2015, 2020 IBM Corp. All rights reserved.
2+
# Copyright (C) 2015, 2021 IBM Corp. All rights reserved.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@
2727
import sys
2828
import unittest
2929
from time import sleep
30+
from urllib.parse import urlparse
3031

3132
import mock
3233
import requests
@@ -213,7 +214,7 @@ def test_auto_renew_enabled_with_auto_connect(self):
213214
@skip_if_not_cookie_auth
214215
def test_session(self):
215216
"""
216-
Test getting session information.
217+
Test getting session information.
217218
Session info is None if CouchDB Admin Party mode was selected.
218219
"""
219220
try:
@@ -563,7 +564,7 @@ def test_get_cached_db_object_via_get(self):
563564
self.client.connect()
564565
# Default returns None
565566
self.assertIsNone(self.client.get('no_such_db'))
566-
# Creates the database remotely and adds it to the
567+
# Creates the database remotely and adds it to the
567568
# client database cache
568569
db = self.client.create_database(dbname)
569570
# Locally cached database object is returned
@@ -702,7 +703,7 @@ def test_cloudant_context_helper(self):
702703
Test that the cloudant context helper works as expected.
703704
"""
704705
try:
705-
with cloudant(self.user, self.pwd, account=self.account) as c:
706+
with cloudant(self.user, self.pwd, url=self.url) as c:
706707
self.assertIsInstance(c, Cloudant)
707708
self.assertIsInstance(c.r_session, requests.Session)
708709
except Exception as err:
@@ -718,7 +719,7 @@ def test_cloudant_bluemix_context_helper_with_legacy_creds(self):
718719
'credentials': {
719720
'username': self.user,
720721
'password': self.pwd,
721-
'host': '{0}.cloudant.com'.format(self.account),
722+
'host': urlparse(self.url).hostname,
722723
'port': 443,
723724
'url': self.url
724725
},
@@ -744,7 +745,7 @@ def test_cloudant_bluemix_context_helper_with_iam(self):
744745
'credentials': {
745746
'apikey': self.iam_api_key,
746747
'username': self.user,
747-
'host': '{0}.cloudant.com'.format(self.account),
748+
'host': urlparse(self.url).hostname,
748749
'port': 443,
749750
'url': self.url
750751
},
@@ -766,7 +767,7 @@ def test_cloudant_bluemix_context_helper_raise_error_for_missing_iam_and_creds(s
766767
instance_name = 'Cloudant NoSQL DB-lv'
767768
vcap_services = {'cloudantNoSQLDB': [{
768769
'credentials': {
769-
'host': '{0}.cloudant.com'.format(self.account),
770+
'host': urlparse(self.url).hostname,
770771
'port': 443,
771772
'url': self.url
772773
},
@@ -795,7 +796,7 @@ def test_cloudant_bluemix_dedicated_context_helper(self):
795796
'credentials': {
796797
'username': self.user,
797798
'password': self.pwd,
798-
'host': '{0}.cloudant.com'.format(self.account),
799+
'host': urlparse(self.url).hostname,
799800
'port': 443,
800801
'url': self.url
801802
},
@@ -818,10 +819,10 @@ def test_constructor_with_account(self):
818819
"""
819820
# Ensure that the client is new
820821
del self.client
821-
self.client = Cloudant(self.user, self.pwd, account=self.account)
822+
self.client = Cloudant('user', 'pass', account='foo')
822823
self.assertEqual(
823824
self.client.server_url,
824-
'https://{0}.cloudant.com'.format(self.account)
825+
'https://foo.cloudant.com'
825826
)
826827

827828
@skip_if_not_cookie_auth
@@ -835,7 +836,7 @@ def test_bluemix_constructor_with_legacy_creds(self):
835836
'credentials': {
836837
'username': self.user,
837838
'password': self.pwd,
838-
'host': '{0}.cloudant.com'.format(self.account),
839+
'host': urlparse(self.url).hostname,
839840
'port': 443,
840841
'url': self.url
841842
},
@@ -870,7 +871,7 @@ def test_bluemix_constructor_with_iam(self):
870871
'credentials': {
871872
'apikey': self.iam_api_key,
872873
'username': self.user,
873-
'host': '{0}.cloudant.com'.format(self.account),
874+
'host': urlparse(self.url).hostname,
874875
'port': 443
875876
},
876877
'name': instance_name
@@ -901,7 +902,7 @@ def test_bluemix_constructor_specify_instance_name(self):
901902
'credentials': {
902903
'username': self.user,
903904
'password': self.pwd,
904-
'host': '{0}.cloudant.com'.format(self.account),
905+
'host': urlparse(self.url).hostname,
905906
'port': 443,
906907
'url': self.url
907908
},
@@ -934,7 +935,7 @@ def test_bluemix_constructor_with_multiple_services(self):
934935
{
935936
'credentials': {
936937
'apikey': '1234api',
937-
'host': '{0}.cloudant.com'.format(self.account),
938+
'host': urlparse(self.url).hostname,
938939
'port': 443,
939940
'url': self.url
940941
},
@@ -973,10 +974,11 @@ def test_connect_headers(self):
973974
"""
974975
try:
975976
self.client.connect()
976-
self.assertEqual(
977-
self.client.r_session.headers['X-Cloudant-User'],
978-
self.account
979-
)
977+
if (self.account):
978+
self.assertEqual(
979+
self.client.r_session.headers['X-Cloudant-User'],
980+
self.account
981+
)
980982
agent = self.client.r_session.headers.get('User-Agent')
981983
ua_parts = agent.split('/')
982984
self.assertEqual(len(ua_parts), 6)
@@ -1413,4 +1415,4 @@ def test_update_cors_configuration(self):
14131415
self.client.disconnect()
14141416

14151417
if __name__ == '__main__':
1416-
unittest.main()
1418+
unittest.main()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.