#NEWLINE# def test_scale_with_unauthorized_user_returns_403( self ) : #NEWLINE# #INDENT# "An unauthorized user should not be able to access an app's resources.\n\n        If an unauthorized user is trying to scale an app he or she does not have access to, it\n        should return a 403.\n        " #NEWLINE# url = '/v1/apps' #NEWLINE# response = self . client . post ( url , HTTP_AUTHORIZATION = 'token {}' . format ( self . token ) ) #NEWLINE# self . assertEqual ( response . status_code , 201 ) #NEWLINE# app_id = response . data [ 'id' ] #NEWLINE# url = '/v1/apps/{app_id}/builds' . format ( ** locals ( ) ) #NEWLINE# body = { #NEWLINE# #INDENT# 'image' : 'autotest/example' , #NEWLINE# 'sha' : ( 'a' * 40 ) , #NEWLINE# 'procfile' : json . dumps ( { #NEWLINE# #INDENT# 'web' : 'node server.js' , #NEWLINE# 'worker' : 'node worker.js' , #NEWLINE# #UNINDENT# } ) , #NEWLINE# #UNINDENT# } #NEWLINE# response = self . client . post ( url , json . dumps ( body ) , content_type = 'application/json' , HTTP_AUTHORIZATION = 'token {}' . format ( self . token ) ) #NEWLINE# unauthorized_user = User . objects . get ( username = 'autotest2' ) #NEWLINE# unauthorized_token = Token . objects . get ( user = unauthorized_user ) . key #NEWLINE# url = '/v1/apps/{app_id}/scale' . format ( ** locals ( ) ) #NEWLINE# body = { #NEWLINE# #INDENT# 'web' : 4 , #NEWLINE# #UNINDENT# } #NEWLINE# response = self . client . post ( url , json . dumps ( unauthorized_token ) , content_type = 'application/json' , HTTP_AUTHORIZATION = 'token {}' . format ( unauthorized_token ) ) #NEWLINE# self . assertEqual ( response . status_code , 403 )