def test_getAccount_cas_compte_inexistant(mocker): with pytest.raises(ServiceException): response = initBadResponse() con = create_connexion() with mocker.patch('requests.post', return_value=response): with mocker.patch.object(con, 'token', return_value="test"): AccountService.getAccount("*****@*****.**")
def test_modifyAliases_cas_depart1AliasPassageA2Alias(test_config): AccountService.modifyAccountAliases( test_config['accountname'], [test_config['accountalias'], test_config['autre_accountalias']]) account = AccountService.getAccount(test_config['accountname']) assert (test_config['accountalias'] in account.zimbraMailAlias) and (test_config['autre_accountalias'] in account.zimbraMailAlias)
def test_modifyAccount_cas_Normal(test_config): account_as_dict = { 'displayName': "Test2", 'telephoneNumber': "0223232323", 'carLicense': "test@DOMAIN", 'givenName': "prénom", 'sn': "nom accentué", } account = AccountService.getAccount(test_config['accountname']) for attribute in account_as_dict: setattr(account, "_" + attribute, account_as_dict[attribute]) AccountService.modifyAccount(account) account = AccountService.getAccount(test_config['accountname']) errors = 0 for attribute in account_as_dict: if getattr(account, "_" + attribute) != account_as_dict[attribute]: errors = errors + 1 assert errors == 0
def test_getAccount_cas_compte_existant(mocker): response = initGoodResponse() con = create_connexion() with mocker.patch('requests.post', return_value=response): with mocker.patch.object(con, 'token', return_value="test"): account = AccountService.getAccount("*****@*****.**") assert account.name == "*****@*****.**" print(account.carLicense) assert account.carLicense == "EPPN" assert account.zimbraCOSId == "testCOSId"
def create_account(name): account = AccountService.getAccount(name) if account == None: AccountService.createAccount(name, "{ssha}BIDON")
except Exception as err: print("Echec de connexion : %s" % err) sys.exit(2) if args['getAllAccounts'] == True: action_args = { 'domain': args['domain'], 'limit': args['limit'], 'offset': args['offset'], 'attrs': args['attrs'], } if args['ldapQuery']: action_args['ldapQuery'] = args['ldapQuery'] try: all_accounts = AccountService.getAllAccounts(**action_args) except Exception as err: raise err print("%d comptes retournés :" % len(all_accounts)) for account in all_accounts: print("Compte %s :" % account.name) print(account.showAttr()) elif args['getAccount'] == True: if not args['email']: raise Exception("Missing 'email' argument") try: account = AccountService.getAccount(args['email'])
def test_modifyAliases_cas_departVideAjout1Alias(test_config): AccountService.modifyAccountAliases(test_config['accountname'], [test_config['accountalias']]) account = AccountService.getAccount(test_config['accountname']) assert account.zimbraMailAlias == test_config['accountalias']
def test_modifyAccount_cas_resetZimlet(test_config): account = AccountService.getAccount(test_config['accountname']) account.resetZimbraZimletAvailableZimlets() AccountService.modifyAccount(account) account = AccountService.getAccount(test_config['accountname']) assert "com_zimbra_emaildownloader" not in account.zimbraZimletAvailableZimlets
def test_getAccount_cas_normal(test_config): account = AccountService.getAccount(test_config['accountname']) assert account.name == test_config['accountname']
def test_getAccount_cas_compte_inexistant(test_config): account = AccountService.getAccount("inexistant" + '@' + test_config['bss_domain']) assert account == None
def test_createAccount_cas_compteExistant(test_config): with pytest.raises(ServiceException): AccountService.createAccount(test_config['accountname'], "{ssha}BIDON")
def test_createAccount_cas_normal(test_config): AccountService.createAccount(test_config['accountname'], "{ssha}BIDON") account = AccountService.getAccount(test_config['accountname']) assert account.name == test_config['accountname']
def test_deleteAccount_cas_compteInexistant(test_config): with pytest.raises(ServiceException): AccountService.deleteAccount(test_config['accountname'])
def delete_account(name): account = AccountService.getAccount(name) if account != None: AccountService.deleteAccount(name)
def test_deleteAccount_cas_Normal(test_config): AccountService.deleteAccount(test_config['accountname']) account = AccountService.getAccount(test_config['accountname']) assert account == None