Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rediss (Redis over SSL) protocol to RedisDsn #1911

Merged
merged 21 commits into from Dec 30, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/1911-TrDex.md
@@ -0,0 +1 @@
Add `rediss` (Redis over SSL) protocol to `RedisDsn
mykolasolodukha marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 2 additions & 2 deletions docs/usage/types.md
Expand Up @@ -513,8 +513,8 @@ For URI/URL validation the following types are available:
- `AnyHttpUrl`: schema `http` or `https`, TLD not required
- `HttpUrl`: schema `http` or `https`, TLD required, max length 2083
- `PostgresDsn`: schema `postgres` or `postgresql`, user info required, TLD not required
- `RedisDsn`: schema `redis`, user info not required, tld not required (CHANGED: user info not required from
**v1.6** onwards)
- `RedisDsn`: schema `redis` or `rediss`, user info not required, tld not required (CHANGED: user info
not required from **v1.6** onwards)
- `stricturl`, method with the following keyword arguments:
- `strip_whitespace: bool = True`
- `min_length: int = 1`
Expand Down
2 changes: 1 addition & 1 deletion pydantic/networks.py
Expand Up @@ -279,7 +279,7 @@ class PostgresDsn(AnyUrl):


class RedisDsn(AnyUrl):
allowed_schemes = {'redis'}
allowed_schemes = {'redis', 'rediss'}


def stricturl(
Expand Down
3 changes: 3 additions & 0 deletions tests/test_networks.py
Expand Up @@ -326,6 +326,9 @@ class Model(BaseModel):
assert m.a.user == 'user'
assert m.a.password == 'pass'

m = Model(a='rediss://user:pass@localhost:5432/app')
assert m.a == 'rediss://user:pass@localhost:5432/app'

with pytest.raises(ValidationError) as exc_info:
Model(a='http://example.org')
assert exc_info.value.errors()[0]['type'] == 'value_error.url.scheme'
Expand Down