Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
547 changes: 426 additions & 121 deletions tests/unit/accounts/test_views.py

Large diffs are not rendered by default.

388 changes: 270 additions & 118 deletions tests/unit/manage/test_views.py

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions warehouse/accounts/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,7 @@ class NewEmailMixin:
validators=[
wtforms.validators.InputRequired(),
PreventNullBytesValidator(),
wtforms.validators.Regexp(
r".+@.+\..+", message=_("The email address isn't valid. Try again.")
),
wtforms.validators.Email(),
wtforms.validators.Length(
max=254, message=_("The email address is too long. Try again.")
),
Expand Down
49 changes: 46 additions & 3 deletions warehouse/accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,17 @@
)
from warehouse.events.tags import EventTag
from warehouse.metrics.interfaces import IMetricsService
from warehouse.oidc.forms import DeletePublisherForm
from warehouse.oidc.forms.github import PendingGitHubPublisherForm
from warehouse.oidc.forms import (
DeletePublisherForm,
PendingGitHubPublisherForm,
PendingGooglePublisherForm,
)
from warehouse.oidc.interfaces import TooManyOIDCRegistrations
from warehouse.oidc.models import PendingGitHubPublisher, PendingOIDCPublisher
from warehouse.oidc.models import (
PendingGitHubPublisher,
PendingGooglePublisher,
PendingOIDCPublisher,
)
from warehouse.organizations.interfaces import IOrganizationService
from warehouse.organizations.models import OrganizationRole, OrganizationRoleType
from warehouse.packaging.models import (
Expand Down Expand Up @@ -1467,6 +1474,10 @@ def __init__(self, request):
api_token=self.request.registry.settings.get("github.token"),
project_factory=self.project_factory,
)
self.pending_google_publisher_form = PendingGooglePublisherForm(
self.request.POST,
project_factory=self.project_factory,
)

@property
def _ratelimiters(self):
Expand Down Expand Up @@ -1502,6 +1513,15 @@ def _check_ratelimits(self):
def default_response(self):
return {
"pending_github_publisher_form": self.pending_github_publisher_form,
"pending_google_publisher_form": self.pending_google_publisher_form,
"disabled": {
"GitHub": self.request.flags.disallow_oidc(
AdminFlagValue.DISALLOW_GITHUB_OIDC
),
"Google": self.request.flags.disallow_oidc(
AdminFlagValue.DISALLOW_GOOGLE_OIDC
),
},
}

@view_config(request_method="GET")
Expand Down Expand Up @@ -1640,6 +1660,29 @@ def _add_pending_oidc_publisher(

return HTTPSeeOther(self.request.path)

@view_config(
request_method="POST",
request_param=PendingGooglePublisherForm.__params__,
)
def add_pending_google_oidc_publisher(self):
form = self.default_response["pending_google_publisher_form"]
return self._add_pending_oidc_publisher(
publisher_name="Google",
publisher_class=PendingGooglePublisher,
admin_flag=AdminFlagValue.DISALLOW_GOOGLE_OIDC,
form=form,
make_pending_publisher=lambda request, form: PendingGooglePublisher(
project_name=form.project_name.data,
added_by=request.user,
email=form.email.data,
sub=form.sub.data,
),
make_existence_filters=lambda form: dict(
email=form.email.data,
sub=form.sub.data,
),
)

@view_config(
request_method="POST",
request_param=PendingGitHubPublisherForm.__params__,
Expand Down
Loading