Ejemplo n.º 1
0
    def test_view_2_trusted(self):
        request = self.factory.get('/')
        request.user = self.alice
        request.agent = Agent.trusted_agent(self.alice)

        response = decorated_view_2(request)

        self.assertEqual(response.status_code, 200)
Ejemplo n.º 2
0
    def test_cross_user(self):
        AgentSettings.objects.get_or_create(user=self.bob)

        agent = Agent.trusted_agent(self.alice)
        encoded = self.middleware._encode_cookie(agent, self.alice)
        agent = self.middleware._decode_cookie(encoded, self.bob)

        self.assertTrue(not agent.is_trusted)
Ejemplo n.º 3
0
 def test_trust_anonymous(self):
     with self.assertRaises(Exception):
         Agent.trusted_agent(AnonymousUser())