@@ -619,8 +619,8 @@ def test_bucket_create_encryption(self):
619619 expected_params = [
620620 'bucketType=couchbase' , 'name=name' , 'evictionPolicy=fullEviction' , 'replicaNumber=0' ,
621621 'ramQuotaMB=100' , 'storageBackend=magma' , 'rank=3' , 'numVBuckets=128' ,
622- 'encryptionAtRestKeyId=2' , f'encryptionAtRestDekRotationInterval={ 30 * 24 * 60 * 60 } ' ,
623- f'encryptionAtRestDekLifetime={ 60 * 24 * 60 * 60 } ' ,
622+ 'encryptionAtRestKeyId=2' , f'encryptionAtRestDekRotationInterval={ 30 * 24 * 60 * 60 } ' ,
623+ f'encryptionAtRestDekLifetime={ 60 * 24 * 60 * 60 } ' ,
624624 ]
625625 self .rest_parameter_match (expected_params )
626626
@@ -793,8 +793,8 @@ def test_bucket_edit_encryption_settings(self):
793793 ]
794794 self .no_error_run (self .command + self .command_args + args , self .server_args )
795795 expected_params = [
796- 'encryptionAtRestKeyId=2' , f'encryptionAtRestDekRotationInterval={ 30 * 24 * 60 * 60 } ' ,
797- f'encryptionAtRestDekLifetime={ 60 * 24 * 60 * 60 } ' ,
796+ 'encryptionAtRestKeyId=2' , f'encryptionAtRestDekRotationInterval={ 30 * 24 * 60 * 60 } ' ,
797+ f'encryptionAtRestDekLifetime={ 60 * 24 * 60 * 60 } ' ,
798798 ]
799799 self .rest_parameter_match (expected_params )
800800
@@ -1360,15 +1360,15 @@ def test_set_encryption(self):
13601360 '--dek-lifetime' , '60' ]
13611361 self .no_error_run (self .command + args , self .server_args )
13621362 expected_params = ['log.encryptionMethod=encryptionKey' , 'log.encryptionKeyId=2' ,
1363- f'log.dekRotationInterval={ 30 * 24 * 60 * 60 } ' , f'log.dekLifetime={ 60 * 24 * 60 * 60 } ' ]
1363+ f'log.dekRotationInterval={ 30 * 24 * 60 * 60 } ' , f'log.dekLifetime={ 60 * 24 * 60 * 60 } ' ]
13641364 self .rest_parameter_match (expected_params )
13651365
13661366 def test_set_encryption_master_password (self ):
13671367 args = ['--set' , '--type' , 'master-password' , '--target' , 'log' , '--dek-rotate-every' , '30' ,
13681368 '--dek-lifetime' , '60' ]
13691369 self .no_error_run (self .command + args , self .server_args )
13701370 expected_params = ['log.encryptionMethod=nodeSecretManager' ,
1371- f'log.dekRotationInterval={ 30 * 24 * 60 * 60 } ' , f'log.dekLifetime={ 60 * 24 * 60 * 60 } ' ]
1371+ f'log.dekRotationInterval={ 30 * 24 * 60 * 60 } ' , f'log.dekLifetime={ 60 * 24 * 60 * 60 } ' ]
13721372 self .rest_parameter_match (expected_params )
13731373
13741374 def test_add_edit_key_no_name (self ):
@@ -2310,27 +2310,73 @@ def test_regenerate_cert_not_init(self):
23102310 self .assertIn ('POST:/controller/regenerateCertificate' , self .server .trace )
23112311 self .assertIn ('Certificate regenerate and copied to `node1.pem`' , self .str_output )
23122312
2313+ def test_set_node_certificate_missing (self ):
2314+ self .system_exit_run (self .command + ['--set-node-certificate' ], self .server_args )
2315+ self .assertIn ('--pkey-passphrase-settings is required' , self .str_output )
2316+
2317+ def test_set_node_certificate_invalid_json (self ):
2318+ with tempfile .NamedTemporaryFile () as link_options_file :
2319+ link_options_file .write (b'{123:123}' )
2320+ link_options_file .flush ()
2321+
2322+ self .system_exit_run (self .command + ['--set-node-certificate' , '--pkey-passphrase-settings' ,
2323+ link_options_file .name ], self .server_args )
2324+ self .assertIn ('does not contain valid JSON data' , self .str_output )
2325+
23132326 def test_set_node_certificate (self ):
2314- self .no_error_run (self .command + ['--set-node-certificate' ], self .server_args )
2315- self .assertIn ('POST:/node/controller/reloadCertificate' , self .server .trace )
2316- self .assertIn ('Node certificate set' , self .str_output )
2327+ with tempfile .NamedTemporaryFile () as link_options_file :
2328+ link_options_file .write (b'{"asd":123}' )
2329+ link_options_file .flush ()
2330+
2331+ self .no_error_run (self .command + ['--set-node-certificate' , '--pkey-passphrase-settings' ,
2332+ link_options_file .name ], self .server_args )
2333+ self .assertIn ('POST:/node/controller/reloadCertificate' , self .server .trace )
2334+ self .assertIn ('Node certificate set' , self .str_output )
23172335
23182336 def test_set_node_certificate_not_init (self ):
2319- self .server_args ['init' ] = False
2320- self .no_error_run (self .command + ['--set-node-certificate' ], self .server_args )
2321- self .assertIn ('POST:/node/controller/reloadCertificate' , self .server .trace )
2322- self .assertIn ('Node certificate set' , self .str_output )
2337+ with tempfile .NamedTemporaryFile () as link_options_file :
2338+ link_options_file .write (b'{"asd":123}' )
2339+ link_options_file .flush ()
2340+
2341+ self .server_args ['init' ] = False
2342+ self .no_error_run (self .command + ['--set-node-certificate' , '--pkey-passphrase-settings' ,
2343+ link_options_file .name ], self .server_args )
2344+ self .assertIn ('POST:/node/controller/reloadCertificate' , self .server .trace )
2345+ self .assertIn ('Node certificate set' , self .str_output )
2346+
2347+ def test_set_client_certificate_missing (self ):
2348+ self .system_exit_run (self .command + ['--set-client-certificate' ], self .server_args )
2349+ self .assertIn ('--pkey-passphrase-settings is required' , self .str_output )
2350+
2351+ def test_set_client_certificate_invalid_json (self ):
2352+ with tempfile .NamedTemporaryFile () as link_options_file :
2353+ link_options_file .write (b'{123:123}' )
2354+ link_options_file .flush ()
2355+
2356+ self .system_exit_run (self .command + ['--set-client-certificate' , '--pkey-passphrase-settings' ,
2357+ link_options_file .name ], self .server_args )
2358+ self .assertIn ('does not contain valid JSON data' , self .str_output )
23232359
23242360 def test_set_client_certificate (self ):
2325- self .no_error_run (self .command + ['--set-client-certificate' ], self .server_args )
2326- self .assertIn ('POST:/node/controller/reloadClientCertificate' , self .server .trace )
2327- self .assertIn ('Internal client certificate set' , self .str_output )
2361+ with tempfile .NamedTemporaryFile () as link_options_file :
2362+ link_options_file .write (b'{"asd":123}' )
2363+ link_options_file .flush ()
2364+
2365+ self .no_error_run (self .command + ['--set-client-certificate' , '--pkey-passphrase-settings' ,
2366+ link_options_file .name ], self .server_args )
2367+ self .assertIn ('POST:/node/controller/reloadClientCertificate' , self .server .trace )
2368+ self .assertIn ('Internal client certificate set' , self .str_output )
23282369
23292370 def test_set_client_certificate_not_init (self ):
2330- self .server_args ['init' ] = False
2331- self .no_error_run (self .command + ['--set-client-certificate' ], self .server_args )
2332- self .assertIn ('POST:/node/controller/reloadClientCertificate' , self .server .trace )
2333- self .assertIn ('Internal client certificate set' , self .str_output )
2371+ with tempfile .NamedTemporaryFile () as link_options_file :
2372+ link_options_file .write (b'{"asd":123}' )
2373+ link_options_file .flush ()
2374+
2375+ self .server_args ['init' ] = False
2376+ self .no_error_run (self .command + ['--set-client-certificate' , '--pkey-passphrase-settings' ,
2377+ link_options_file .name ], self .server_args )
2378+ self .assertIn ('POST:/node/controller/reloadClientCertificate' , self .server .trace )
2379+ self .assertIn ('Internal client certificate set' , self .str_output )
23342380
23352381 def test_set_node_certificate_with_pkey_settings (self ):
23362382 pkey_settings_file = tempfile .NamedTemporaryFile (delete = False )
@@ -2603,7 +2649,7 @@ def succ_cmd(self, addrFamily):
26032649
26042650def read_password (sock ):
26052651 (result , remoteaddr ) = sock .recvfrom (128 )
2606- assert (result == b'asdasd' )
2652+ assert (result == b'asdasd' )
26072653 sock .sendto (b'ok' , remoteaddr )
26082654
26092655
0 commit comments