| 57 | return httpx.Response(200, json=data) |
| 58 | |
| 59 | def challenge_send(self, request: httpx.Request) -> httpx.Response: |
| 60 | self._response_count += 1 |
| 61 | nonce = ( |
| 62 | hashlib.sha256(os.urandom(8)).hexdigest() |
| 63 | if self._regenerate_nonce |
| 64 | else class="st">"ee96edced2a0b43e4869e96ebe27563f369c1205a049d06419bb51d8aeddf3d3" |
| 65 | ) |
| 66 | challenge_data = { |
| 67 | class="st">"nonce": nonce, |
| 68 | class="st">"qop": self.qop, |
| 69 | class="st">"opaque": ( |
| 70 | class="st">"ee6378f3ee14ebfd2fff54b70a91a7c9390518047f242ab2271380db0e14bda1" |
| 71 | ), |
| 72 | class="st">"algorithm": self.algorithm, |
| 73 | class="st">"stale": class="st">"FALSE", |
| 74 | } |
| 75 | challenge_str = class="st">", ".join( |
| 76 | &class="cm">#x27;{}=class="st">"{}"'.format(key, value) |
| 77 | for key, value in challenge_data.items() |
| 78 | if value |
| 79 | ) |
| 80 | |
| 81 | headers = { |
| 82 | class="st">"www-authenticate": f&class="cm">#x27;Digest realm=class="st">"httpx@example.org", {challenge_str}', |
| 83 | } |
| 84 | return httpx.Response(401, headers=headers) |
| 85 | |
| 86 | |
| 87 | class RepeatAuth(httpx.Auth): |