Page MenuHomeSoftware Heritage

tests: Simplify OIDCUser tests
ClosedPublic

Authored by anlambert on Mar 25 2021, 12:06 PM.

Details

Summary

Remove the AppUser test model inheriting from OIDCUser as this is not
how the model should be used (composition should be preferred).

Update tests accordingly.

Diff Detail

Repository
rDAUTH Common authentication libraries
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Build is green

Patch application report for D5331 (id=19113)

Rebasing onto 13a56100ba...

Current branch diff-target is up to date.
Changes applied before test
commit e88e971d835d352d1d58612d4b9e0d0d15dde16a
Author: Antoine Lambert <antoine.lambert@inria.fr>
Date:   Thu Mar 25 12:03:33 2021 +0100

    tests: Simplify OIDCUser tests
    
    Remove the AppUser test model inheriting from OIDCUser as this is not
    how the model should be used (composition should be preferred).
    
    Update tests accordingly.

See https://jenkins.softwareheritage.org/job/DAUTH/job/tests-on-diff/51/ for more details.

ardumont added a subscriber: ardumont.

how the model should be used (composition should be preferred).

/me coughs
right, i forgot to come back here and adapt ¯\_(ツ)_/¯.

Thanks.

But maybe we could demonstrate how to use composition in those tests instead of dropping the model?
As you wish ;)

This revision is now accepted and ready to land.Mar 25 2021, 12:13 PM

how the model should be used (composition should be preferred).

/me coughs
right, i forgot to come back here and adapt ¯\_(ツ)_/¯.

Thanks.

But maybe we could demonstrate how to use composition in those tests instead of dropping the model?
As you wish ;)

In fact, that user model should not be composed with another user model.

The incoming auth backends will create an instance of the OIDCUser model and associate it to
any incoming request that requires authentication.

Proper way to persist data associated to a remote user should be to create a django model
with a column storing the user identifier (see example).

I will rephrase the commit message then.

Build is green

Patch application report for D5331 (id=19119)

Rebasing onto 13a56100ba...

Current branch diff-target is up to date.
Changes applied before test
commit b1e0415698f086670661cce8f94126128c0ecdfd
Author: Antoine Lambert <antoine.lambert@inria.fr>
Date:   Thu Mar 25 12:03:33 2021 +0100

    tests: Simplify OIDCUser tests
    
    Remove the AppUser test model inheriting from OIDCUser.
    
    Storing data related to a remote user should be done with a dedicated
    django model containing a user identifier column.
    
    Update tests accordingly.

See https://jenkins.softwareheritage.org/job/DAUTH/job/tests-on-diff/52/ for more details.

This revision was automatically updated to reflect the committed changes.