def test_update_password(self):
     """
     The update_password() method runs a groovy script to update the
     password for the given user.
     """
     username = "******"
     password = "******"
     script = UPDATE_PASSWORD_SCRIPT.format(username=username,
                                            password=password)
     self.fakes.jenkins.scripts[script] = ""
     self.assertIsNone(self.api.update_password(username, password))
Exemple #2
0
 def test_update_password(self):
     """
     The update_password() method runs a groovy script to update the
     password for the given user.
     """
     username = "******"
     password = "******"
     script = UPDATE_PASSWORD_SCRIPT.format(
         username=username, password=password)
     self.fakes.jenkins.scripts[script] = ""
     self.assertIsNone(self.api.update_password(username, password))
Exemple #3
0
    def test_configure_admin_random_password(self):
        """
        If a password is not provided, a random one will be generated.
        """
        def pwgen(length):
            return "z"
        script = UPDATE_PASSWORD_SCRIPT.format(username="******", password="******")
        self.fakes.jenkins.scripts[script] = ""

        self.useFixture(MonkeyPatch("charmhelpers.core.host.pwgen", pwgen))
        self.users.configure_admin()
        self.assertTrue(hookenv.config()["_generated-password"])
Exemple #4
0
    def test_configure_admin_custom_password(self):
        """
        If a password is provided, it's used to configure the admin user.
        """
        self.fakes.juju.config["password"] = "******"
        script = UPDATE_PASSWORD_SCRIPT.format(username="******", password="******")
        self.fakes.jenkins.scripts[script] = ""

        self.users.configure_admin()

        self.assertThat(paths.ADMIN_PASSWORD, FileContains("x"))
        self.assertThat(paths.ADMIN_PASSWORD, HasOwnership(0, 0))
        self.assertThat(paths.ADMIN_PASSWORD, HasPermissions("0600"))

        self.assertThat(paths.LAST_EXEC, FileContains("2.0.0\n"))
        self.assertThat(paths.LAST_EXEC, HasOwnership(123, 456))