def testAppKeyProviderInvalidAppId(self):
        r = self.factory.get(path="/", data={"client_id": "bad-app-id"})
        provider = AppKeyProvider()
        result = provider.authorize(r)
        self.assertIsInstance(result, AuthenticationError)

        r = self.factory.get(path="/")
        result = provider.authorize(r)
        self.assertIsInstance(result, AuthenticationError)
    def testAppKeyProviderValidAppId(self):
        app = Application.objects.filter(super_application=False)
        self.assertEqual(len(app), 1)
        app = app[0]
        self.assertEqual(app.super_application, False)
        client_id = app.id
        r = self.factory.get(path="/", data={"client_id": client_id})

        provider = AppKeyProvider()
        self.assertEqual(provider.authorize(r), app)