Skip to content

Commit

Permalink
Auth fix
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenburns committed Jul 24, 2024
1 parent e14e55d commit 85a3881
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/posting/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,19 +182,15 @@ def apply_template(self, variables: dict[str, Any]) -> None:

if self.auth:
if self.auth.basic:
template = Template(self.auth.basic.username.get_secret_value())
self.auth.basic.username = SecretStr(template.substitute(variables))
template = Template(self.auth.basic.password.get_secret_value())
self.auth.basic.password = SecretStr(template.substitute(variables))
template = Template(self.auth.basic.username)
self.auth.basic.username = template.substitute(variables)
template = Template(self.auth.basic.password)
self.auth.basic.password = template.substitute(variables)
if self.auth.digest:
template = Template(self.auth.digest.username.get_secret_value())
self.auth.digest.username = SecretStr(
template.substitute(variables)
)
template = Template(self.auth.digest.password.get_secret_value())
self.auth.digest.password = SecretStr(
template.substitute(variables)
)
template = Template(self.auth.digest.username)
self.auth.digest.username = template.substitute(variables)
template = Template(self.auth.digest.password)
self.auth.digest.password = template.substitute(variables)
except (KeyError, ValueError) as e:
raise SubstitutionError(f"Variable not defined: {e}")

Expand Down

0 comments on commit 85a3881

Please sign in to comment.