def runTest(self, mock_gp):
        """Test 'st2 login' functionality with --write-password flag set"""

        expected_username = self.TOKEN["user"]
        args = [
            "--config",
            self.CONFIG_FILE,
            "login",
            expected_username,
            "--password",
            "Password1!",
            "--write-password",
        ]

        self.shell.run(args)

        with open(self.CONFIG_FILE, "r") as config_file:

            for line in config_file.readlines():

                # Make sure certain values are not present
                self.assertNotIn("olduser", line)

                # Make sure configured username is what we expect
                if "username" in line:
                    self.assertEqual(line.split(" ")[2][:-1], expected_username)

            # validate token was created
            self.assertTrue(
                os.path.isfile("%stoken-%s" % (self.DOTST2_PATH, expected_username))
            )
Test 'st2 login' functionality with --write-password flag set
st2client/tests/unit/test_auth.py