Skip to content

Commit 0c49d87

Browse files
committed
Add Google PendingPublisher tests
1 parent a656cf8 commit 0c49d87

File tree

1 file changed

+88
-1
lines changed

1 file changed

+88
-1
lines changed

tests/unit/accounts/test_views.py

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
from warehouse.events.tags import EventTag
5858
from warehouse.metrics.interfaces import IMetricsService
5959
from warehouse.oidc.interfaces import TooManyOIDCRegistrations
60-
from warehouse.oidc.models import PendingGitHubPublisher
60+
from warehouse.oidc.models import PendingGitHubPublisher, PendingGooglePublisher
6161
from warehouse.organizations.models import (
6262
OrganizationInvitation,
6363
OrganizationRole,
@@ -3431,6 +3431,11 @@ def test_manage_publishing_admin_disabled(self, monkeypatch, pyramid_request):
34313431
AdminFlagValue.DISALLOW_GITHUB_OIDC,
34323432
"GitHub",
34333433
),
3434+
(
3435+
"add_pending_google_oidc_publisher",
3436+
AdminFlagValue.DISALLOW_GOOGLE_OIDC,
3437+
"Google",
3438+
),
34343439
],
34353440
)
34363441
def test_add_pending_oidc_publisher_admin_disabled(
@@ -3502,6 +3507,11 @@ def test_add_pending_oidc_publisher_admin_disabled(
35023507
AdminFlagValue.DISALLOW_GITHUB_OIDC,
35033508
"GitHub",
35043509
),
3510+
(
3511+
"add_pending_google_oidc_publisher",
3512+
AdminFlagValue.DISALLOW_GOOGLE_OIDC,
3513+
"Google",
3514+
),
35053515
],
35063516
)
35073517
def test_add_pending_oidc_publisher_user_cannot_register(
@@ -3596,6 +3606,18 @@ def test_add_pending_oidc_publisher_user_cannot_register(
35963606
),
35973607
PendingGitHubPublisher,
35983608
),
3609+
(
3610+
"add_pending_google_oidc_publisher",
3611+
AdminFlagValue.DISALLOW_GOOGLE_OIDC,
3612+
"Google",
3613+
lambda i, user_id: PendingGooglePublisher(
3614+
project_name="some-project-name-" + str(i),
3615+
email="some-email-" + str(i) + "@example.com",
3616+
sub="some-sub",
3617+
added_by_id=user_id,
3618+
),
3619+
PendingGooglePublisher,
3620+
),
35993621
],
36003622
)
36013623
def test_add_pending_github_oidc_publisher_too_many_already(
@@ -3663,6 +3685,10 @@ def test_add_pending_github_oidc_publisher_too_many_already(
36633685
"add_pending_github_oidc_publisher",
36643686
"GitHub",
36653687
),
3688+
(
3689+
"add_pending_google_oidc_publisher",
3690+
"Google",
3691+
),
36663692
],
36673693
)
36683694
def test_add_pending_oidc_publisher_ratelimited(
@@ -3725,6 +3751,10 @@ def test_add_pending_oidc_publisher_ratelimited(
37253751
"add_pending_github_oidc_publisher",
37263752
"GitHub",
37273753
),
3754+
(
3755+
"add_pending_google_oidc_publisher",
3756+
"Google",
3757+
),
37283758
],
37293759
)
37303760
def test_add_pending_oidc_publisher_invalid_form(
@@ -3814,6 +3844,23 @@ def test_add_pending_oidc_publisher_invalid_form(
38143844
}
38153845
),
38163846
),
3847+
(
3848+
"add_pending_google_oidc_publisher",
3849+
"Google",
3850+
lambda user_id: PendingGooglePublisher(
3851+
project_name="some-project-name",
3852+
3853+
sub="some-sub",
3854+
added_by_id=user_id,
3855+
),
3856+
MultiDict(
3857+
{
3858+
"email": "[email protected]",
3859+
"sub": "some-sub",
3860+
"project_name": "some-project-name",
3861+
}
3862+
),
3863+
),
38173864
],
38183865
)
38193866
def test_add_pending_oidc_publisher_already_exists(
@@ -3900,6 +3947,18 @@ def test_add_pending_oidc_publisher_already_exists(
39003947
),
39013948
PendingGitHubPublisher,
39023949
),
3950+
(
3951+
"add_pending_google_oidc_publisher",
3952+
"Google",
3953+
MultiDict(
3954+
{
3955+
"email": "[email protected]",
3956+
"sub": "some-sub",
3957+
"project_name": "some-project-name",
3958+
}
3959+
),
3960+
PendingGooglePublisher,
3961+
),
39033962
],
39043963
)
39053964
def test_add_pending_oidc_publisher(
@@ -4091,6 +4150,15 @@ def test_delete_pending_oidc_publisher_invalid_form(
40914150
),
40924151
PendingGitHubPublisher,
40934152
),
4153+
(
4154+
lambda user_id: PendingGooglePublisher(
4155+
project_name="some-project-name",
4156+
4157+
sub="some-sub",
4158+
added_by_id=user_id,
4159+
),
4160+
PendingGooglePublisher,
4161+
),
40944162
],
40954163
)
40964164
def test_delete_pending_oidc_publisher_not_found(
@@ -4142,6 +4210,15 @@ def test_delete_pending_oidc_publisher_not_found(
41424210
),
41434211
PendingGitHubPublisher,
41444212
),
4213+
(
4214+
lambda user_id: PendingGooglePublisher(
4215+
project_name="some-project-name",
4216+
4217+
sub="some-sub",
4218+
added_by_id=user_id,
4219+
),
4220+
PendingGooglePublisher,
4221+
),
41454222
],
41464223
)
41474224
def test_delete_pending_oidc_publisher_no_access(
@@ -4197,6 +4274,16 @@ def test_delete_pending_oidc_publisher_no_access(
41974274
),
41984275
PendingGitHubPublisher,
41994276
),
4277+
(
4278+
"Google",
4279+
lambda user_id: PendingGooglePublisher(
4280+
project_name="some-project-name",
4281+
4282+
sub="some-sub",
4283+
added_by_id=user_id,
4284+
),
4285+
PendingGooglePublisher,
4286+
),
42004287
],
42014288
)
42024289
def test_delete_pending_oidc_publisher(

0 commit comments

Comments
 (0)