예제 #1
0
 def test_ca_create_admin(
     self,
     mock_abspath,
     mock_execute,
     mock_ingress_read,
     mock_isdir,
     mock_listdir,
     mock_register_id,
 ):
     mock_isdir.side_effect = [False]
     mock_listdir.side_effect = [False]
     mock_ingress_read.side_effect = [["an-ingress"]]
     mock_abspath.side_effect = ["/home/nephos/tls_cert.pem"]
     create_admin(self.OPTS, "a_MSP")
     mock_ingress_read.assert_called_once_with("a-ca-hlf-ca",
                                               namespace="ca-namespace",
                                               verbose=False)
     mock_register_id.assert_called_once_with("ca-namespace",
                                              "a-ca",
                                              "an_admin",
                                              "a_password",
                                              admin=True,
                                              verbose=False)
     mock_isdir.assert_called_once_with("./crypto/a_MSP/keystore")
     mock_listdir.assert_not_called()
     mock_abspath.assert_called_once_with("./tls_cert.pem")
     mock_execute.assert_called_once_with(
         "FABRIC_CA_CLIENT_HOME=./config fabric-ca-client enroll " +
         "-u https://an_admin:a_password@an-ingress -M ./crypto/a_MSP --tls.certfiles /home/nephos/tls_cert.pem",
         verbose=False,
     )
예제 #2
0
 def test_ca_create_admin_again(
     self,
     mock_abspath,
     mock_execute,
     mock_ingress_read,
     mock_isdir,
     mock_listdir,
     mock_register_id,
 ):
     mock_isdir.side_effect = [True]
     mock_listdir.side_effect = [True]
     mock_ingress_read.side_effect = [["an-ingress"]]
     mock_abspath.side_effect = ["/home/nephos/tls_cert.pem"]
     create_admin(self.OPTS, "a_MSP", verbose=True)
     mock_ingress_read.assert_called_once_with("a-ca-hlf-ca",
                                               namespace="ca-namespace",
                                               verbose=True)
     mock_register_id.assert_called_once_with("ca-namespace",
                                              "a-ca",
                                              "an_admin",
                                              "a_password",
                                              admin=True,
                                              verbose=True)
     mock_isdir.assert_called_once_with("./crypto/a_MSP/keystore")
     mock_listdir.assert_called_once_with("./crypto/a_MSP/keystore")
     mock_abspath.assert_not_called()
     mock_execute.assert_not_called()
예제 #3
0
 def test_ca_create_admin(self, mock_execute, mock_get_pod, mock_ingress_read):
     mock_pod_exec = mock.Mock()
     mock_pod_exec.execute.side_effect = [
         None,  # List CA identities
         'registration'
     ]
     mock_get_pod.side_effect = [mock_pod_exec]
     mock_ingress_read.side_effect = [['an-ingress']]
     create_admin(self.OPTS, 'a_MSP')
     mock_get_pod.assert_called_once_with(
         namespace='ca-namespace', release='a-ca', app='hlf-ca', verbose=False)
     mock_ingress_read.assert_called_once_with(
         'a-ca-hlf-ca', namespace='ca-namespace', verbose=False)
     mock_pod_exec.execute.assert_has_calls([
         call('fabric-ca-client identity list --id an_admin'),
         call("fabric-ca-client register --id.name an_admin --id.secret a_password --id.attrs 'admin=true:ecert'")
     ])
     mock_execute.assert_called_once_with(
         'FABRIC_CA_CLIENT_HOME=./a_dir fabric-ca-client enroll ' +
         '-u https://an_admin:a_password@an-ingress -M a_MSP --tls.certfiles ./a_cert.pem', verbose=False)