Skip to content

Commit

Permalink
finished testing
Browse files Browse the repository at this point in the history
  • Loading branch information
hburke123 committed Oct 24, 2019
1 parent 36f78c8 commit 0318920
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 5 deletions.
28 changes: 23 additions & 5 deletions common/walkoff_client/.travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,32 @@
# ref: https://docs.travis-ci.com/user/languages/python
sudo: required

language: python
python:
- "2.7"
- "3.2"
- "3.3"
- "3.4"
- "3.5"
- "3.7"
#- "3.5-dev" # 3.5 development branch
#- "nightly" # points to the latest development branch e.g. 3.6-dev

services:
- docker

before_install:
- sudo apt-get update
- sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce
- docker version
- sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-compose

# command to install dependencies
install: "pip install -r requirements.txt"

before_script:
- docker swarm init
- ./walkoff.sh up -bdy

# command to run tests
script: nosetests

after_script:
- docker stack services ci
- docker stack ps ci
- ./walkoff.sh down -cy
30 changes: 30 additions & 0 deletions testing/aa_completed/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,33 @@ def test_invalid_super_admin_logout(api: TestClient):
assert p.status_code == 422


def test_new_user_auth_complete(api: TestClient, auth_header: dict):
with open('testing/util/role.json') as fp:
role_json = json.load(fp)
role_id = role_json["id_"]
api.post("/walkoff/api/roles/", headers=auth_header, data=json.dumps(role_json))

data = {
"username": "new_test",
"password": 123,
"roles": [role_id]
}
api.post("/walkoff/api/users/", headers=auth_header, data=json.dumps(data))

data = {
"username": "new_test",
"password": 123,
}

p = api.post(base_auth_url + "login", data=json.dumps(data))
assert p.status_code == 201
tokens = p.json()
new_headers = {"Authorization": "Bearer " + tokens["access_token"]}
refresh_headers = {"Authorization": "Bearer " + tokens["refresh_token"]}
data = {"refresh_token": tokens["refresh_token"]}

p = api.post(base_auth_url + "refresh", headers=refresh_headers)
assert p.status_code == 200

p = api.post(base_auth_url + "logout", headers=new_headers, data=json.dumps(data))
assert p.status_code == 204
43 changes: 43 additions & 0 deletions testing/aa_completed/test_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,49 @@ def test_invalid_update_super_admin_password_and_username2(api: TestClient, auth
assert p.status_code == 403


def test_create_new_user_with_new_role(api: TestClient, auth_header: dict):
with open('testing/util/role.json') as fp:
role_json = json.load(fp)
role_id = role_json["id_"]

api.post("/walkoff/api/roles/", headers=auth_header, data=json.dumps(role_json))

inputs = [
{
"create": f"""
username: new_test
password: 123
roles: [
{role_id}
]
active: {True}
"""
}
]
assert_crud_resource(api, auth_header, base_users_url, inputs, yaml.full_load)


def test_login_new_user_with_new_role(api: TestClient, auth_header: dict):
with open('testing/util/role.json') as fp:
role_json = json.load(fp)
role_id = role_json["id_"]
api.post("/walkoff/api/roles/", headers=auth_header, data=json.dumps(role_json))

data = {
"username": "new_test",
"password": 123,
"roles": [role_id]
}
api.post(base_users_url, headers=auth_header, data=json.dumps(data))

data = {
"username": "new_test",
"password": 123,
}
p = api.post(base_auth_url + "login", data=json.dumps(data))
assert p.status_code == 201


def test_rud_user_dne(api: TestClient, auth_header: dict):
with open('testing/util/user.json') as fp:
user_json = json.load(fp)
Expand Down

0 comments on commit 0318920

Please sign in to comment.