{"action":"created","issue":{"url":"https://api.github.com/repos/django/channels/issues/1008","repository_url":"https://api.github.com/repos/django/channels","labels_url":"https://api.github.com/repos/django/channels/issues/1008/labels{/name}","comments_url":"https://api.github.com/repos/django/channels/issues/1008/comments","events_url":"https://api.github.com/repos/django/channels/issues/1008/events","html_url":"https://github.com/django/channels/issues/1008","id":312321049,"number":1008,"title":"ChannelsLiveServerTestCase session cookie creation error","user":{"login":"kradem","id":7360633,"avatar_url":"https://avatars1.githubusercontent.com/u/7360633?v=4","gravatar_id":"","url":"https://api.github.com/users/kradem","html_url":"https://github.com/kradem","followers_url":"https://api.github.com/users/kradem/followers","following_url":"https://api.github.com/users/kradem/following{/other_user}","gists_url":"https://api.github.com/users/kradem/gists{/gist_id}","starred_url":"https://api.github.com/users/kradem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kradem/subscriptions","organizations_url":"https://api.github.com/users/kradem/orgs","repos_url":"https://api.github.com/users/kradem/repos","events_url":"https://api.github.com/users/kradem/events{/privacy}","received_events_url":"https://api.github.com/users/kradem/received_events","type":"User","site_admin":false},"labels":[{"id":407159546,"url":"https://api.github.com/repos/django/channels/labels/blocked/user-response","name":"blocked/user-response","color":"f9d0c4","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":11,"created_at":"2018-04-08T16:53:25Z","updated_at":"2018-04-17T22:32:06Z","closed_at":null,"author_association":"NONE","body":"My functional tests use following code snippets to log user in:\r\n\r\n    def create_session_cookie(self, username, password):\r\n        # First, create a new test user\r\n        User = get_user_model()\r\n        user = User.objects.create_user(username=username, password=password)\r\n\r\n        # Then create the authenticated session using the new user credentials\r\n        session = SessionStore()\r\n        session[SESSION_KEY] = user.pk\r\n        session[BACKEND_SESSION_KEY] = settings.AUTHENTICATION_BACKENDS[0]\r\n        session[HASH_SESSION_KEY] = user.get_session_auth_hash()\r\n        session.save()\r\n\r\n        # Finally, create the cookie dictionary\r\n        cookie = {\r\n            'name': settings.SESSION_COOKIE_NAME,\r\n            'value': session.session_key,\r\n            'secure': False,\r\n            'path': '/',\r\n        }\r\n        return cookie\r\n\r\n    def create_cookie_and_go_to_page(self, email):\r\n        session_cookie = self.create_session_cookie(\r\n            username=email, password='top_secret'\r\n        )\r\n\r\n        # visit some url in your domain to setup Selenium.\r\n        # (404 pages load the quickest)\r\n        self.browser.get(self.server_url + '/404.html')\r\n        # add the newly created session cookie to selenium webdriver.\r\n        self.browser.add_cookie(session_cookie)\r\n        # refresh to exchange cookies with the server.\r\n        self.browser.refresh()\r\n        # This time user should present as logged in.\r\n        self.browser.get(self.server_url)\r\n\r\nand I use it as:\r\n\r\n    class DjangoTest(StaticLiveServerTestCase):\r\n\r\n        def test_django(self):\r\n            self.create_cookie_and_go_to_page('email@example.com')\r\n\r\nAlso I used to test my channels pages (installed with `pip install git+git://github.com/django/channels.git@master#egg=channels`) like this:\r\n\r\n    class ChannelsTest(ChannelsLiveServerTestCase):\r\n\r\n        def test_channels(self):\r\n            self.create_cookie_and_go_to_page('email@example.com')\r\n\r\n, but with `ChannelsLiveServerTestCase` something has gone wrong in recent commits to master. It simply shows **Bad Request (400)** page after `self.browser.get(self.server_url + '/404.html')` call. If I revert to channels==2.0.2 from PyPI then it goes well, but css and js are broken with that version. I tried to locate error on a specific commit or dependency version, but without success."},"comment":{"url":"https://api.github.com/repos/django/channels/issues/comments/382177051","html_url":"https://github.com/django/channels/issues/1008#issuecomment-382177051","issue_url":"https://api.github.com/repos/django/channels/issues/1008","id":382177051,"user":{"login":"andrewgodwin","id":36182,"avatar_url":"https://avatars1.githubusercontent.com/u/36182?v=4","gravatar_id":"","url":"https://api.github.com/users/andrewgodwin","html_url":"https://github.com/andrewgodwin","followers_url":"https://api.github.com/users/andrewgodwin/followers","following_url":"https://api.github.com/users/andrewgodwin/following{/other_user}","gists_url":"https://api.github.com/users/andrewgodwin/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewgodwin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewgodwin/subscriptions","organizations_url":"https://api.github.com/users/andrewgodwin/orgs","repos_url":"https://api.github.com/users/andrewgodwin/repos","events_url":"https://api.github.com/users/andrewgodwin/events{/privacy}","received_events_url":"https://api.github.com/users/andrewgodwin/received_events","type":"User","site_admin":false},"created_at":"2018-04-17T22:32:06Z","updated_at":"2018-04-17T22:32:06Z","author_association":"OWNER","body":"Not really surprising then, as that changed the entire way the forking worked. I can't reproduce the problem locally though, so until I can do that there's not going to be a fix..."}}
{"actor":{"display_login":"andrewgodwin"}}