Skip to content

Commit

Permalink
Add CredentialsAuthHeader dataclass
Browse files Browse the repository at this point in the history
  • Loading branch information
azgabur committed Oct 30, 2023
1 parent 9cb8f26 commit 4673136
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions testsuite/objects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,24 @@ class Credentials:

def asdict(self):
"""Custom asdict because of needing to put location as parent dict key for inner dict"""
if self.in_location == "authorizationHeader":
return {self.in_location: {"prefix": self.keySelector}}
assert (
self.in_location != "authorizationHeader"
), "For 'authorizationHeader' please use CredentialsAuthHeader dataclass."
return {self.in_location: {"name": self.keySelector}}


@dataclass
class CredentialsAuthHeader(Credentials):
"""Dataclass for Credentials of type Authorization Header."""

def __post_init__(self):
assert self.in_location == "authorizationHeader"

def asdict(self):
"""Custom asdict because of needing to put location as parent dict key for inner dict"""
return {self.in_location: {"prefix": self.keySelector}}


@dataclass
class Rule:
"""
Expand Down

0 comments on commit 4673136

Please sign in to comment.