コード例 #1
0
    def test_link(self):
        Storage().link_home(self.storage_dir)
        self.assertTrue(os.path.islink(paths.HOME))
        self.assertEqual(os.path.realpath(paths.HOME), self.storage_dir)
        self.assertThat(paths.HOME, HasOwnership(123, 123))

        # Second run paths.HOME is a link
        Storage().link_home(self.storage_dir)
        self.assertTrue(os.path.islink(paths.HOME))
        self.assertEqual(os.path.realpath(paths.HOME), self.storage_dir)
        self.assertThat(paths.HOME, HasOwnership(123, 123))
コード例 #2
0
    def test_unlink(self):
        with open(os.path.join(self.storage_dir, "touched"), 'w') as f:
            f.write("touched")
        Storage().link_home(self.storage_dir)

        Storage().unlink_home()
        self.assertFalse(os.path.islink(paths.HOME))
        self.assertThat(paths.HOME, HasOwnership(123, 123))

        # Second run is a no-op
        Storage().unlink_home()
        self.assertFalse(os.path.islink(paths.HOME))
        self.assertThat(paths.HOME, HasOwnership(123, 123))
コード例 #3
0
 def test_set_url(self):
     needs_restart = self.configuration.set_url()
     self.assertFalse(needs_restart)
     self.assertThat(paths.LOCATION_CONFIG_FILE, HasOwnership(123, 456))
     self.assertThat(
         paths.LOCATION_CONFIG_FILE,
         FileContains(matcher=Contains("<jenkinsUrl></jenkinsUrl>")))
コード例 #4
0
ファイル: test_users.py プロジェクト: sastix/jenkins-charm
    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))
コード例 #5
0
 def test_bootstrap(self):
     """
     If it hasn't been done yet, the Jenkins configuration file gets
     generated.
     """
     self.configuration.bootstrap()
     self.assertThat(paths.CONFIG_FILE, HasOwnership(123, 456))
     self.assertThat(
         paths.CONFIG_FILE,
         FileContains(matcher=Contains("<numExecutors>1</numExecutors>")))
     self.assertEqual({8080}, self.fakes.juju.ports["TCP"])
コード例 #6
0
 def test_token_set(self):
     """
     The user's API token can be set, and will be saved in the local
     state.
     """
     self.useFixture(JenkinsConfiguredAdmin(self.fakes))
     self.assertEqual("abc", self.credentials.token("abc"))
     self.assertEqual("abc", self.credentials.token())
     self.assertThat(paths.ADMIN_TOKEN, FileContains("abc"))
     self.assertThat(paths.ADMIN_TOKEN, HasOwnership(0, 0))
     self.assertThat(paths.ADMIN_TOKEN, HasPermissions("0600"))
コード例 #7
0
    def test_unlink_no_backup(self):
        Storage().link_home(self.storage_dir)

        Storage().unlink_home()
        self.assertFalse(os.path.islink(paths.HOME))
        self.assertThat(paths.HOME, HasOwnership(123, 123))