def test_create_smime_info_file_not_found(self): smime_info = smime_snippets.create_smime_info('files/notfound.p12') self.mock_insert.assert_not_called() self.mock_list.assert_not_called() self.mock_set_default.assert_not_called() self.assertIsNone(smime_info)
def test_create_smime_info_with_password(self): smime_info = smime_snippets.create_smime_info('files/cert.p12', 'password') self.assertIsNotNone(smime_info) self.assertSetEqual(set(smime_info.keys()), set(['pkcs12', 'encryptedKeyPassword'])) self.assertGreater(len(smime_info['pkcs12']), 0) self.assertEqual(smime_info['encryptedKeyPassword'], 'password')
def test_insert_smime_info(self): insert_result = self.make_fake_insert_result() self.mock_insert.return_value = mock.Mock( **{'execute.return_value': insert_result}) smime_info = smime_snippets.create_smime_info('files/cert.p12') result = smime_snippets.insert_smime_info(self.mock_service, self.TEST_USER, smime_info) self.mock_insert.assert_called_with(userId=self.TEST_USER, sendAsEmail=self.TEST_USER, body=smime_info) self.mock_list.assert_not_called() self.mock_set_default.assert_not_called() self.assertEqual(result, insert_result)
def test_insert_smime_info_error(self): fake_error = self.make_http_error(500, 'Fake Error') self.mock_insert.side_effect = fake_error smime_info = smime_snippets.create_smime_info('files/cert.p12') result = smime_snippets.insert_smime_info(self.mock_service, self.TEST_USER, smime_info, '*****@*****.**') self.mock_insert.assert_called_with( userId=self.TEST_USER, sendAsEmail='*****@*****.**', body=smime_info) self.mock_list.assert_not_called() self.mock_set_default.assert_not_called() self.assertIsNone(result)
def test_create_smime_info(self): smime_info = smime_snippets.create_smime_info('files/cert.p12') self.assertIsNotNone(smime_info) self.assertListEqual(list(smime_info.keys()), ['pkcs12']) self.assertGreater(len(smime_info['pkcs12']), 0)