def test_auth_post(self): call = dict(title='POST', description='Create redirect url', url='/auth', verb='POST', autodoc=f'{document_directory}/auth_post.md') with self.given(**call): then(response.status_code == 302)
def test_version(self): call = dict( title='Application version', description='Get application version', url='/apiv1/version', verb='GET', ) with self.given(**call): then(response.status_code == 200) and_('version' in response.json) and_(response.json['version'] == restfulpy_boilerplate.__version__)
def test_root(self): call = dict( title='GET', description='', url='/', verb='GET', ) with self.given(**call): then(response.status_code == 200) call = dict(title='POST', description='', url='/', verb='POST', form={'url': 'www.varzesh3.com'}) with self.given(**call): then(response.status_code == 200)
def test_root(self): principal = JwtPrincipal(dict( email='*****@*****.**', name='mohammad', family='sheikhian', id=1, sessionId=1, roles=['admin'] )) self.login_token = principal.dump().decode("utf-8") call = dict( title='GET', description='', url='/', verb='GET', autodoc=f'{document_directory}/root_get_with_authorization.md' ) with self.given(**call): then(response.status_code == 200) self.login_token = None call = dict( title='GET', description='', url='/', verb='GET', autodoc=f'{document_directory}/root_get_without_authorization.md' ) with self.given(**call): then(response.status_code == 200) call = dict( title='POST', description='', url='/', verb='POST', form={ 'url': 'www.varzesh3.com' }, autodoc=f'{document_directory}/root_post.md' ) with self.given(**call): then(response.status_code == 200) call = dict( title='POST', description='', url='/', verb='POST', form={} ) with self.given(**call): then(response.status_code == 400)
def test_login(self): call = dict( title='Login', description='Login to system as god', url='/apiv1/members', verb='LOGIN', form={ 'email': '*****@*****.**', 'password': '******', } ) with self.given(**call): then(response.status_code == 200) and_('token' in response.json) principal = JwtPrincipal.load(response.json['token']) and_('sessionId' in principal.payload) when( 'Trying to login with invalid email and_ password', form={ 'email': '*****@*****.**', 'password': '******', } ) then(response.status_code == 400) when( 'Trying to login with invalid password', form={ 'email': '*****@*****.**', 'password': '******', } ) then(response.status_code == 400)
def test_urls(self): call = dict( title='GET', description='Found url using by hash id', url='/urls/zK', verb='GET', autodoc=f'{document_directory}/urls_get.md' ) with self.given(**call): then(response.status_code == 302) call = dict( title='GET', description='Invalid hash id', url='/urls/lP5', verb='GET' ) with self.given(**call): then(response.status_code == 400) call = dict( title='GET', description='Not found url with hash id', url='/urls/lP', verb='GET' ) with self.given(**call): then(response.status_code == 404)
def test_urls(self): call = dict( title='GET', description='', url='/urls/zK', verb='GET', ) with self.given(**call): then(response.status_code == 302) call = dict( title='GET', description='', url='/urls/lP5', verb='GET', ) with self.given(**call): then(response.status_code == 400) call = dict( title='GET', description='', url='/urls/lP', verb='GET', ) with self.given(**call): then(response.status_code == 404)
def test_auth(self): with oauth_mockup_server(OAuthMockupServer): call = dict( title='POST', description='', url='/auth', verb='POST', ) with self.given(**call): then(response.status_code == 302) call = dict(title='GET', description='', url='/auth', verb='GET', query={ 'state': 'sdfsd', 'code': 'sdfs', 'scope': 'asd' }) with self.given(**call): then(response.status_code == 200)
def test_auth_get(self): with oauth_mockup_server(Root()): settings.mockup_server_url = settings.tokenizer['url'] settings.auth_google_uri_token = f'{settings.mockup_server_url}' \ f'/token' settings.oauth_url_google_api = f'{settings.mockup_server_url}' \ f'/profile' call = dict(title='GET', description='Key value error code or state or scope', url='/auth', verb='GET', query={}) with self.given(**call): then(response.status_code == 400) call = dict(title='GET', description='invalid code or state or scope', url='/auth', verb='GET', query={ 'state': 'DAMDzeJImyByVNSdUOVMzy5moo77JZ', 'code': '_ieAH5x0_nAl45U03Iom6Ut2bcMV-oN8pYrnZtGUYKD' 'povHVmjpCbWu4zBdUYrLtb6JMguFf_E2tyxqLo_vo', 'scope': 'https://www.googleapis.com/auth/userinfo.profile' ' https://www.googleapis.com/auth/plus.me ' 'https://www.googleapis.com/auth/userinfo.email' }) with self.given(**call): then(response.status_code == 403) call = dict(title='GET', description='', url='/auth', verb='GET', query={ 'state': 'DAMDzeJImyByVNSdUOVMzy5moo77JZ', 'code': '5/AAA_ieAH5x0_nAl45U03Iom6Ut2bcMV-oN8pYrnZtGU' 'YKDpovHVmjpCbWu4zBdUYrLtb6JMguFf_E2tyxqLo_vo', 'scope': 'https://www.googleapis.com/auth/userinfo.profile' ' https://www.googleapis.com/auth/plus.me ' 'https://www.googleapis.com/auth/userinfo.email' }) with self.given(**call): then(response.status_code == 404) call = dict(title='GET', description='', url='/auth', verb='GET', query={ 'state': 'DAMDzeJImyByVNSdUOVMzy5moo77JZ', 'code': '4/AAA_ieAH5x0_nAl45U03Iom6Ut2bcMV-oN8pYrnZtGU' 'YKDpovHVmjpCbWu4zBdUYrLtb6JMguFf_E2tyxqLo_vo', 'scope': 'https://www.googleapis.com/auth/userinfo.profile' ' https://www.googleapis.com/auth/plus.me ' 'https://www.googleapis.com/auth/userinfo.email' }, autodoc=f'{document_directory}/auth_get.md') with self.given(**call): then(response.status_code == 200)