- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 6.2k
Disable Oauth check if oauth disabled #32368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
4597aeb
              ee7116a
              ff56466
              f1b3305
              72c3025
              25ebfe4
              2d8d8aa
              da0b2cb
              3e74010
              9cb651b
              d4f9654
              5d26567
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -7,8 +7,10 @@ import ( | |
| "bytes" | ||
| "io" | ||
| "net/http" | ||
| "net/url" | ||
| "testing" | ||
|  | ||
| auth_model "code.gitea.io/gitea/models/auth" | ||
| "code.gitea.io/gitea/modules/json" | ||
| "code.gitea.io/gitea/modules/setting" | ||
| oauth2_provider "code.gitea.io/gitea/services/oauth2_provider" | ||
|  | @@ -477,3 +479,24 @@ func TestOAuthIntrospection(t *testing.T) { | |
| resp = MakeRequest(t, req, http.StatusUnauthorized) | ||
| assert.Contains(t, resp.Body.String(), "no valid authorization") | ||
| } | ||
|  | ||
| func TestGitOpWithOAuthDisabled(t *testing.T) { | ||
|          | ||
| defer tests.PrepareTestEnv(t)() | ||
|  | ||
| setting.OAuth2.Enabled = true | ||
| defer func() { | ||
| setting.OAuth2.Enabled = false | ||
| }() | ||
|  | ||
| onGiteaRun(t, func(t *testing.T, u *url.URL) { | ||
| httpContext := NewAPITestContext(t, "user2", "repo1", auth_model.AccessTokenScopeWriteRepository) | ||
|  | ||
| u.Path = httpContext.GitPath() | ||
| dstPath := t.TempDir() | ||
|  | ||
| u.Path = httpContext.GitPath() | ||
| u.User = url.UserPassword("user2", userPassword) | ||
|  | ||
| t.Run("Clone", doGitClone(dstPath, u)) | ||
| }) | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.