def _prompt_password(cert_type, bypass_options, config_file_setting):
        options_str = ''
        options_len = len(bypass_options)
        index = 0
        for option in bypass_options:
            options_str += option
            if index < options_len - 1:
                options_str += ' or '
            else:
                options_str += '.'
            index += 1

        config_file_setting = '"security.certificates.<option>.' + config_file_setting + '"'
        print('\n',
              '\n********************************************************************************'
              '\nPlease enter a passphrase for the', cert_type, 'private key.',
              '\n\nTo prevent this prompt from appearing, input the required passphrase',
              '\nor generate the private key without a passphrase.',
              '\n\n When using the command line options to setup the IoT Edge runtime:',
              '\n - Enter the passphrase via the command line options:',
              '\n  ', options_str,
              '\n - When opting not to use a passphrase, use command line option:',
              '\n   --auto-cert-gen-force-no-passwords.',
              '\n\n When using the --config-file to setup the runtime:',
              '\n - Set the input passphrase file via JSON configuration item:',
              '\n  ', config_file_setting,
              '\n - When opting not to use a passphrase, set JSON configuration item:',
              '\n   "security.certificates.<option>.forceNoPasswords" to true.'
              '\n********************************************************************************')
        return EdgeUtils.prompt_password(cert_type,
                                         EdgeCertUtil.MIN_PASSPHRASE_LENGTH,
                                         EdgeCertUtil.MAX_PASSPHRASE_LENGTH)
Exemple #2
0
 def test_prompt_password(self, mock_getpass):
     """ Test a valid invocation of API prompt_password """
     valid_pass = '******'
     mock_getpass.return_value = valid_pass
     result = EdgeUtils.prompt_password('test password', 5, 8)
     self.assertTrue(valid_pass, result)