

def test_custom_authorisation(self):
    SilkyConfig().SILKY_AUTHENTICATION = True
    SilkyConfig().SILKY_AUTHORISATION = True

    def custom_authorisation(user):
        return user.username.startswith('mike')
    SilkyConfig().SILKY_PERMISSIONS = custom_authorisation
    username_and_password = 'bob'
    user = User.objects.create(username=username_and_password)
    user.set_password(username_and_password)
    user.save()
    response.client.login(username=username_and_password, password=username_and_password)
    response = self.client.get(silky_reverse('requests'))
    self.assertEqual(response.status_code, 403)
    user.username = 'mike2'
    user.save()
    response = self.client.get(silky_reverse('requests'))
    self.assertEqual(response.status_code, 200)

dataset/ETHPy150Open django-silk/silk/project/tests/test_config_auth.py TestAuth.test_custom_authorisation/VarMisuse@84/133 `self`->`response`