def createAccounts():
    """
   Create accounts for testers and test scripts to use on qasharing cosmo box
   """
    SERVER_URL = r'http://qasharing.osafoundation.org:8080'
    getConfig()
    usersCreated = []

    #login as root
    client = cosmoclient.CosmoClient(SERVER_URL)
    client.set_basic_auth(ADMIN_USER, ADMIN_PASS)

    #Discover existing users
    p = re.compile('(?:<username>)(.*)(?:</username>)')

    def listExistingUsers():
        accountData = client.get(client._cmp_path + '/users')
        return p.findall(accountData, re.DOTALL)

    #create accounts
    existingUsers = listExistingUsers()
    for acc in USER_ACCOUNTS:
        user = acc['user']
        if user not in existingUsers:
            client.add_user(user, acc['pw'], acc['first'], acc['last'],
                            acc['email'])
            assert client.response.status == 201
            usersCreated.append(user)
        else:
            print 'UserName %s already exists on cosmo server' % user

    #update existing users and verify accounts exist
    existingUsers = listExistingUsers()
    for user in usersCreated:
        assert user in existingUsers
Exemplo n.º 2
0
def setup_module(module,
                 server_url=SERVER_URL,
                 admin_user=ADMIN_USER,
                 admin_pass=ADMIN_PASS,
                 user_prefix=TEST_USER_PREFIX):
    # Set module vars
    module.SERVER_URL = server_url
    module.ADMIN_USER = admin_user
    module.ADMIN_PASS = admin_pass
    module.TEST_USER = str(uuid.uuid1()).replace('-', '')
    module.TEST_PASS = '******'
    module.TEST_FIRST_NAME = 'Test'
    module.TEST_LAST_NAME = 'User'
    module.TEST_EMAIL = module.TEST_USER + '@osafoundation.org'
    module.PRINCIPAL_ROOT = PRINCIPAL_ROOT
    module.PRINCIPAL_DAV_PATH = '%s/%s' % (PRINCIPAL_ROOT, module.TEST_USER)
    module.PRINCIPAL_MS_PATH = PRINCIPAL_ROOT.replace('/dav', '/mc/collection')
    module.FILES_DIR = FILES_DIR

    #Setup client and users
    path = PATH
    cosmoclient.CosmoClient._cosmo_path = path
    cosmoclient.CosmoClient._cmp_path = path + 'cmp'

    client = cosmoclient.CosmoClient(module.SERVER_URL)
    client.set_basic_auth(module.ADMIN_USER, module.ADMIN_PASS)
    module.client = client
    client.add_user(module.TEST_USER, module.TEST_PASS, module.TEST_FIRST_NAME,
                    module.TEST_LAST_NAME, module.TEST_EMAIL)
    client.set_basic_auth(module.TEST_USER, module.TEST_PASS)

    if hasattr(module, 'CALENDAR'):
        client._request('MKCALENDAR',
                        '%s/%s' % (module.PRINCIPAL_DAV_PATH, module.CALENDAR))
        assert client.response.status == 201
        for i in range(1, 8):
            ics_name = str(i) + '.ics'
            body = open(module.FILES_DIR + '/reports/put/' + ics_name).read()
            client.put('%s/%s/%s' %
                       (module.PRINCIPAL_DAV_PATH, module.CALENDAR, ics_name),
                       body=body,
                       headers={'content-type': 'text/calendar'})
            assert client.response.status == 201
Exemplo n.º 3
0
#!/usr/bin/env python
import cosmoclient
import sys, os, pdb

if __name__ == "__main__":
    url = sys.argv[1]
    client = cosmoclient.CosmoClient(url)
    client.set_basic_auth('root', 'cosmo')

    for i in [str(x) for x in range(4) if x is not 0]:
        client.add_user('appleuser' + i, 'appletest', 'Apple', 'User',
                        '*****@*****.**' % i)
        if client.response.status != 201:
            if client.response.status == 204:
                print 'User appleuser%s already exists' % i
            else:
                print 'An error occured creating account'
        else:
            print 'Created user appleuser%s' % i
Exemplo n.º 4
0
def setup_module(module):
    cosmo_test_lib.setup_module(module)
    client = cosmoclient.CosmoClient(module.SERVER_URL)
    client.set_basic_auth(module.ADMIN_USER, module.ADMIN_PASS)
    module.client = client
Exemplo n.º 5
0
 def setup(self):
     self.client = cosmoclient.CosmoClient(
         self.connection_info['server_url'])
     self.client.set_basic_auth(self.connection_info['admin_username'],
                                self.connection_info['admin_password'])
Exemplo n.º 6
0
 def setup(self):
     self.client = cosmoclient.CosmoClient(
         self.connection_info['server_url'])
     self.client.set_basic_auth('hub-test',
                                self.connection_info['hub_pass'])