def test_deployment_reconciler(self):
        """test that deployment requires update"""
        controller = ProxyKubernetesController(self.outpost,
                                               self.service_connection)
        deployment_reconciler = DeploymentReconciler(controller)

        self.assertIsNotNone(deployment_reconciler.retrieve())

        config = self.outpost.config
        config.kubernetes_replicas = 3
        self.outpost.config = config

        with self.assertRaises(NeedsUpdate):
            deployment_reconciler.reconcile(
                deployment_reconciler.retrieve(),
                deployment_reconciler.get_reference_object(),
            )

        with CONFIG.patch("outposts.container_image_base", "test"):
            with self.assertRaises(NeedsUpdate):
                deployment_reconciler.reconcile(
                    deployment_reconciler.retrieve(),
                    deployment_reconciler.get_reference_object(),
                )

        deployment_reconciler.delete(
            deployment_reconciler.get_reference_object())
예제 #2
0
 def test_discovery(self):
     """Test certificate discovery"""
     builder = CertificateBuilder()
     builder.common_name = "test-cert"
     with self.assertRaises(ValueError):
         builder.save()
     builder.build(
         subject_alt_names=[],
         validity_days=3,
     )
     with TemporaryDirectory() as temp_dir:
         with open(f"{temp_dir}/foo.pem", "w+", encoding="utf-8") as _cert:
             _cert.write(builder.certificate)
         with open(f"{temp_dir}/foo.key", "w+", encoding="utf-8") as _key:
             _key.write(builder.private_key)
         makedirs(f"{temp_dir}/foo.bar", exist_ok=True)
         with open(f"{temp_dir}/foo.bar/fullchain.pem",
                   "w+",
                   encoding="utf-8") as _cert:
             _cert.write(builder.certificate)
         with open(f"{temp_dir}/foo.bar/privkey.pem",
                   "w+",
                   encoding="utf-8") as _key:
             _key.write(builder.private_key)
         with CONFIG.patch("cert_discovery_dir", temp_dir):
             # pyright: reportGeneralTypeIssues=false
             certificate_discovery()  # pylint: disable=no-value-for-parameter
     keypair: CertificateKeyPair = CertificateKeyPair.objects.filter(
         managed=MANAGED_DISCOVERED % "foo").first()
     self.assertIsNotNone(keypair)
     self.assertIsNotNone(keypair.certificate)
     self.assertIsNotNone(keypair.private_key)
     self.assertTrue(
         CertificateKeyPair.objects.filter(managed=MANAGED_DISCOVERED %
                                           "foo.bar").exists())
예제 #3
0
 def test_version_disabled(self):
     """Test Update checker while its disabled"""
     with CONFIG.patch("disable_update_check", True):
         update_latest_version.delay().get()
         self.assertEqual(cache.get(VERSION_CACHE_KEY), "0.0.0")