Skip to content

Commit 5770b17

Browse files
committed
MB-65344 Don't require password on xdcr-setup with full encryption
If the remote cluster is being setup as full encryption (i.e. only ever users mTLS) then a username and password is not required. Before this commit we would error if they were not passed. Change-Id: I6a6a636cfdf9f2367089d5ceb3744896b39c4c04 Reviewed-on: https://review.couchbase.org/c/couchbase-cli/+/236623 Reviewed-by: Safian Ali <safian.ali@couchbase.com> Well-Formed: Restriction Checker Tested-by: Matt Hall <matt.hall@couchbase.com>
1 parent f4519bd commit 5770b17

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

cbmgr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4113,9 +4113,9 @@ def _set(self, opts):
41134113
_exit_if_errors([f'--xdcr-cluster-name is required to {cmd} a cluster connection'])
41144114
if opts.hostname is None:
41154115
_exit_if_errors([f'--xdcr-hostname is required to {cmd} a cluster connections'])
4116-
if opts.username is None:
4116+
if opts.username is None and opts.secure_connection != "full":
41174117
_exit_if_errors([f'--xdcr-username is required to {cmd} a cluster connections'])
4118-
if opts.password is None:
4118+
if opts.password is None and opts.secure_connection != "full":
41194119
_exit_if_errors([f'--xdcr-password is required to {cmd} a cluster connections'])
41204120
if (opts.encrypt is not None or opts.encryption_type is not None) and opts.secure_connection is not None:
41214121
_exit_if_errors(["Cannot use deprecated flags --xdcr-demand-encryption or --xdcr-encryption-type with"

test/test_cli.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2158,6 +2158,21 @@ def test_edit_xdcr(self):
21582158
expected_params = ['name=name', 'hostname=hostname', 'username=username', 'password=pwd', 'demandEncryption=0']
21592159
self.rest_parameter_match(expected_params)
21602160

2161+
def test_edit_xdcr_cert(self):
2162+
contents = 'this-is-the-cert-and-key-file'
2163+
cert_file = tempfile.NamedTemporaryFile(delete=False)
2164+
cert_file.write(contents.encode('utf-8'))
2165+
cert_file.close()
2166+
2167+
args = ['--xdcr-hostname', 'hostname', '--xdcr-cluster-name', 'name', '--xdcr-secure-connection', 'full',
2168+
'--xdcr-user-certificate', cert_file.name, '--xdcr-user-key', cert_file.name,
2169+
'--xdcr-certificate', cert_file.name]
2170+
self.no_error_run(self.command + ['--edit'] + args, self.server_args)
2171+
self.assertIn('POST:/pools/default/remoteClusters/name', self.server.trace)
2172+
expected_params = ['name=name', 'hostname=hostname', 'demandEncryption=1', 'encryptionType=full',
2173+
f'clientCertificate={contents}', f'clientKey={contents}', f'certificate={contents}']
2174+
self.rest_parameter_match(expected_params)
2175+
21612176
def test_list_xdcr(self):
21622177
self.server_args['remote-clusters'] = [{'name': 'name', 'uuid': '1', 'hostname': 'host', 'username': 'user',
21632178
'uri': 'uri', 'deleted': False}]

0 commit comments

Comments
 (0)