-
Notifications
You must be signed in to change notification settings - Fork 10
Cleanup #9
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
Merged
Cleanup #9
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| name: Test Python package | ||
|
|
||
| on: [push] | ||
|
|
||
| jobs: | ||
| build: | ||
|
|
||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| - name: Set up Python ${{ matrix.python-version }} | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | ||
| - name: Run tests | ||
| run: | | ||
| make test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| include CHANGELOG.md |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| [build-system] | ||
| requires = ["setuptools>=61.0.0", "wheel"] | ||
| build-backend = "setuptools.build_meta" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| python-dotenv~=0.21.0 | ||
| cryptography<41.0.0,>=3.1.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| __title__ = "python-dotenv-vault" | ||
| __description__ = "Decrypt .env.vault file." | ||
| __url__ = "https://github.com/dotenv-org/python-dotenv-vault" | ||
| __version__ = "0.4.1" | ||
| __version__ = "0.5.0" | ||
| __author__ = "dotenv" | ||
| __author_email__ = "mot@dotenv.org" | ||
| __license__ = "MIT" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| from io import StringIO | ||
| import os | ||
| import unittest | ||
|
|
||
| from dotenv.main import DotEnv | ||
|
|
||
| import dotenv_vault.main as vault | ||
|
|
||
| class TestParsing(unittest.TestCase): | ||
| TEST_KEYS = [ | ||
| # OK. | ||
| ["dotenv://:key_0dec82bea24ada79a983dcc11b431e28838eae59a07a8f983247c7ca9027a925@dotenv.local/vault/.env.vault?environment=development", | ||
| True, "DOTENV_VAULT_DEVELOPMENT"], | ||
|
|
||
| # Key too short (must be 64 characters + prefix). | ||
| ["dotenv://:key_1234@dotenv.org/vault/.env.vault?environment=production", | ||
| False, "DOTENV_VAULT_PRODUCTION"], | ||
|
|
||
| # Missing key value. | ||
| ["dotenv://dotenv.org/vault/.env.vault?environment=production", | ||
| False, "DOTENV_VAULT_PRODUCTION"], | ||
|
|
||
| # Missing environment. | ||
| ["dotenv://:key_1234@dotenv.org/vault/.env.vault", False, ""] | ||
| ] | ||
|
|
||
| def test_key_parsing(self): | ||
| for test in self.TEST_KEYS: | ||
| dotenv_key, should_pass, environment_key_check = test | ||
| old_dotenv_key = os.environ.get("DOTENV_KEY") | ||
| os.environ["DOTENV_KEY"] = dotenv_key | ||
| try: | ||
| key, environment_key = vault.parse_key(dotenv_key) | ||
| self.assertTrue(should_pass) | ||
| self.assertEqual(environment_key, environment_key_check) | ||
| except Exception as exc: | ||
| self.assertFalse(should_pass) | ||
| finally: | ||
| os.unsetenv("DOTENV_KEY") | ||
| if old_dotenv_key: | ||
| os.environ["DOTENV_KEY"] = old_dotenv_key | ||
|
|
||
| PARSE_TEST_KEY = "dotenv://:key_0dec82bea24ada79a983dcc11b431e28838eae59a07a8f983247c7ca9027a925@dotenv.local/vault/.env.vault?environment=development" | ||
|
|
||
| PARSE_TEST_VAULT = """# .env.vault (generated with npx dotenv-vault local build) | ||
| DOTENV_VAULT_DEVELOPMENT="H2A2wOUZU+bjKH3kTpeua9iIhtK/q7/VpAn+LLVNnms+CtQ/cwXqiw==" | ||
| """ | ||
|
|
||
| def test_vault_parsing(self): | ||
| old_dotenv_key = os.environ.get("DOTENV_KEY") | ||
| os.environ["DOTENV_KEY"] = self.PARSE_TEST_KEY | ||
| try: | ||
| stream = vault.parse_vault(StringIO(self.PARSE_TEST_VAULT)) | ||
| dotenv = DotEnv(dotenv_path=".env.vault", stream=stream) | ||
| self.assertEqual(dotenv.dict().get("HELLO"), "world") | ||
| finally: | ||
| os.unsetenv("DOTENV_KEY") | ||
| if old_dotenv_key: | ||
| os.environ["DOTENV_KEY"] = old_dotenv_key | ||
|
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ian-ross what does this do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It uses this thing to wrap the build process. More recent versions of pip complain about packages with only a
setup.py, so I needed to add apyproject.toml, and thisbuildpackage is a nice front-end to the wholepyproject.toml-drive package build approach. (It works with other build systems like Poetry as well, so you can just saypython -m buildto build your distribution whatever build system you're using.)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh cool! do I need to install poetry?
I was curious about this because when i tried doing
make buildI get aNo module named buildThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ha. You're totally right. That's a mistake.
You don't need to install Poetry. The build still uses
setuptools(you can see that in thepyproject.ymlfile). However, you do need to have the build package installed. I have this installed because I use Poetry on some other projects and Poetry depends onbuildso I get it for free. It's not working for you because thebuildpackage isn't installed by default, and I forgot to add something to the Makefile to install it. There's a line in the CI setup that installs it, but I need to add something to the Makefile as well.I'll do that right now and make a new release. Thanks for looking at this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in v0.5.2! Thanks again!