forked from globus/transfer-api-client-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_activate.py
More file actions
executable file
·62 lines (51 loc) · 2.14 KB
/
Copy pathtest_activate.py
File metadata and controls
executable file
·62 lines (51 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env python
# Copyright 2010 University of Chicago
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
Test a proxy chain created with mkproxy or some other external method
by using it to activate an endpoint. Real applications should use the provided
API instead - see
globusonline/transfer/api_client/examples/delegate_proxy_activate.py.
Usage:
# Create proxy with 10 hour lifetime. server.pubkey must contain the PEM
# from the public_key activation_requirement.
cat server.pubkey /path/to/activation/credential \
| mkproxy 10 > /tmp/proxy_chain
test_activate.py USERNAME 'ENDPOINT_NAME' /tmp/proxy_chain \
-k /path/to/auth/key -c /path/to/auth/cert
The endpoint name may contain a # which is a shell comment, so be sure to
quote the endpoint name.
"""
import sys
import subprocess
from globusonline.transfer.api_client import create_client_from_args
if __name__ == '__main__':
api, args = create_client_from_args()
if len(args) < 2:
sys.stderr.write(
"username, endpoint, proxy_chain_file arguments are required")
sys.exit(1)
ep = args[0]
proxy_chain_file = args[1]
# Deactivate so if the activation fails, testing ls afterward will also
# fail and not use some old working credential from previous activation.
api.endpoint_deactivate(ep)
_, _, reqs = api.endpoint_activation_requirements(ep,
type="delegate_proxy")
with open(proxy_chain_file) as f:
proxy_chain = f.read()
print proxy_chain
reqs.set_requirement_value("delegate_proxy", "proxy_chain", proxy_chain)
result = api.endpoint_activate(ep, reqs)
print result