6
from requests_oauthlib import OAuth1Session
9
client_access_key = environ['CLIENT_ACCESS_KEY']
11
sys.stderr.write('CLIENT_ACCESS_KEY environment variable must be set')
15
resource_owner_key = environ['RESOURCE_OWNER_KEY']
17
sys.stderr.write('RESOURCE_OWNER_KEY environment variable must be set')
20
# Note: The resource_owner_secret is *secret*, and must be kept secret. If
21
# you think it's been compromised, contact IS with your client access key
22
# and they can invalidate the old key and assign a new one.
24
resource_owner_secret = environ['RESOURCE_OWNER_SECRET']
26
sys.stderr.write('RESOURCE_OWNER_SECRET environment variable must be set')
30
backend = environ['NFSS_BACKEND']
32
sys.stderr.write('NFSS_BACKEND environment variable must be set')
35
if len(sys.argv) != 3:
36
sys.stderr.write("Usage: %s <projectname> <testname>\n" % sys.argv[0])
37
sys.stderr.write("Pipe json test data to this script to insert it into the"
44
if sys.stdin.isatty():
45
sys.stderr.write("Error: Pipe json test data through this script,"
47
sys.stderr.write("$ cat test_data | %s %s %s\n" %
48
(sys.argv[0], project, test))
51
data = sys.stdin.read()
54
except ValueError as e:
55
sys.stderr.write("Error: Data does not appear to be valid json: %s\n" % e)
58
test_session = OAuth1Session(
60
resource_owner_key=resource_owner_key,
61
resource_owner_secret=resource_owner_secret
63
url = '/'.join((backend, project, test))
64
r = test_session.post(url, dict(data=data.encode()))
66
if '403 Forbidden' in r.text:
67
sys.stderr.write('Check your credentials, particularly for \\\\.\n')
68
sys.stderr.write('RESOURCE_OWNER_SECRET is sensitive to that.\n')