Skip to content

Commit dd46850

Browse files
committed
Add Google Publisher tests
1 parent d70c873 commit dd46850

File tree

1 file changed

+50
-1
lines changed

1 file changed

+50
-1
lines changed

tests/unit/manage/test_views.py

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
from warehouse.manage.views import organizations as org_views
4848
from warehouse.metrics.interfaces import IMetricsService
4949
from warehouse.oidc.interfaces import TooManyOIDCRegistrations
50-
from warehouse.oidc.models import GitHubPublisher, OIDCPublisher
50+
from warehouse.oidc.models import GitHubPublisher, GooglePublisher, OIDCPublisher
5151
from warehouse.organizations.interfaces import IOrganizationService
5252
from warehouse.organizations.models import (
5353
OrganizationRoleType,
@@ -5905,6 +5905,21 @@ def test_manage_project_oidc_publishers_admin_disabled(
59055905
normalized_environment=publisher.environment,
59065906
),
59075907
),
5908+
(
5909+
"add_google_oidc_publisher",
5910+
pretend.stub(
5911+
id="fakeid",
5912+
publisher_name="Google",
5913+
publisher_url=lambda x=None: None,
5914+
5915+
sub="some-sub",
5916+
),
5917+
lambda publisher: pretend.stub(
5918+
validate=pretend.call_recorder(lambda: True),
5919+
email=pretend.stub(data=publisher.email),
5920+
sub=pretend.stub(data=publisher.sub),
5921+
),
5922+
),
59085923
],
59095924
)
59105925
def test_add_oidc_publisher_preexisting(
@@ -6014,6 +6029,15 @@ def test_add_oidc_publisher_preexisting(
60146029
),
60156030
pretend.stub(publisher_name="GitHub"),
60166031
),
6032+
(
6033+
"add_google_oidc_publisher",
6034+
pretend.stub(
6035+
validate=pretend.call_recorder(lambda: True),
6036+
email=pretend.stub(data="[email protected]"),
6037+
sub=pretend.stub(data="some-sub"),
6038+
),
6039+
"Google",
6040+
),
60176041
],
60186042
)
60196043
def test_add_oidc_publisher_created(
@@ -6143,6 +6167,20 @@ def test_add_oidc_publisher_created(
61436167
}
61446168
),
61456169
),
6170+
(
6171+
"add_google_oidc_publisher",
6172+
"Google",
6173+
GooglePublisher(
6174+
6175+
sub="some-sub",
6176+
),
6177+
MultiDict(
6178+
{
6179+
"email": "[email protected]",
6180+
"sub": "some-sub",
6181+
}
6182+
),
6183+
),
61466184
],
61476185
)
61486186
def test_add_oidc_publisher_already_registered_with_project(
@@ -6209,6 +6247,7 @@ def test_add_oidc_publisher_already_registered_with_project(
62096247
"view_name, publisher_name",
62106248
[
62116249
("add_github_oidc_publisher", "GitHub"),
6250+
("add_google_oidc_publisher", "Google"),
62126251
],
62136252
)
62146253
def test_add_oidc_publisher_ratelimited(
@@ -6256,6 +6295,7 @@ def test_add_oidc_publisher_ratelimited(
62566295
"view_name, publisher_name",
62576296
[
62586297
("add_github_oidc_publisher", "GitHub"),
6298+
("add_google_oidc_publisher", "Google"),
62596299
],
62606300
)
62616301
def test_add_oidc_publisher_admin_disabled(
@@ -6296,6 +6336,7 @@ def test_add_oidc_publisher_admin_disabled(
62966336
"view_name, publisher_name",
62976337
[
62986338
("add_github_oidc_publisher", "GitHub"),
6339+
("add_google_oidc_publisher", "Google"),
62996340
],
63006341
)
63016342
def test_add_oidc_publisher_invalid_form(
@@ -6357,6 +6398,10 @@ def test_add_oidc_publisher_invalid_form(
63576398
workflow_filename="some-workflow-filename.yml",
63586399
environment="some-environment",
63596400
),
6401+
GooglePublisher(
6402+
6403+
sub="some-sub",
6404+
),
63606405
],
63616406
)
63626407
def test_delete_oidc_publisher_registered_to_multiple_projects(
@@ -6455,6 +6500,10 @@ def test_delete_oidc_publisher_registered_to_multiple_projects(
64556500
workflow_filename="some-workflow-filename.yml",
64566501
environment="some-environment",
64576502
),
6503+
GooglePublisher(
6504+
6505+
sub="some-sub",
6506+
),
64586507
],
64596508
)
64606509
def test_delete_oidc_publisher_entirely(self, monkeypatch, db_request, publisher):

0 commit comments

Comments
 (0)