Skip to content

Commit

Permalink
fix(CredentialsHelper): Add single quotes around username/password to…
Browse files Browse the repository at this point in the history
… support special characters in credentials (#171)

Co-authored-by: Nikolas Philips <nikolas.philips@baloise.com>
  • Loading branch information
niiku and Nikolas Philips committed Feb 18, 2022
1 parent b5833f6 commit bd2ad19
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions gitopscli/git_api/git_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def __create_credentials_file(self, username: str, password: str) -> str:
file_path = f"{self.__tmp_dir}/credentials.sh"
with open(file_path, "w") as text_file:
text_file.write("#!/bin/sh\n")
text_file.write(f"echo username={username}\n")
text_file.write(f"echo password={password}\n")
text_file.write(f"echo username='{username}'\n")
text_file.write(f"echo password='{password}'\n")
os.chmod(file_path, 0o700)
return file_path
4 changes: 2 additions & 2 deletions tests/git_api/test_git_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ def test_clone_with_credentials(self, logging_mock):
self.assertEqual(
"""\
#!/bin/sh
echo username=User
echo password=Pass
echo username='User'
echo password='Pass'
""",
credentials_file,
)
Expand Down

0 comments on commit bd2ad19

Please sign in to comment.