Skip to content

Commit ec87724

Browse files
committed
undo changes to auth configuration
1 parent 503976f commit ec87724

File tree

4 files changed

+16
-24
lines changed

4 files changed

+16
-24
lines changed

test/test_client_util.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ def setUp(self):
1919
dirname, filename = os.path.split(os.path.abspath(__file__))
2020
self.testdata_dir = dirname + 'data'
2121
self.local = {'cwl': 'file://' + os.path.join(os.getcwd() + '/testdata/md5sum.cwl'),
22-
'wdl': 'file://' + os.path.join(os.getcwd() + '/testdata/md5sum.wdl'),
23-
'py': 'file://' + os.path.join(os.getcwd() + '/test/test_integration.py'),
24-
'unsupported': 'fake.txt'}
22+
'wdl': 'file://' + os.path.join(os.getcwd() + '/testdata/md5sum.wdl'),
23+
'py': 'file://' + os.path.join(os.getcwd() + '/test/test_integration.py'),
24+
'unsupported': 'fake.txt'}
2525

2626
self.remote = {
2727
'cwl': 'https://raw.githubusercontent.com/common-workflow-language/workflow-service/master/testdata/md5sum.cwl',
@@ -31,9 +31,9 @@ def setUp(self):
3131
'unreachable': 'https://fake.py'}
3232

3333
self.expected = {'cwl': ('v1.0', 'CWL'),
34-
'wdl': ('draft-2', 'WDL'),
35-
'py': ('2.7', 'PY'),
36-
'pyWithPrefix': ('2.7', 'PY')}
34+
'wdl': ('draft-2', 'WDL'),
35+
'py': ('2.7', 'PY'),
36+
'pyWithPrefix': ('2.7', 'PY')}
3737

3838
def tearDown(self):
3939
unittest.TestCase.tearDown(self)

test/test_integration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def setUpClass(cls):
3333
cls.wdl_attachments = ['file://' + os.path.abspath('testdata/md5sum.input')]
3434

3535
# client for the swagger API methods
36-
cls.client = WESClient({'auth': '', 'auth_type': None, 'proto': 'http', 'host': 'localhost:8080'})
36+
cls.client = WESClient({'auth': '', 'proto': 'http', 'host': 'localhost:8080'})
3737

3838
# manual test (wdl only working locally atm)
3939
cls.manual = False

wes_client/util.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,8 @@ def build_wes_request(workflow_file, json_path, attachments=None):
110110
wf_params = json.dumps(json.load(f))
111111
elif json_path.startswith("http"):
112112
wf_params = modify_jsonyaml_paths(json_path)
113-
else:
113+
else:
114114
wf_params = json_path
115-
with open(json_path) as f:
116-
wf_params = json.dumps(json.load(f))
117-
118115
wf_version, wf_type = wf_info(workflow_file)
119116

120117
parts = [("workflow_params", wf_params),
@@ -130,7 +127,7 @@ def build_wes_request(workflow_file, json_path, attachments=None):
130127
if attachments:
131128
for attachment in attachments:
132129
if attachment.startswith("file://"):
133-
attachment = attachment[7:]
130+
attachment = attachment[7:]
134131
attach_f = open(attachment, "rb")
135132
elif attachment.startswith("http"):
136133
attach_f = urlopen(attachment)
@@ -166,10 +163,6 @@ def __init__(self, service):
166163
self.auth = service['auth']
167164
self.proto = service['proto']
168165
self.host = service['host']
169-
auth_param = {'token': 'Authorization',
170-
'api_key': 'X-API-KEY',
171-
None: 'Authorization'}
172-
self.param_in = auth_param[service['auth_type']]
173166

174167
def get_service_info(self):
175168
"""
@@ -185,7 +178,7 @@ def get_service_info(self):
185178
:return: The body of the get result as a dictionary.
186179
"""
187180
postresult = requests.get("%s://%s/ga4gh/wes/v1/service-info" % (self.proto, self.host),
188-
headers={self.param_in: self.auth})
181+
headers={"Authorization": self.auth})
189182
return wes_reponse(postresult)
190183

191184
def list_runs(self):
@@ -201,7 +194,7 @@ def list_runs(self):
201194
:return: The body of the get result as a dictionary.
202195
"""
203196
postresult = requests.get("%s://%s/ga4gh/wes/v1/runs" % (self.proto, self.host),
204-
headers={self.param_in: self.auth})
197+
headers={"Authorization": self.auth})
205198
return wes_reponse(postresult)
206199

207200
def run(self, wf, jsonyaml, attachments):
@@ -221,7 +214,7 @@ def run(self, wf, jsonyaml, attachments):
221214
parts = build_wes_request(wf, jsonyaml, attachments)
222215
postresult = requests.post("%s://%s/ga4gh/wes/v1/runs" % (self.proto, self.host),
223216
files=parts,
224-
headers={self.param_in: self.auth})
217+
headers={"Authorization": self.auth})
225218
return wes_reponse(postresult)
226219

227220
def cancel(self, run_id):
@@ -235,7 +228,7 @@ def cancel(self, run_id):
235228
:return: The body of the delete result as a dictionary.
236229
"""
237230
postresult = requests.delete("%s://%s/ga4gh/wes/v1/runs/%s" % (self.proto, self.host, run_id),
238-
headers={self.param_in: self.auth})
231+
headers={"Authorization": self.auth})
239232
return wes_reponse(postresult)
240233

241234
def get_run_log(self, run_id):
@@ -249,7 +242,7 @@ def get_run_log(self, run_id):
249242
:return: The body of the get result as a dictionary.
250243
"""
251244
postresult = requests.get("%s://%s/ga4gh/wes/v1/runs/%s" % (self.proto, self.host, run_id),
252-
headers={self.param_in: self.auth})
245+
headers={"Authorization": self.auth})
253246
return wes_reponse(postresult)
254247

255248
def get_run_status(self, run_id):
@@ -263,5 +256,5 @@ def get_run_status(self, run_id):
263256
:return: The body of the get result as a dictionary.
264257
"""
265258
postresult = requests.get("%s://%s/ga4gh/wes/v1/runs/%s/status" % (self.proto, self.host, run_id),
266-
headers={self.param_in: self.auth})
259+
headers={"Authorization": self.auth})
267260
return wes_reponse(postresult)

wes_client/wes_client_main.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ def main(argv=sys.argv[1:]):
1616
parser.add_argument("--host", type=str, default=os.environ.get("WES_API_HOST"),
1717
help="Example: '--host=localhost:8080'. Defaults to WES_API_HOST.")
1818
parser.add_argument("--auth", type=str, default=os.environ.get("WES_API_AUTH"), help="Defaults to WES_API_AUTH.")
19-
parser.add_argument("--auth_type", type=str, default=None, help="Defaults to None.")
2019
parser.add_argument("--proto", type=str, default=os.environ.get("WES_API_PROTO", "https"),
2120
help="Options: [http, https]. Defaults to WES_API_PROTO (https).")
2221
parser.add_argument("--quiet", action="store_true", default=False)
@@ -50,7 +49,7 @@ def main(argv=sys.argv[1:]):
5049
print(u"%s %s" % (sys.argv[0], pkg[0].version))
5150
exit(0)
5251

53-
client = WESClient({'auth': args.auth, 'auth_type': args.auth_type, 'proto': args.proto, 'host': args.host})
52+
client = WESClient({'auth': args.auth, 'proto': args.proto, 'host': args.host})
5453

5554
if args.list:
5655
response = client.list_runs() # how to include: page_token=args.page, page_size=args.page_size ?

0 commit comments

Comments
 (0)