lab132 / buildbot-gitea

Buildbot plugin for integration with gitea.
MIT License
62 stars 21 forks source link

WIP: Add GiteaAuth class and documentation #5

Closed tcrowe closed 4 years ago

tcrowe commented 4 years ago

What does it do?

It adds a class to the project that allows users to authenticate over OAuth2.

How to test

I'm unsure the proper way to test with python but this is how I've configured it.

./master.cfg

from buildbot_gitea.auth import GiteaAuth
c['www']['auth'] = GiteaAuth(
    endpoint="https://your-gitea-host",
    client_id 'oauth2-client-id',
    client_secret='oauth2-client-secret')

Demo screens

At buildbot home page

Screen Shot 2019-12-17 at 3 39 33 PM

When logging in the title comes from this class. With faIcon property I don't see it but I copied the other classes, like GitHub, or GitLab, which reference an faIcon = '?'. It's from FontAwesome icons.

Screen Shot 2019-12-17 at 3 40 00 PM

Login at your Gitea

Screen Shot 2019-12-17 at 3 40 49 PM

Authorize buildbot. The title and naming comes from how the user configures it.

Screen Shot 2019-12-17 at 3 43 34 PM

The user is logged in

Screen Shot 2019-12-17 at 3 44 17 PM
tcrowe commented 4 years ago

https://github.com/lab132/buildbot-gitea/issues/4

I'm unsure how to incorporate it into setup.py or if it needs to be. Any changes you need I'll be happy to make. You will not hurt my feelings in any way if you say I am wrong or need a change.

tcrowe commented 4 years ago

I forgot to add the tests. I will have to study how that works before I can add it.

pampersrocker commented 4 years ago

The tests for oauth can be quite tricky, see https://github.com/buildbot/buildbot/blob/master/master/buildbot/test/unit/test_www_oauth.py for example. I would not set-up an end 2 end (E2E) unit test for this, but you may derive a unittest for Gitea from the OAuth2Auth class in there.

The current CI fail is not because of your code, but buildbot changed something regarding the regular git step so don't worry about it.

tcrowe commented 4 years ago

RE: Tests - I'm following that file

RE: Avatar - I'm looking at the classes for that, like Gravatar.

RE: Roles, teams, groups - I'm seeing how this interacts with Authz class

tcrowe commented 4 years ago

I tried the above talked about things for a while but my knowledge is lacking. My time is short as well but I also don't want your team to have to pick up the slack because I don't have the python skill yet. Should we close it out and maybe me or someone can pick up the thread later?

pampersrocker commented 4 years ago

I tried the above talked about things for a while but my knowledge is lacking. My time is short as well but I also don't want your team to have to pick up the slack because I don't have the python skill yet. Should we close it out and maybe me or someone can pick up the thread later?

You effort is greatly appreciated, thank you! I will see if I can continue this implementation. The unit tests from buildbot are not easy to understand, I have struggled myself multiple days to get them working. Please don't feel sorry for implicitly putting a task upon us, we want to develop this plugin further as well!

Thanks again for your contribution! I will probably incorporate this PR into a branch and close it in the next few days.

tcrowe commented 4 years ago

Thank you as well

pampersrocker commented 4 years ago

@tcrowe I've finished the implementation now and added minimal unittests. Feel free to take a look at the changes.