Skip to content

Commit

Permalink
chore: remove feature flag for tokenless (#328)
Browse files Browse the repository at this point in the history
Removes the reollout for tokenless uploads.
Prepping tokenless for GA
  • Loading branch information
giovanni-guidini authored Jan 22, 2024
1 parent a9a1f25 commit eec38e0
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 57 deletions.
8 changes: 0 additions & 8 deletions codecov_auth/authentication/repo_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
TokenTypeChoices,
)
from core.models import Repository
from rollouts import TOKENLESS_AUTH_BY_OWNER_SLUG, owner_slug
from services.repo_providers import RepoProviderService
from upload.helpers import get_global_tokens
from upload.views.helpers import get_repository_from_string
Expand Down Expand Up @@ -257,13 +256,6 @@ def authenticate(self, request):
# Tokneless is only for public repos
if repository.private:
raise exceptions.AuthenticationFailed(self.auth_failed_message)
# Adding a Feature to this for internal testing
# before wide release
# TODO: remove Feature after tokenless goes to general access
if not TOKENLESS_AUTH_BY_OWNER_SLUG.check_value(
owner_slug(repository.author), default=False
):
raise exceptions.AuthenticationFailed(self.auth_failed_message)
# Get the provider service to check the tokenless claim
repository_service = RepoProviderService().get_adapter(
repository.author, repository
Expand Down
40 changes: 0 additions & 40 deletions codecov_auth/tests/unit/test_repo_authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from shared.torngit.exceptions import TorngitObjectNotFoundError

from codecov_auth.authentication.repo_auth import (
TOKENLESS_AUTH_BY_OWNER_SLUG,
GlobalTokenAuthentication,
OrgLevelTokenAuthentication,
RepositoryLegacyQueryTokenAuthentication,
Expand Down Expand Up @@ -468,9 +467,6 @@ def test_tokenless_private_repo(self, db):

@patch("codecov_auth.authentication.repo_auth.RepoProviderService")
def test_tokenless_pr_not_found(self, mock_repo_provider, db, mocker):
mocker.patch.object(
TOKENLESS_AUTH_BY_OWNER_SLUG, "check_value", return_value=True
)
repo = RepositoryFactory(private=False)
mock_adapter = MagicMock(
name="mock_provider_adapter",
Expand Down Expand Up @@ -502,9 +498,6 @@ def test_tokenless_pr_from_different_fork(self, mock_repo_provider, db, mocker):
get_pull_request=AsyncMock(name="mock_get_pr", return_value=pr_info),
)
mock_repo_provider.return_value.get_adapter.return_value = mock_adapter
mocker.patch.object(
TOKENLESS_AUTH_BY_OWNER_SLUG, "check_value", return_value=True
)
request = APIRequestFactory().post(
f"/upload/github/{repo.author.username}::::{repo.name}/commits/commit_sha/reports/report_code/uploads",
headers={"X-Tokenless": "user-name/repo-forked", "X-Tokenless-PR": "15"},
Expand All @@ -522,35 +515,6 @@ def test_tokenless_success(self, mock_repo_provider, db, mocker):
"base": {"slug": f"{repo.author.username}/{repo.name}"},
"head": {"slug": f"some-user/{repo.name}"},
}
mocker.patch.object(
TOKENLESS_AUTH_BY_OWNER_SLUG, "check_value", return_value=True
)
mock_adapter = MagicMock(
name="mock_provider_adapter",
get_pull_request=AsyncMock(name="mock_get_pr", return_value=pr_info),
)
mock_repo_provider.return_value.get_adapter.return_value = mock_adapter

request = APIRequestFactory().post(
f"/upload/github/{repo.author.username}::::{repo.name}/commits/commit_sha/reports/report_code/uploads",
headers={"X-Tokenless": f"some-user/{repo.name}", "X-Tokenless-PR": "15"},
)
authentication = TokenlessAuthentication()
res = authentication.authenticate(request)
assert res is not None
repo_as_user, auth_class = res
assert repo_as_user.is_authenticated()
assert isinstance(auth_class, TokenlessAuth)
mock_adapter.get_pull_request.assert_called_with("15")

@patch("codecov_auth.authentication.repo_auth.RepoProviderService")
def test_tokenless_success_no_mocker_flag(self, mock_repo_provider, db):
repo = RepositoryFactory(private=False, author__username="codecov")
random_repo = RepositoryFactory()
pr_info = {
"base": {"slug": f"{repo.author.username}/{repo.name}"},
"head": {"slug": f"some-user/{repo.name}"},
}
mock_adapter = MagicMock(
name="mock_provider_adapter",
get_pull_request=AsyncMock(name="mock_get_pr", return_value=pr_info),
Expand All @@ -567,8 +531,4 @@ def test_tokenless_success_no_mocker_flag(self, mock_repo_provider, db):
repo_as_user, auth_class = res
assert repo_as_user.is_authenticated()
assert isinstance(auth_class, TokenlessAuth)
assert auth_class.get_repositories() == [repo]
assert auth_class.allows_repo(repo)
assert not auth_class.allows_repo(random_repo)
assert auth_class.get_scopes() == ["upload"]
mock_adapter.get_pull_request.assert_called_with("15")
9 changes: 0 additions & 9 deletions rollouts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,3 @@ def owner_slug(owner: Owner) -> str:

# By default, features have one variant:
# { "enabled": FeatureVariant(True, 1.0) }
TOKENLESS_AUTH_BY_OWNER_SLUG = Feature(
"tokenless_auth",
0.0,
overrides={
"github/codecov": "enabled",
"github/thomasrockhu-codecov": "enabled",
"github/giovanni-guidini": "enabled",
},
)

0 comments on commit eec38e0

Please sign in to comment.