|
| 1 | +import os |
| 2 | +import pwd |
| 3 | +import osgtest.library.core as core |
| 4 | +import osgtest.library.files as files |
| 5 | +import osgtest.library.service as service |
| 6 | +import osgtest.library.osgunittest as osgunittest |
| 7 | + |
| 8 | + |
| 9 | +HTTP_PORT1 = 9001 # chosen so it doesn't conflict w/ the stashcache instances |
| 10 | +HTTP_PORT2 = 9002 |
| 11 | + |
| 12 | +XROOTD_CFG_TEXT = """\ |
| 13 | +cms.space min 2g 5g |
| 14 | +xrootd.seclib /usr/lib64/libXrdSec.so |
| 15 | +http.secxtractor /usr/lib64/libXrdLcmaps.so |
| 16 | +
|
| 17 | +sec.protocol /usr/lib64 gsi -d 2 -certdir:/etc/grid-security/certificates \ |
| 18 | + -cert:/etc/grid-security/xrd/xrdcert.pem \ |
| 19 | + -key:/etc/grid-security/xrd/xrdkey.pem \ |
| 20 | + -crl:1 \ |
| 21 | + -ca:0 \ |
| 22 | + --gmapopt:10 \ |
| 23 | + --gmapto:0 \ |
| 24 | + %s |
| 25 | +
|
| 26 | +acc.authdb /etc/xrootd/auth_file |
| 27 | +ofs.authorize |
| 28 | +all.export / |
| 29 | +
|
| 30 | +if exec xrootd |
| 31 | + http.cadir /etc/grid-security/certificates |
| 32 | + http.cert /etc/grid-security/xrd/xrdcert.pem |
| 33 | + http.key /etc/grid-security/xrd/xrdkey.pem |
| 34 | + http.listingdeny yes |
| 35 | + http.desthttps yes |
| 36 | + http.trace all debug |
| 37 | + # Enable third-party-copy |
| 38 | + http.exthandler xrdtpc libXrdHttpTPC.so |
| 39 | + # Pass the bearer token to the Xrootd authorization framework. |
| 40 | + http.header2cgi Authorization authz |
| 41 | +
|
| 42 | + # Enable Macaroons |
| 43 | + ofs.authlib libXrdMacaroons.so |
| 44 | + xrd.port %d |
| 45 | + xrd.protocol http:%d /usr/lib64/libXrdHttp-4.so |
| 46 | +fi |
| 47 | +http.exthandler xrdmacaroons libXrdMacaroons.so |
| 48 | +all.sitename VDTTESTSITE |
| 49 | +
|
| 50 | +""" |
| 51 | + |
| 52 | +class TestStartXrootdTPC(osgunittest.OSGTestCase): |
| 53 | + @core.elrelease(7,8) |
| 54 | + def test_01_configure_xrootd(self): |
| 55 | + core.config['xrootd.tpc.config-1'] = '/etc/xrootd/xrootd-third-party-copy-1.cfg' |
| 56 | + core.config['xrootd.tpc.config-2'] = '/etc/xrootd/xrootd-third-party-copy-2.cfg' |
| 57 | + core.config['xrootd.tpc.http-port1'] = HTTP_PORT1 |
| 58 | + core.config['xrootd.tpc.http-port2'] = HTTP_PORT2 |
| 59 | + core.state['xrootd.started-http-server-1'] = False |
| 60 | + core.state['xrootd.started-http-server-2'] = False |
| 61 | + core.state['xrootd.tpc.backups-exist'] = False |
| 62 | + |
| 63 | + self.skip_ok_unless(core.options.adduser, 'user not created') |
| 64 | + core.skip_ok_unless_installed('globus-proxy-utils', 'xrootd', 'xrootd-scitokens', by_dependency=True) |
| 65 | + |
| 66 | + user = pwd.getpwnam("xrootd") |
| 67 | + |
| 68 | + lcmaps_packages = ('lcmaps', 'lcmaps-db-templates', 'xrootd-lcmaps', 'vo-client', 'vo-client-lcmaps-voms') |
| 69 | + if all([core.rpm_is_installed(x) for x in lcmaps_packages]): |
| 70 | + core.log_message("Using xrootd-lcmaps authentication") |
| 71 | + sec_protocol = '-authzfun:libXrdLcmaps.so -authzfunparms:--loglevel,5' |
| 72 | + sec_protocol += ',--policy,authorize_only' |
| 73 | + else: |
| 74 | + core.log_message("Using XRootD mapfile authentication") |
| 75 | + sec_protocol = '-gridmap:/etc/grid-security/xrd/xrdmapfile' |
| 76 | + |
| 77 | + files.write(core.config['xrootd.tpc.config-1'], |
| 78 | + XROOTD_CFG_TEXT % (sec_protocol, core.config['xrootd.tpc.http-port1'], core.config['xrootd.tpc.http-port1']), |
| 79 | + owner='xrootd', backup=True, chown=(user.pw_uid, user.pw_gid)) |
| 80 | + files.write(core.config['xrootd.tpc.config-2'], |
| 81 | + XROOTD_CFG_TEXT % (sec_protocol, core.config['xrootd.tpc.http-port2'], core.config['xrootd.tpc.http-port2']), |
| 82 | + owner='xrootd', backup=True, chown=(user.pw_uid, user.pw_gid)) |
| 83 | + core.state['xrootd.tpc.backups-exist'] = True |
| 84 | + |
| 85 | + def test_02_create_secrets(self): |
| 86 | + core.skip_ok_unless_installed('xrootd', 'xrootd-scitokens', by_dependency=True) |
| 87 | + core.config['xrootd.tpc.macaroon-secret-1'] = '/etc/xrootd/macaroon-secret-1' |
| 88 | + core.config['xrootd.tpc.macaroon-secret-2'] = '/etc/xrootd/macaroon-secret-2' |
| 89 | + core.check_system(["openssl", "rand", "-base64", "-out", |
| 90 | + core.config['xrootd.tpc.macaroon-secret-1'], "64"], "Creating symmetric key") |
| 91 | + core.check_system(["openssl", "rand", "-base64", "-out", |
| 92 | + core.config['xrootd.tpc.macaroon-secret-2'], "64"], "Creating symmetric key") |
| 93 | + files.append(core.config['xrootd.tpc.config-1'], |
| 94 | + "macaroons.secretkey %s"%(core.config['xrootd.tpc.macaroon-secret-1']), |
| 95 | + owner='xrootd', backup=False) |
| 96 | + files.append(core.config['xrootd.tpc.config-2'], |
| 97 | + "macaroons.secretkey %s"%(core.config['xrootd.tpc.macaroon-secret-2']), |
| 98 | + owner='xrootd', backup=False) |
| 99 | + |
| 100 | + |
| 101 | + def test_03_start_xrootd(self): |
| 102 | + core.skip_ok_unless_installed('xrootd', 'xrootd-scitokens', by_dependency=True) |
| 103 | + core.config['xrootd_tpc_service_1'] = "xrootd@third-party-copy-1" |
| 104 | + core.config['xrootd_tpc_service_2'] = "xrootd@third-party-copy-2" |
| 105 | + service.check_start(core.config['xrootd_tpc_service_1'], log_to_check = '/var/log/xrootd/third-party-copy-1/xrootd.log') |
| 106 | + service.check_start(core.config['xrootd_tpc_service_2'], log_to_check = '/var/log/xrootd/third-party-copy-2/xrootd.log') |
| 107 | + core.state['xrootd.started-http-server-1'] = True |
| 108 | + core.state['xrootd.started-http-server-2'] = True |
| 109 | + |
0 commit comments