|
| 1 | +import os |
| 2 | +import socket |
| 3 | +import shutil |
| 4 | +import tempfile |
| 5 | +import pwd |
| 6 | +import requests |
| 7 | + |
| 8 | +import osgtest.library.core as core |
| 9 | +import osgtest.library.files as files |
| 10 | +import osgtest.library.osgunittest as osgunittest |
| 11 | + |
| 12 | + |
| 13 | +class TestXrootdTPC(osgunittest.OSGTestCase): |
| 14 | + |
| 15 | + |
| 16 | + def test_01_create_macaroons(self): |
| 17 | + core.skip_ok_unless_installed('xrootd', 'xrootd-scitokens', by_dependency=True) |
| 18 | + euid = os.geteuid() |
| 19 | + cert = '/tmp/x509up_u%d' % euid |
| 20 | + key = '/tmp/x509up_u%d' % euid |
| 21 | + cert = os.environ.get('X509_USER_PROXY', cert) |
| 22 | + key = os.environ.get('X509_USER_PROXY', key) |
| 23 | + |
| 24 | + session = requests.Session() |
| 25 | + session.verify = False |
| 26 | + data_json = {"caveats": "activity:%s" % "DOWNLOAD", |
| 27 | + "validity": 20} |
| 28 | + urlServer1 = ("http://",core.gethostname(),":9001", '/tmp/tmp.txt') |
| 29 | + response = session.post(urlServer1, |
| 30 | + headers={"Content-Type": "application/macaroon-request"}, |
| 31 | + data=json.dumps(data_json) |
| 32 | + ) |
| 33 | + self.assertEqual(response.status_code, requests.codes.ok, "Problems Generating the macaroon") |
| 34 | + Macaroon1 = response.text |
| 35 | + data_json = {"caveats": "activity:%s" % "UPLOAD", |
| 36 | + "validity": 20} |
| 37 | + urlServer1 = ("http://",core.gethostname(),":9002", '/tmp/tmp-tpc.txt') |
| 38 | + response = session.post(urlServer1, |
| 39 | + headers={"Content-Type": "application/macaroon-request"}, |
| 40 | + data=json.dumps(data_json) |
| 41 | + ) |
| 42 | + self.assertEqual(response.status_code, requests.codes.ok, "Problems Generating the macaroon") |
| 43 | + Macaroon2 = response.text |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | + |
0 commit comments