@@ -27,7 +27,10 @@ class TestStashCache(OSGTestCase):
27
27
for x in range (4 )
28
28
]
29
29
30
- def assertCached (self , name , contents ):
30
+ def assertCached (self , name , contents , auth = False ):
31
+ OriginExport = getcfg ("OriginExport" )
32
+ if auth :
33
+ OriginExport = getcfg ("OriginAuthExport" )
31
34
fpath = os .path .join (getcfg ("CacheRootdir" ), getcfg ("OriginExport" ).lstrip ("/" ), name )
32
35
self .assertTrue (os .path .exists (fpath ),
33
36
name + " not cached" )
@@ -47,16 +50,20 @@ def setUp(self):
47
50
by_dependency = True )
48
51
if core .rpm_is_installed ("xcache" ):
49
52
self .skip_ok_if (core .PackageVersion ("xcache" ) < "1.0.2" , "needs xcache 1.0.2+" )
50
- self .skip_bad_unless_running ("xrootd@stash-origin" , "xrootd@stash-cache" )
53
+ self .skip_bad_unless_running ("xrootd@stash-origin" , "xrootd@stash-cache" , "xrootd@stash-origin-auth" ,
54
+ "xrootd@stash-cache-auth" )
51
55
52
56
def test_01_create_files (self ):
53
57
xrootd_user = pwd .getpwnam ("xrootd" )
54
58
for name , contents in self .testfiles :
55
59
files .write (os .path .join (getcfg ("OriginRootdir" ), getcfg ("OriginExport" ).lstrip ("/" ), name ),
56
60
contents , backup = False , chmod = 0o644 ,
57
61
chown = (xrootd_user .pw_uid , xrootd_user .pw_gid ))
62
+ files .write (os .path .join (getcfg ("OriginRootdir" ), getcfg ("OriginAuthExport" ).lstrip ("/" ), name ),
63
+ contents , backup = False , chmod = 0o644 ,
64
+ chown = (xrootd_user .pw_uid , xrootd_user .pw_gid ))
58
65
59
- def test_02_xroot_fetch_from_origin (self ):
66
+ def test_02_xrootd_fetch_from_origin (self ):
60
67
name , contents = self .testfiles [0 ]
61
68
path = os .path .join (getcfg ("OriginExport" ), name )
62
69
result , _ , _ = \
@@ -100,3 +107,53 @@ def test_05_stashcp(self):
100
107
result = tf .read ()
101
108
self .assertEqualVerbose (result , contents , "stashcp'ed file mismatch" )
102
109
self .assertCached (name , contents )
110
+
111
+ def test_06_xrootd_fetch_from_origin_auth (self ):
112
+ core .skip_ok_unless_installed ('globus-proxy-utils' , by_dependency = True )
113
+ self .skip_bad_unless (core .state ['proxy.valid' ], 'requires a proxy cert' )
114
+ name , contents = self .testfiles [0 ]
115
+ path = os .path .join (getcfg ("OriginAuthExport" ), name )
116
+ dest_file = '/tmp/testfileFromOriginAuth'
117
+ os .environ ["XrdSecGSISRVNAMES" ] = "*"
118
+ result , _ , _ = core .check_system (["xrdcp" , "-d1" , '-f' ,
119
+ "root://localhost:%d/%s" % (getcfg ("OriginAuthXrootPort" ), path ),
120
+ dest_file ],
121
+ "Checking xrootd copy from authenticated origin" , user = True )
122
+ origin_file = os .path .join (getcfg ("OriginRootdir" ), getcfg ("OriginAuthExport" ).lstrip ("/" ), name )
123
+ checksum_match = files .checksum_files_match (origin_file , dest_file )
124
+ self .assert_ (checksum_match , 'Origin and directly downloaded file have the same contents' )
125
+
126
+ def test_07_xrootd_fetch_from_auth_cache (self ):
127
+ core .skip_ok_unless_installed ('globus-proxy-utils' , by_dependency = True )
128
+ self .skip_bad_unless (core .state ['proxy.valid' ], 'requires a proxy cert' )
129
+ name , contents = self .testfiles [2 ]
130
+ path = os .path .join (getcfg ("OriginAuthExport" ), name )
131
+ os .environ ["XrdSecGSISRVNAMES" ] = "*"
132
+ dest_file = '/tmp/testfileXrootdFromAuthCache'
133
+ result , _ , _ = \
134
+ core .check_system (["xrdcp" , "-d1" ,"-f" ,
135
+ "root://%s:%d/%s" % (core .get_hostname (),getcfg ("CacheHTTPSPort" ), path ),
136
+ dest_file ], "Checking xrootd copy from Authenticated cache" , user = True )
137
+ origin_file = os .path .join (getcfg ("OriginRootdir" ), getcfg ("OriginAuthExport" ).lstrip ("/" ), name )
138
+ checksum_match = files .checksum_files_match (origin_file , dest_file )
139
+ self .assert_ (checksum_match , 'Origin and file downloaded via cache have the same contents' )
140
+
141
+ def test_08_https_fetch_from_auth_cache (self ):
142
+ core .skip_ok_unless_installed ('globus-proxy-utils' , 'gfal2-plugin-http' , 'gfal2-util' ,
143
+ 'gfal2-plugin-file' , by_dependency = True )
144
+ self .skip_bad_unless (core .state ['proxy.valid' ], 'requires a proxy cert' )
145
+ name , contents = self .testfiles [3 ]
146
+ path = os .path .join (getcfg ("OriginAuthExport" ), name )
147
+ dest_file = '/tmp/testfileHTTPsFromAuthCache'
148
+ uid = pwd .getpwnam (core .options .username )[2 ]
149
+ usercert = '/tmp/x509up_u%d' % uid
150
+ userkey = '/tmp/x509up_u%d' % uid
151
+ result , _ , _ = \
152
+ core .check_system (["gfal-copy" , "-vf" ,
153
+ "--cert" , usercert , "--key" , userkey ,
154
+ "https://%s:%d%s" % (core .get_hostname (),getcfg ("CacheHTTPSPort" ), path ),
155
+ "file://%s" % dest_file ],
156
+ "Checking xrootd copy from Authenticated cache" , user = True )
157
+ origin_file = os .path .join (getcfg ("OriginRootdir" ), getcfg ("OriginAuthExport" ).lstrip ("/" ), name )
158
+ checksum_match = files .checksum_files_match (origin_file , dest_file )
159
+ self .assert_ (checksum_match , 'Origin and file downloaded via cache have the same contents' )
0 commit comments