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

Unit tests development #130

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
13 changes: 13 additions & 0 deletions .env_example
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
USER_NAME="< your e-mail on which to register an account >"
CLIENT_SECRET="< The secret key of your application >"
INTEGRATOR_KEY_JWT="< your Integration Key >"
TEMPLATE_ID="< your template id >"
REDIRECT_URI="< URI for redirect >"
USER_ID="< your User ID >"
BRAND_ID="< your brand ID >"

PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----
...
< your private key >
...
-----END RSA PRIVATE KEY-----"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,4 @@ target/

# Local files
*.DS_Store
.env
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,54 @@ For details regarding which type of OAuth grant will work best for your DocuSign

For security purposes, DocuSign recommends using the [Authorization Code Grant](https://developers.docusign.com/esign-rest-api/guides/authentication/oauth2-code-grant) flow.

## Tests:

### Test configuration
1. Login with your DocuSign account on https://appdemo.docusign.com.
2. Open Apps and Keys section in Settings and press Add App and Integration Key button.
3. Enter App name, add secret key, generate RSA key and press Save button.
4. Create new brand on https://admindemo.docusign.com/brands page and save its ID.
5. Create new template on https://appdemo.docusign.com/templates page and save its ID.
6. Create a .env file at the root of the repository (or rename an existing .env_example file) and fill it with required data from steps 3-5.
7. Write your generated private key into .env file

8. Where in the developer account to look for data for the .env file:
* USER_NAME=< your e-mail on which to register an account >
* CLIENT_SECRET=< The secret key of your application > \
settings => Apps and Keys =>
Apps and Integration Keys your app "ACTIONS" => Edit =>
Authentication => Secret Keys
* INTEGRATOR_KEY_JWT=< your Integration Key > \
settings => Apps and Keys => Integration Key of your app
* TEMPLATE_ID=< your template id > \
templates => in MyTemplates list click by choosen template => template id
* REDIRECT_URI=< URI for redirect >
* USER_ID=< your User ID > \
settings => Apps and Keys => User ID
* BRAND_ID=< your brand ID > \
settings => Brands => your Brand => "Edit" => Brand id
* PRIVATE_KEY=< your private key > \
Settings => "Apps and Keys"
in Apps and Integration Keys choose your application name => "ACTIONS" Edit => Service Integration => + GENERATE RSA

9. Install dependencies: \
python3 -m pip install --upgrade pip \
pip3 install -r requirements.txt \
pip3 install -r test-requirements.txt

10. Run tests: \
python3 -m unittest test.test_oauth \
python3 -m unittest test.unit_tests

### Recomended operating system
The prefered operating system to run unit-tests is Linux.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linux can't be the prefered operation system. Please provide instructions for both Mac and PC


### Installing Python3 language on PC
To run tests for this project, please, install the Python 3.7 or higher on your PC:\
https://www.python.org/downloads/ \
After downloading process is complete, check if you have a Python3 installed on your PC by using \
python3 --version

## Support
Log issues against this client through GitHub. We also have an [active developer community on Stack Overflow](https://stackoverflow.com/questions/tagged/docusignapi).

Expand Down
1 change: 1 addition & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ nose>=1.3.7
pluggy>=0.3.1
py>=1.4.31
randomize>=0.13
python-dotenv
tox
4 changes: 3 additions & 1 deletion test/test_oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
import base64
import os
import unittest
from dotenv import load_dotenv

from docusign_esign.client.api_client import ApiClient
from docusign_esign.client.auth.oauth import OAuthToken

load_dotenv()

class TestConfig(object):
def __init__(self, user_name=None, client_secret =None, user_id=None, integrator_key=None, host=None, recipient_email=None,
Expand All @@ -36,7 +38,7 @@ def __init__(self, user_name=None, client_secret =None, user_id=None, integrator
self.redirect_uri = redirect_uri if redirect_uri else os.environ.get("REDIRECT_URI")

self.oauth_host_name = "account-d.docusign.com"
self.private_key_bytes = base64.b64decode(os.environ.get("PRIVATE_KEY"))
self.private_key_bytes = os.environ.get("PRIVATE_KEY")
self.expires_in = 3600


Expand Down
Loading