import os
import unittest

import osgtest.library.core as core
import osgtest.library.osgunittest as osgunittest

class TestSetupVomsAdmin(osgunittest.OSGTestCase):

    def test_01_wait_for_voms_admin(self):
        core.state['voms.started-webapp'] = False

        core.skip_ok_unless_installed('voms-admin-server')

        line, gap = core.monitor_file(core.config['voms.webapp-log'],
                                      core.state['voms.webapp-log-stat'],
                                      'VOMS-Admin started succesfully', 60.0)
        self.assert_(line is not None, 'VOMS Admin webapp started')
        core.state['voms.started-webapp'] = True
        core.log_message('VOMS Admin started after %.1f seconds' % gap)

    def test_02_open_access(self):
        core.skip_ok_unless_installed('voms-admin-server', 'voms-admin-client')
        self.skip_ok_unless(core.state['voms.started-webapp'], 'VOMS Admin webapp not started')

        command = ('voms-admin', '--nousercert',
                   '--vo', core.config['voms.vo'],
                   'add-ACL-entry', '/' + core.config['voms.vo'], 'ANYONE',
                   'VOMS_CA', 'CONTAINER_READ,MEMBERSHIP_READ', 'true')
        core.check_system(command, 'Add VOMS Admin ACL entry')

@@ -386,46 +386,8 @@
 g'%5D,
-%0A                                     
  cor
@@ -495,9 +495,10 @@
 y', 
-6
+12
 0.0)
@@ -948,35 +948,16 @@
 ercert',
-%0A                  
  '--vo',
@@ -980,18 +980,34 @@
 ms.vo'%5D,
-%0A
  
+'add-ACL-entry',%0A
         
@@ -1016,32 +1016,16 @@
         
-'add-ACL-entry',
  '/' + c
@@ -1056,35 +1056,16 @@
 ANYONE',
-%0A                  
  'VOMS_C

Increase the timeout value for the VOMS Admin start-up from 60s to 120s. Primarily, this is driven by occasional timeouts in the VMU tests, which can run slowly on a heavily loaded host.