Skip to content

Commit

Permalink
modify default suffix for clear text cassettes
Browse files Browse the repository at this point in the history
It's better not to add a suffix by default, so that editors can still
recognize file extensions like '.yaml'.
  • Loading branch information
CarloDePieri committed Aug 7, 2021
1 parent c3895d5 commit b83684f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ coverage
.coveralls.yml
.secrets
dist
.idea
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ class MyEncryptedPersister(BaseEncryptedPersister):
The encrypted persister can now be registered and used:

```python
import vcr
import requests

# create a custom vcr object
my_vcr = vcr.VCR()

Expand All @@ -83,27 +86,26 @@ reserving the one with the encrypted persister only for requests resulting in ca

## Customization

Sometimes it can be handy to inspect the content of a cassette. This can be done even for encrypted cassettes:
Sometimes it can be handy to inspect the content of a cassette. This can be done even when using encrypted cassettes:

```python
class MyEncryptedPersister(BaseEncryptedPersister):
encryption_key: bytes = key
should_output_clear_text_as_well = True
```

The persister will output a clear text cassette side by side with the encrypted one. The clear text cassette will
be saved with a specific file extension (`.clear_text` by default): this will allow to blacklist the extension
within the version control system to make sure not to share those files. For example for git:
This persister will output a clear text cassette side by side with the encrypted one. Remember to blacklist all clear
text cassette in the version control system! For example this will cause git to ignore all `.yaml` file inside a
cassettes' folder (at any depth):

```bash
# file: .gitignore
*.clear_text
**/cassettes/**/*.yaml
```

Clear text cassettes are only useful for human inspection: the persister will still use only the encrypted ones to
replay network requests.

If different cassette file extensions are desired, they can be customized:
If different cassettes file name suffix are desired, they can be customized:

```python
class MyEncryptedPersister(BaseEncryptedPersister):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "vcrpy-encrypt"
version = "0.9.0"
version = "0.9.1"
description = "Encrypt vcrpy cassettes so they can be safely kept under version control."

license = "GPL-3.0-only"
Expand Down
2 changes: 1 addition & 1 deletion vcrpy_encrypt/persister.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class BaseEncryptedPersister(ABC):

encryption_key: Union[None, bytes] = None
should_output_clear_text_as_well: bool = False
clear_text_suffix: str = ".clear_text"
clear_text_suffix: str = ""
encoded_suffix: str = ".enc"

@classmethod
Expand Down

0 comments on commit b83684f

Please sign in to comment.