lundi 21 décembre 2015

Django rest testing with oauth2 authentication

I have problem creating new instance of oauth2.Application object for testing purpose. I need application object for creating acces token so then I could perform requests testing. The code for creating application object is:

self.application = Application.objects.create(
                   name="Test Application",
                   redirect_uris="http://localhost",
                   user=self.test_user,
                   client_type=Application.CLIENT_CONFIDENTIAL,
                   authorization_grant_type=Application.GRANT_AUTHORIZATION_CODE,
               )

The error which I get is: Warning: Field 'skip_authorization' doesn't have a default value If I add skip_authorization=False in constructor the error is next:

TypeError: 'skip_authorization' is an invalid keyword argument for this function

The same thing happen if I want to inflate data into database from fixture .json file. What is solution for this, and is any other way for testing application?

I also try to generate fixture .json file from command line from existing database which has different values in Application table at skip_authentication column, but this field did not appear nowhere in .json file.

Aucun commentaire:

Enregistrer un commentaire