File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed
gramps_webapi/api/resources Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change 1919
2020"""API resource endpoints."""
2121
22+ from flask import abort
2223from flask .views import MethodView
2324
2425from ..auth import (
3233class Resource (MethodView ):
3334 """Base class for API resources."""
3435
36+ def get (self , * args , ** kwargs ):
37+ """Default GET endpoint."""
38+ abort (405 )
39+
40+ def put (self , * args , ** kwargs ):
41+ """Default PUT endpoint."""
42+ abort (405 )
43+
44+ def post (self , * args , ** kwargs ):
45+ """Default POST endpoint."""
46+ abort (405 )
47+
48+ def delete (self , * args , ** kwargs ):
49+ """Default DELETE endpoint."""
50+ abort (405 )
51+
52+ def patch (self , * args , ** kwargs ):
53+ """Default PATCH endpoint."""
54+ abort (405 )
55+
3556
3657class ProtectedResource (Resource ):
3758 """Resource requiring JWT authentication."""
Original file line number Diff line number Diff line change @@ -112,8 +112,16 @@ def tearDown(self):
112112 self .dbman .remove_database (self .name )
113113
114114 def test_change_password_wrong_method (self ):
115- rv = self .client .get (BASE_URL + "/users/-/password/change" )
116- assert rv .status_code == 404
115+ rv = self .client .post (
116+ BASE_URL + "/token/" , json = {"username" : "user" , "password" : "123" }
117+ )
118+ assert rv .status_code == 200
119+ token = rv .json ["access_token" ]
120+ rv = self .client .get (
121+ BASE_URL + "/users/-/password/change" ,
122+ headers = {"Authorization" : f"Bearer { token } " },
123+ )
124+ assert rv .status_code == 405
117125
118126 def test_change_password_no_token (self ):
119127 rv = self .client .post (
You can’t perform that action at this time.
0 commit comments