File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change 1-
1+ from syncano . exceptions import SyncanoValueError
22
33from . import fields
44from .base import Model
@@ -117,6 +117,10 @@ class Meta:
117117 'methods' : ['post' ],
118118 'path' : '/users/{id}/reset_key/' ,
119119 },
120+ 'auth' : {
121+ 'methods' : ['post' ],
122+ 'path' : '/user/auth/' ,
123+ },
120124 'list' : {
121125 'methods' : ['get' ],
122126 'path' : '/users/' ,
@@ -133,6 +137,21 @@ def reset_key(self):
133137 connection = self ._get_connection ()
134138 return connection .request ('POST' , endpoint )
135139
140+ def auth (self , username = None , password = None ):
141+ properties = self .get_endpoint_data ()
142+ endpoint = self ._meta .resolve_endpoint ('auth' , properties )
143+ connection = self ._get_connection ()
144+
145+ if not (username and password ):
146+ raise SyncanoValueError ('You need provide username and password.' )
147+
148+ data = {
149+ 'username' : username ,
150+ 'password' : password
151+ }
152+
153+ return connection .request ('POST' , endpoint , data = data )
154+
136155 def _user_groups_method (self , group_id = None , method = 'GET' ):
137156 properties = self .get_endpoint_data ()
138157 endpoint = self ._meta .resolve_endpoint ('groups' , properties )
Original file line number Diff line number Diff line change @@ -67,3 +67,8 @@ def test_user_alt_login(self):
6767 user_key = self .USER_KEY ,
6868 instance_name = self .INSTANCE_NAME )
6969 self .check_connection (con )
70+
71+ def test_user_auth (self ):
72+ self .assertTrue (
73+ self .connection .User ().auth (username = self .USER_NAME , password = self .USER_PASSWORD )
74+ )
You can’t perform that action at this time.
0 commit comments