Skip to content

Commit

Permalink
Store gh_ts in actor cookie, refs #67
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Jan 23, 2021
1 parent 31405aa commit 05677cb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
4 changes: 2 additions & 2 deletions datasette_auth_github/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ async def load_orgs_and_teams(config, profile, access_token):
extras["gh_teams"] = gh_teams
store_timestamp = True

# if store_timestamp:
# extras["gh_ts"] = int(time.time())
if store_timestamp:
extras["gh_ts"] = int(time.time())

return extras

Expand Down
21 changes: 10 additions & 11 deletions tests/test_datasette_auth_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import re



@pytest.fixture
def non_mocked_hosts():
return ["localhost"]
Expand Down Expand Up @@ -144,17 +143,17 @@ async def test_github_auth_callback(ds, mocked_github_api):
"http://localhost/-/github-auth-callback?code=github-code-here",
allow_redirects=False,
)
actor = ds.unsign(response.cookies["ds_actor"], "actor")["a"]
assert {
"a": {
"display": "demouser",
"gh_id": "123",
"gh_name": "GitHub User",
"gh_login": "demouser",
"gh_email": "[email protected]",
"gh_orgs": ["demouser-org"],
"gh_teams": ["demouser-org/thetopteam"],
}
} == ds.unsign(response.cookies["ds_actor"], "actor")
"display": "demouser",
"gh_id": "123",
"gh_name": "GitHub User",
"gh_login": "demouser",
"gh_email": "[email protected]",
"gh_orgs": ["demouser-org"],
"gh_teams": ["demouser-org/thetopteam"],
}.items() <= actor.items()
assert isinstance(actor["gh_ts"], int)
assert "/" == response.headers["location"]


Expand Down

0 comments on commit 05677cb

Please sign in to comment.