-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/46 admin sessions #73
Conversation
2d0b8d0
to
8a65aee
Compare
8a65aee
to
14afa0a
Compare
14afa0a
to
bf1f086
Compare
bf1f086
to
5565720
Compare
list_display = ["session_key", "user", "exists"] | ||
|
||
@property | ||
def SessionStore(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I originally set this in the _init_
but that is not called every time I ran a test and the cached version always used the database backend.
Is there a way to fix this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this caused by assigning the setting here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably because the pytest fixtures change the SESSION_ENGINE
after the __init__
is done, I'm not sure if there is way around this tbh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just use override_settings
and it works as usual :/
admin_user2 = admin_user | ||
|
||
|
||
def test_only_session_profile_of_user_shown( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might still be possible to see the detail or delete view for another users session
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that intended behavior? Either way would be nice to have tests that verify this (whether it is intended or not).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is intended on my end that you can only see you're own sessions. IDK if this is the correct message, do we want users to know other sessions exist?
I do not think it is in scope that a super admin user can see all sessions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the current message is fine, because it does not give users extra information about other user's session. Just adding tests to verify that other users cant access/delete other session is enough in my opinion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still needs an assertion that deleting other users sessions is not possible, but might be nicer to move that to a separate test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now done
Still has the issue where it saves the SessionProfile when sending in the request to delete |
admin_user2 = admin_user | ||
|
||
|
||
def test_only_session_profile_of_user_shown( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
list_display = ["session_key", "user", "exists"] | ||
|
||
@property | ||
def SessionStore(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably because the pytest fixtures change the SESSION_ENGINE
after the __init__
is done, I'm not sure if there is way around this tbh
list_display = ["session_key", "user", "exists"] | ||
|
||
@property | ||
def SessionStore(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this caused by assigning the setting here?
admin_user2 = admin_user | ||
|
||
|
||
def test_only_session_profile_of_user_shown( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that intended behavior? Either way would be nice to have tests that verify this (whether it is intended or not).
tests/conftest.py
Outdated
|
||
@pytest.fixture | ||
def cache_session_store(settings): | ||
settings.SESSION_ENGINE = "django.contrib.sessions.backends.cache" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these settings set directly because they are ran outside of a testcase provided by django (e.g django.test.TestCase
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The db session is not really necessary because its set in the settings.
I've removed both fixtures and replaced them with cache override in the cached version
1ac629a
to
25f3e5d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost there, would be nice if a test for deleting other users sessions is not possible
admin_user2 = admin_user | ||
|
||
|
||
def test_only_session_profile_of_user_shown( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still needs an assertion that deleting other users sessions is not possible, but might be nicer to move that to a separate test
25f3e5d
to
b631bbf
Compare
Fixes #46
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaah