Skip to content

Commit

Permalink
Merge pull request #27 from freedomofpress/stable-dev-env
Browse files Browse the repository at this point in the history
minor fixes to stabilize the dev env
  • Loading branch information
kushaldas authored Oct 23, 2018
2 parents 519ecc6 + f23c4c7 commit 4aea061
Show file tree
Hide file tree
Showing 7 changed files with 213 additions and 76 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
testtoken.json

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
31 changes: 31 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
DEFAULT_GOAL: help
OPEN=$(word 1, $(wildcard /usr/bin/xdg-open /usr/bin/open))

.PHONY: format
format: ## Run the formatter
@docker build -t securedrop-sdk/black:latest -f Dockerfile.black . && \
docker run --rm -v $(PWD):/home/kdas/workplace securedrop-sdk/black:latest black .

TESTS ?= tests
.PHONY: test
test: ## Run the test suite
@pipenv run python -m pytest -v --cov sdclientapi --cov-report html --cov-report term-missing $(TESTS)

.PHONY: open-coverage-report
open-coverage-report: ## Open the coverage report in your browser
@$(OPEN) htmlcov/index.html

# Explaination of the below shell command should it ever break.
# 1. Set the field separator to ": ##" and any make targets that might appear between : and ##
# 2. Use sed-like syntax to remove the make targets
# 3. Format the split fields into $$1) the target name (in blue) and $$2) the target descrption
# 4. Pass this file as an arg to awk
# 5. Sort it alphabetically
# 6. Format columns with colon as delimiter.
.PHONY: help
help: ## Print this message and exit.
@printf "Makefile for developing and testing the SecureDrop SDK.\n"
@printf "Subcommands:\n\n"
@awk 'BEGIN {FS = ":.*?## "} /^[0-9a-zA-Z_-]+:.*?## / {printf "\033[36m%s\033[0m : %s\n", $$1, $$2}' $(MAKEFILE_LIST) \
| sort \
| column -s ':' -t
2 changes: 2 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ vcrpy = "*"
mypy = "*"
pyotp = "*"
sphinx = "*"
pytest = "*"
pytest-cov = "*"

[packages]
requests = "*"
234 changes: 174 additions & 60 deletions Pipfile.lock

Large diffs are not rendered by default.

13 changes: 0 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,6 @@ This is a Python3 project.

We are using [mypy](http://mypy-lang.org) for type annotation checks.

### Code formatting

We are using [Black](https://black.readthedocs.io/en/stable/) tool for code formatting. There is a dockerfile
in the repository, which can be used to run Black on the code.

```
docker build -t kdas/black -f Dockerfile.black
docker run --rm -v $PWD:/home/kdas/workplace kdas/black black .
```

Note: The dockerfile still needs work.


We cover all the API calls of SecureDrop.

Note: The `get_source` will get an update to take a Source object as an input.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
long_description=long_description,
long_description_content_type="text/markdown",
license="GPLv3+",
install_requires=["requests",],
install_requires=["requests"],
python_requires=">=3.5",
url="https://github.com/freedomofpress/securedrop-sdk",
packages=setuptools.find_packages(exclude=["docs", "tests"]),
Expand Down
5 changes: 3 additions & 2 deletions tests/test_apiproxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ def setUp(self):
self.username = "journalist"
self.password = "correct horse battery staple profanity oil chewy"
self.server = "http://localhost:8081/"
self.api = API(self.server, self.username, self.password,
str(self.totp.now()), proxy=True)
self.api = API(
self.server, self.username, self.password, str(self.totp.now()), proxy=True
)
for i in range(3):
try:
self.api.authenticate()
Expand Down

0 comments on commit 4aea061

Please sign in to comment.