Acloud over secure webrtc openssl command implementation.

Use openssl tool instead of mkcert.

Bug: 214337220
Test: acloud-dev create
acloud-dev create --local-image
acloud-dev create --local-instance
acloud-dev create --local-instance --local-image
acloud-dev setup

Change-Id: I01ea06b2ee30b69683f645c4b0b1b2f0d365d9cd
diff --git a/setup/mkcert_test.py b/setup/mkcert_test.py
new file mode 100644
index 0000000..6a88178
--- /dev/null
+++ b/setup/mkcert_test.py
@@ -0,0 +1,95 @@
+# Copyright 2022 - The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+"""Tests for mkcert."""
+import filecmp
+import os
+import unittest
+
+from acloud.internal.lib import driver_test_lib
+from acloud.internal.lib import utils
+from acloud.setup import mkcert
+
+
+class MkcertTest(driver_test_lib.BaseDriverTest):
+    """Test Mkcert."""
+
+    # pylint: disable=no-member
+    def testInstall(self):
+        """Test Install."""
+        self.Patch(os.path, "isdir", return_value=False)
+        self.Patch(os.path, "exists", return_value=False)
+        self.Patch(os, "mkdir")
+        self.Patch(mkcert, "IsRootCAReady")
+        self.Patch(mkcert, "UnInstall")
+        self.Patch(utils, "Popen")
+        mkcert.Install()
+        os.mkdir.assert_called_once()
+        self.assertEqual(4, utils.Popen.call_count)
+        utils.Popen.reset_mock()
+
+        self.Patch(os.path, "isdir", return_value=True)
+        self.Patch(os.path, "exists", return_value=True)
+        mkcert.Install()
+        mkcert.UnInstall.assert_called_once()
+        self.assertEqual(0, utils.Popen.call_count)
+
+
+    def testAllocateLocalHostCert(self):
+        """Test AllocateLocalHostCert."""
+        self.Patch(mkcert, "IsRootCAReady", return_value=False)
+        self.assertFalse(mkcert.AllocateLocalHostCert())
+
+        self.Patch(mkcert, "IsRootCAReady", return_value=True)
+        self.Patch(os.path, "exists", return_value=True)
+        self.Patch(utils, "Popen")
+        self.Patch(mkcert, "IsCertificateReady")
+        mkcert.AllocateLocalHostCert()
+        self.assertEqual(0, utils.Popen.call_count)
+
+        self.Patch(os.path, "exists", return_value=False)
+        mkcert.AllocateLocalHostCert()
+        self.assertEqual(3, utils.Popen.call_count)
+
+
+    def testIsRootCAReady(self):
+        """Test IsRootCAReady."""
+        self.Patch(os.path, "exists", return_value=True)
+        self.Patch(filecmp, "cmp", return_value=True)
+        self.assertTrue(mkcert.IsRootCAReady())
+
+        self.Patch(filecmp, "cmp", return_value=False)
+        self.assertFalse(mkcert.IsRootCAReady())
+
+        self.Patch(os.path, "exists", return_value=False)
+        self.assertFalse(mkcert.IsRootCAReady())
+
+
+    def testIsCertificateReady(self):
+        """Test IsCertificateReady."""
+        self.Patch(os.path, "exists", return_value=False)
+        self.assertFalse(mkcert.IsCertificateReady())
+
+        self.Patch(os.path, "exists", return_value=True)
+        self.assertTrue(mkcert.IsCertificateReady())
+
+
+    def testUnInstall(self):
+        """Test UnInstall."""
+        self.Patch(utils, "Popen")
+        mkcert.UnInstall()
+        self.assertEqual(3, utils.Popen.call_count)
+
+
+if __name__ == '__main__':
+    unittest.main()