Skip to content

#158114970 BUILT new endpoints & applied security using jwt #32

Open
aokilipa wants to merge 3 commits into
developfrom
ch-apply-security-using-jwt-158114970
Open

#158114970 BUILT new endpoints & applied security using jwt #32
aokilipa wants to merge 3 commits into
developfrom
ch-apply-security-using-jwt-158114970

Conversation

@aokilipa
Copy link
Copy Markdown
Owner

@aokilipa aokilipa commented Jun 19, 2018

What does this PR do?

Have API endpoints protected with JWT and add Approve, Disapprove and Resolve request endpoint

Description of Task to be completed?

Have the following endpoints protected and working:

  • GET /api/v1/request
  • PUT /api/v1/requests/<requestId>/approve
  • PUT /api/v1/requests/<requestId>/disapprove
  • PUT /api/v1/requests/<requestId>/resolve

How should this be manually tested?

  1. Clone the repo: git clone https://github.com/antokish/Maintenance-Tracker.git
  2. cd into the cloned folder: cd Maintenance-Tracker/
  3. run: $ python run.py
  4. Enter url in postman. example: http://127.0.0.1:5000/api/v1/request

What are the relevant pivotal tracker stories?

#158114970

Screenshots

Get all request

screenshot from 2018-06-20 02-31-55

Expired Token

screenshot from 2018-06-20 02-30-21

Approve request

screenshot from 2018-06-20 02-29-44

Comment thread resources/requests.py
current_user = get_jwt_identity()
user_id = find_by_username(current_user)[0]

if user_id == response['requestor']:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have a response for a non-existent request instead of just returning an empty list.

Comment thread resources/requests.py
"""Modify a request"""
@jwt_required
def put(self, req_id):
"""Modify a request"""
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you aren't checking whether the user is authorised to edit the request

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you also need to check whether the request is already approved by the admin, then it shouldn't be editable.

Comment thread resources/requests.py
if check_admin is True:
try:

RM.request_action(self, status,last_modified,request_id)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check to see that admin cannot resolve a disapproved request

Comment thread run.py
from flask_jwt_extended import JWTManager

config_name = os.getenv('APP_SETTINGS')
config_name = 'testing'#os.getenv('APP_SETTINGS')
Copy link
Copy Markdown

@daisymacharia daisymacharia Jun 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are you defining the config_name variable as testing

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was temporary I forgot to undo..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants