def test_apikey(self): expected_apikey = resolve_apikey() username = os.environ.get('MONITIS_USER') password = os.environ.get('MONITIS_PASS') returned_apikey = monitis.user.apikey(username=username, password=password) assert_equal(expected_apikey, returned_apikey)
def secretkey(apikey=None): ''' The secret key associated with the given API key ''' if apikey is None: apikey = resolve_apikey() return get(action='secretkey', apikey=apikey)['secretkey']
def auth_token(apikey=None, secretkey=None): ''' Generate an auth token If the apikey and/or secretkey are not specified as parameters, then they will be resolved, if possible. ''' if apikey is None: apikey = resolve_apikey() if secretkey is None: secretkey = resolve_secretkey() return get(action='authToken', apikey=apikey, secretkey=secretkey)['authToken']
def test_secretkey(self): apikey = resolve_apikey() expected_secretkey = resolve_secretkey() returned_secretkey = monitis.user.secretkey() assert_equal(expected_secretkey, returned_secretkey)
def test_resolve_apikey(self): apikey = resolve_apikey() # apikey is a string of exactly 26 uppercase alphanumeric characters matched = match('^[0-9A-Z]{26}$', apikey) assert matched is not None