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.

Update test server config #498

Merged
merged 4 commits into from
May 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions 2 CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
- [FIXED] Fixed the documentation for `bookmarks`.
- [FIXED] Also exit `follow_replication` for `failed` state.
- [FIXED] Fixed result paging for grouped view queries.
- [FIXED] Incorrect use of username as account name in `Cloudant.bluemix()`.
- [IMPROVED] Documented use of None account name and url override for `Cloudant.iam()`.

# 2.14.0 (2020-08-17)

Expand Down
7 changes: 4 additions & 3 deletions 7 Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
def getEnvForSuite(suiteName) {
// Base environment variables
def envVars = [
"CLOUDANT_ACCOUNT=$DB_USER",
"DB_URL=${SDKS_TEST_SERVER_URL}",
"RUN_CLOUDANT_TESTS=1",
"SKIP_DB_UPDATES=1" // Disable pending resolution of case 71610
]
Expand All @@ -13,6 +13,7 @@ def getEnvForSuite(suiteName) {
case 'iam':
// Setting IAM_API_KEY forces tests to run using an IAM enabled client.
envVars.add("IAM_API_KEY=$DB_IAM_API_KEY")
envVars.add("IAM_TOKEN_URL=$SDKS_TEST_IAM_URL")
break
case 'cookie':
case 'simplejson':
Expand All @@ -28,8 +29,8 @@ def setupPythonAndTest(pythonVersion, testSuite) {
// Unstash the source on this node
unstash name: 'source'
// Set up the environment and test
withCredentials([usernamePassword(credentialsId: 'clientlibs-test', usernameVariable: 'DB_USER', passwordVariable: 'DB_PASSWORD'),
string(credentialsId: 'clientlibs-test-iam', variable: 'DB_IAM_API_KEY')]) {
withCredentials([usernamePassword(credentialsId: 'testServerLegacy', usernameVariable: 'DB_USER', passwordVariable: 'DB_PASSWORD'),
string(credentialsId: 'testServerIamApiKey', variable: 'DB_IAM_API_KEY')]) {
withEnv(getEnvForSuite("${testSuite}")) {
try {
sh """
Expand Down
6 changes: 3 additions & 3 deletions 6 src/cloudant/client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
# Copyright (c) 2015, 2019 IBM Corp. All rights reserved.
# Copyright (c) 2015, 2021 IBM Corp. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -853,7 +853,7 @@ def bluemix(cls, vcap_services, instance_name=None, service_name=None, **kwargs)
raise CloudantClientException(103)

if hasattr(service, 'iam_api_key'):
return Cloudant.iam(service.username,
return Cloudant.iam(None,
service.iam_api_key,
url=service.url,
**kwargs)
Expand All @@ -867,7 +867,7 @@ def iam(cls, account_name, api_key, **kwargs):
"""
Create a Cloudant client that uses IAM authentication.

:param account_name: Cloudant account name.
:param account_name: Cloudant account name; or use None and a url kwarg.
:param api_key: IAM authentication API key.
"""
return cls(None,
Expand Down
40 changes: 21 additions & 19 deletions 40 tests/unit/client_tests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
# Copyright (C) 2015, 2020 IBM Corp. All rights reserved.
# Copyright (C) 2015, 2021 IBM Corp. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -27,6 +27,7 @@
import sys
import unittest
from time import sleep
from urllib.parse import urlparse

import mock
import requests
Expand Down Expand Up @@ -213,7 +214,7 @@ def test_auto_renew_enabled_with_auto_connect(self):
@skip_if_not_cookie_auth
def test_session(self):
"""
Test getting session information.
Test getting session information.
Session info is None if CouchDB Admin Party mode was selected.
"""
try:
Expand Down Expand Up @@ -563,7 +564,7 @@ def test_get_cached_db_object_via_get(self):
self.client.connect()
# Default returns None
self.assertIsNone(self.client.get('no_such_db'))
# Creates the database remotely and adds it to the
# Creates the database remotely and adds it to the
# client database cache
db = self.client.create_database(dbname)
# Locally cached database object is returned
Expand Down Expand Up @@ -702,7 +703,7 @@ def test_cloudant_context_helper(self):
Test that the cloudant context helper works as expected.
"""
try:
with cloudant(self.user, self.pwd, account=self.account) as c:
with cloudant(self.user, self.pwd, url=self.url) as c:
self.assertIsInstance(c, Cloudant)
self.assertIsInstance(c.r_session, requests.Session)
except Exception as err:
Expand All @@ -718,7 +719,7 @@ def test_cloudant_bluemix_context_helper_with_legacy_creds(self):
'credentials': {
'username': self.user,
'password': self.pwd,
'host': '{0}.cloudant.com'.format(self.account),
'host': urlparse(self.url).hostname,
'port': 443,
'url': self.url
},
Expand All @@ -744,7 +745,7 @@ def test_cloudant_bluemix_context_helper_with_iam(self):
'credentials': {
'apikey': self.iam_api_key,
'username': self.user,
'host': '{0}.cloudant.com'.format(self.account),
'host': urlparse(self.url).hostname,
'port': 443,
'url': self.url
},
Expand All @@ -766,7 +767,7 @@ def test_cloudant_bluemix_context_helper_raise_error_for_missing_iam_and_creds(s
instance_name = 'Cloudant NoSQL DB-lv'
vcap_services = {'cloudantNoSQLDB': [{
'credentials': {
'host': '{0}.cloudant.com'.format(self.account),
'host': urlparse(self.url).hostname,
'port': 443,
'url': self.url
},
Expand Down Expand Up @@ -795,7 +796,7 @@ def test_cloudant_bluemix_dedicated_context_helper(self):
'credentials': {
'username': self.user,
'password': self.pwd,
'host': '{0}.cloudant.com'.format(self.account),
'host': urlparse(self.url).hostname,
'port': 443,
'url': self.url
},
Expand All @@ -818,10 +819,10 @@ def test_constructor_with_account(self):
"""
# Ensure that the client is new
del self.client
self.client = Cloudant(self.user, self.pwd, account=self.account)
self.client = Cloudant('user', 'pass', account='foo')
self.assertEqual(
self.client.server_url,
'https://{0}.cloudant.com'.format(self.account)
'https://foo.cloudant.com'
)

@skip_if_not_cookie_auth
Expand All @@ -835,7 +836,7 @@ def test_bluemix_constructor_with_legacy_creds(self):
'credentials': {
'username': self.user,
'password': self.pwd,
'host': '{0}.cloudant.com'.format(self.account),
'host': urlparse(self.url).hostname,
'port': 443,
'url': self.url
},
Expand Down Expand Up @@ -870,7 +871,7 @@ def test_bluemix_constructor_with_iam(self):
'credentials': {
'apikey': self.iam_api_key,
'username': self.user,
'host': '{0}.cloudant.com'.format(self.account),
'host': urlparse(self.url).hostname,
'port': 443
},
'name': instance_name
Expand Down Expand Up @@ -901,7 +902,7 @@ def test_bluemix_constructor_specify_instance_name(self):
'credentials': {
'username': self.user,
'password': self.pwd,
'host': '{0}.cloudant.com'.format(self.account),
'host': urlparse(self.url).hostname,
'port': 443,
'url': self.url
},
Expand Down Expand Up @@ -934,7 +935,7 @@ def test_bluemix_constructor_with_multiple_services(self):
{
'credentials': {
'apikey': '1234api',
'host': '{0}.cloudant.com'.format(self.account),
'host': urlparse(self.url).hostname,
'port': 443,
'url': self.url
},
Expand Down Expand Up @@ -973,10 +974,11 @@ def test_connect_headers(self):
"""
try:
self.client.connect()
self.assertEqual(
self.client.r_session.headers['X-Cloudant-User'],
self.account
)
if (self.account):
self.assertEqual(
self.client.r_session.headers['X-Cloudant-User'],
self.account
)
agent = self.client.r_session.headers.get('User-Agent')
ua_parts = agent.split('/')
self.assertEqual(len(ua_parts), 6)
Expand Down Expand Up @@ -1413,4 +1415,4 @@ def test_update_cors_configuration(self):
self.client.disconnect()

if __name__ == '__main__':
unittest.main()
unittest.main()
Morty Proxy This is a proxified and sanitized view of the page, visit original site.