1212
1313from __future__ import absolute_import
1414
15+ import base64
1516import os
1617import unittest
1718
2021
2122
2223class TestConfig (object ):
23- def __init__ (self , user_name = None , client_secret = None , user_id = None , password = None , integrator_key = None , host = None , recipient_email = None ,
24+ def __init__ (self , user_name = None , client_secret = None , user_id = None , integrator_key = None , host = None , recipient_email = None ,
2425 recipient_name = None , template_role_name = None , template_id = None , return_url = None , redirect_uri = None ):
25- self .
user_name = user_name if user_name else "[email protected] " 26- self .password = password if password else "{ PASSWORD }
27- self.client_secret = client_secret if client_secret else " 3 b61ffcf - xxxx - xxxx - xxxx - d49f7d82cb55 "
28- self.integrator_key = integrator_key if integrator_key else " ae30ea4e - xxxx - xxxx - xxxx - fcb57d2dc4df "
26+ self .user_name = user_name if user_name else os .environ .get ("USER_NAME" )
27+ self .client_secret = client_secret if client_secret else os .environ .get ("CLIENT_SECRET" )
28+ self .integrator_key = integrator_key if integrator_key else os .environ .get ("INTEGRATOR_KEY_JWT" )
2929 self .host = host if host else "https://demo.docusign.net/restapi"
30- self.recipient_email = recipient_email if recipient_email else " node_sdk @ mailinator . com "
31- self.recipient_name = recipient_name if recipient_name else " node_sdk @ mailinator . com "
32- self.template_role_name = template_role_name if template_role_name else " node_sdk @ mailinator . com "
33- self.template_id = template_id if template_id else " cf2a46c2 - xxxx - xxxx - xxxx - 752547 b1a419 "
34- self.return_url = return_url if return_url else " node_sdk @ mailinator . com "
35- self.user_id = user_id if user_id else " fcc5726c - xxxx - xxxx - xxxx - 40 bbbe6ca126 "
36- self.redirect_uri = redirect_uri if redirect_uri else " http : // 38 a36d7b . ngrok . io "
30+ self .recipient_email = recipient_email if recipient_email else os . environ . get ( "USER_NAME" )
31+ self .recipient_name = recipient_name if recipient_name else os . environ . get ( "USER_NAME" )
32+ self .template_role_name = template_role_name if template_role_name else os . environ . get ( "USER_NAME" )
33+ self .template_id = template_id if template_id else os . environ . get ( "TEMPLATE_ID" )
34+ self .return_url = return_url if return_url else os . environ . get ( "REDIRECT_URI" )
35+ self .user_id = user_id if user_id else os . environ . get ( "USER_ID" )
36+ self .redirect_uri = redirect_uri if redirect_uri else os . environ . get ( "REDIRECT_URI" )
3737
3838 self .oauth_host_name = "account-d.docusign.com"
39- self .private_key_file_name = "{}/keys/private.pem" .format (os .path .dirname (os .path .abspath (__file__ )))
40- self .expires_in_hours = 1
41-
42- # this.IntegratorKeyNoConsent = "66750331-xxxx-xxxx-xxxx-6c1a413a6096";
43- # this.PrivateKeyNoConsentFilename = "../../docs/privateKeyConsentReq.pem";
39+ self .private_key_bytes = base64 .b64decode (os .environ .get ("PRIVATE_KEY" ))
40+ self .expires_in = 3600
4441
4542
4643class TestOauth (unittest .TestCase ):
@@ -62,24 +59,22 @@ def test_oauth_uri(self):
6259 self .api_client .rest_client .pool_manager .clear ()
6360
6461 def test_jwt_application (self ):
65- with open (self .test_config .private_key_file_name , 'r' ) as private_key :
66- token_obj = self .api_client .request_jwt_application_token (client_id = self .test_config .integrator_key ,
67- oauth_host_name = self .test_config .oauth_host_name ,
68- private_key_bytes = private_key .read (),
69- expires_in = self .test_config .expires_in_hours )
70- self .assertTrue (isinstance (token_obj , OAuthToken ))
71- self .api_client .rest_client .pool_manager .clear ()
62+ token_obj = self .api_client .request_jwt_application_token (client_id = self .test_config .integrator_key ,
63+ oauth_host_name = self .test_config .oauth_host_name ,
64+ private_key_bytes = self .test_config .private_key_bytes ,
65+ expires_in = self .test_config .expires_in )
66+ self .assertTrue (isinstance (token_obj , OAuthToken ))
67+ self .api_client .rest_client .pool_manager .clear ()
7268
7369 def test_jwt_user (self ):
74- with open (self .test_config .private_key_file_name , 'r' ) as private_key :
75- token_obj = self .api_client .request_jwt_user_token (client_id = self .test_config .integrator_key ,
76- user_id = self .test_config .user_id ,
77- oauth_host_name = self .api_client .get_oauth_host_name (),
78- private_key_bytes = private_key .read (),
79- expires_in = self .test_config .expires_in_hours
80- )
81- self .assertTrue (isinstance (token_obj , OAuthToken ))
82- self .api_client .rest_client .pool_manager .clear ()
70+ token_obj = self .api_client .request_jwt_user_token (client_id = self .test_config .integrator_key ,
71+ user_id = self .test_config .user_id ,
72+ oauth_host_name = self .api_client .get_oauth_host_name (),
73+ private_key_bytes = self .test_config .private_key_bytes ,
74+ expires_in = self .test_config .expires_in
75+ )
76+ self .assertTrue (isinstance (token_obj , OAuthToken ))
77+ self .api_client .rest_client .pool_manager .clear ()
8378
8479 def test_authorization_code_login (self ):
8580 self .api_client .get_oauth_host_name ()
@@ -100,7 +95,7 @@ def test_authorization_code_login(self):
10095 # # lines:
10196 # #
10297 # code = "code"
103- # token_obj = self.api_client.generate_access_token(self.test_config.integrator_key, self.test_config.client_secret, code)
98+ # token_obj = self.api_client.generate_access_token(self.test_config.integrator_key,self.test_config.client_secret, code)
10499 # self.assertTrue(isinstance(token_obj, OAuthToken))
105100 #
106101 # self.api_client.set_access_token(token_obj)
0 commit comments