-
-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #90 from plone/more-mocks
provide login mock and update action mock
- Loading branch information
Showing
12 changed files
with
165 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
POST /plone/login_ | ||
Accept: application/json | ||
|
||
{"username": "admin", "password": "admin"} | ||
|
||
HTTP 200 OK | ||
content-type: application/json | ||
|
||
{ | ||
"jwt": { | ||
"algorithm": "HS256", | ||
"expires": 1463534055.943888, | ||
"fullname": "Foo bar", | ||
"type": "JWT", | ||
"username": "admin" | ||
}, | ||
"signature": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwiZnVsbG5hbWUiOiJGb28gYmFyIiwiZXhwaXJlcyI6MTQ2MzUzNDA1NS45NDM4ODgsInR5cGUiOiJKV1QiLCJhbGdvcml0aG0iOiJIUzI1NiJ9.3IafcTKFwcaiSqwuWJ9yxt3iotTYYhLCv7P8_K32hD0", | ||
"success": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# -*- coding: utf-8 -*- | ||
from plone.rest import Service | ||
from zope.interface import implements | ||
from zope.publisher.interfaces import IPublishTraverse | ||
import jwt | ||
import time | ||
|
||
|
||
class Login(Service): | ||
|
||
# should be in keyring... | ||
secret = 'foobar' | ||
|
||
implements(IPublishTraverse) | ||
|
||
def render(self): | ||
data = { | ||
'algorithm': 'HS256', | ||
'type': 'JWT', | ||
'username': 'admin', | ||
'fullname': 'Foo bar', | ||
'expires': time.time() + (60 * 60 * 12) # 12 hour length? | ||
} | ||
encoded = jwt.encode(data, self.secret, algorithm='HS256') | ||
return { | ||
'success': True, | ||
'jwt': data, | ||
'signature': encoded | ||
} | ||
|
||
|
||
class Logout(Service): | ||
implements(IPublishTraverse) | ||
|
||
def render(self): | ||
# doing nothing right now | ||
return { | ||
'success': True | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<configure | ||
xmlns="http://namespaces.zope.org/zope" | ||
xmlns:plone="http://namespaces.plone.org/plone"> | ||
|
||
<plone:service | ||
method="POST" | ||
for="zope.interface.Interface" | ||
factory=".Login" | ||
name="login_" | ||
permission="zope2.View" | ||
/> | ||
|
||
<plone:service | ||
method="POST" | ||
for="zope.interface.Interface" | ||
factory=".Logout" | ||
name="logout_" | ||
permission="zope2.View" | ||
/> | ||
|
||
</configure> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters