added stubs for authentication and CRUD tests

email
androiddrew 7 years ago
parent 64b60d2ad1
commit 3cd05013ab

@ -1,4 +1,4 @@
; config.ini
# config.ini
[user]
BCRYPT_LOG_ROUNDS : 13

@ -1,5 +1,4 @@
import datetime as dt
import json
from apistar import Component, Settings, http, Route, Include
from apistar.backends.sqlalchemy_backend import Session
from apistar_jwt.authentication import get_jwt

@ -9,9 +9,9 @@ from sqlalchemy.ext.compiler import compiles
from sqlalchemy.types import DateTime as DateTimeType
cfg = ConfigParser()
cfg.read('/Users/Drewbednar/PycharmProjects/apistar_tut/config.ini')
cfg.read('config.ini')
BCRYPT_LOG_ROUNDS = cfg.get('user', 'BCRYPT_LOG_ROUNDS')
BCRYPT_LOG_ROUNDS = int(cfg.get('user', 'BCRYPT_LOG_ROUNDS'))
# can be moved to models util?
@ -62,7 +62,7 @@ class User(DBMixin, Base):
def __init__(self, email, password, admin=False):
self.email = email
self.password = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt(11)).decode()
self.password = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt(BCRYPT_LOG_ROUNDS)).decode()
self.admin = admin
def check_password(self, password):

@ -1,21 +0,0 @@
from app import welcome
from apistar.test import TestClient
def test_welcome():
"""
Testing a view directly.
"""
data = welcome()
assert data == {'message': 'Welcome to API Star!'}
def test_http_request():
"""
Testing a view, using the test client.
"""
client = TestClient()
response = client.get('http://localhost/')
assert response.status_code == 200
assert response.json() == {'message': 'Welcome to API Star!'}

@ -0,0 +1,80 @@
# JWT Token
def test_encode_auth_token():
"""Test JWT token encoding"""
pass
def test_decode_auth_token():
"""Test JWT token decode"""
pass
# Register
def test_registration():
""" Test for user registration """
pass
def test_registered_with_already_registered_user():
""" Test registration with already registered email"""
pass
def test_registered_user_login():
""" Test for login of registered-user login """
pass
def test_non_registered_user_login():
""" Test for login of non-registered user """
pass
# Test Login
def test_registered_user_login(self):
""" Test for login of registered-user login """
pass
def test_non_registered_user_login():
""" Test for login of non-registered user """
pass
# Test Logout
def test_valid_logout():
""" Test for logout before token expires """
pass
def test_invalid_logout():
""" Testing logout after the token expires """
pass
# User status
def test_user_status():
""" Test for user status """
"""In order to get the user details of the currently logged in user, the auth token must be sent with the request within the header."""
def test_user_status_malformed_bearer_token():
""" Test for user status with malformed bearer token"""
pass
# Blacklist
def test_valid_blacklisted_token_logout():
""" Test for logout after a valid token gets blacklisted """
pass
def test_valid_blacklisted_token_user(self):
""" Test for user status with a blacklisted valid token """

@ -0,0 +1,29 @@
# CRUD Cookies
def test_get_cookies():
pass
def test_get_cookie():
pass
def test_valid_create_cookie():
pass
def test_invalid_create_cookie():
pass
def test_valid_update_cookie():
pass
def test_invalid_update_cookie():
pass
def test_delete_cookie():
pass
Loading…
Cancel
Save