Adding a new user to Cosmo (can be used by scooby)
import random
from DAVTest import DAVTest
class cosmoAddUser(DAVTest):
def startRun(self):
# ------- Test Create Account ------- #
self.testStart('Setup Accounts')
try:
self.appendUser = self.appendDict['username']
except KeyError:
self.appendUser = ''
cmpheaders = self.headerAdd({'Content-Type' : "text/xml; charset=UTF-8"})
cmpheaders = self.headerAddAuth("root", "cosmo", headers=cmpheaders)
#CMP path
cmppath = self.pathBuilder('/cmp/user/cosmo-TestAccount%s' % self.appendUser)
#Create testing account
bodycreateaccount = '<?xml version="1.0" encoding="utf-8" ?> \
<user xmlns="http://osafoundation.org/cosmo/CMP"> \
<username>cosmoTestAccount%s</username> \
<password>cosmotest</password> \
<firstName>cosmoTest</firstName> \
<lastName>TestAccount</lastName> \
<email>cosmoTestAccount%s@osafoundation.org</email> \
</user>' % (self.appendUser, self.appendUser)
#Create account and check status
self.request('PUT', cmppath, body=bodycreateaccount, headers=cmpheaders)
self.checkStatus(201) # 201 ACCOUNT CREATED