mirror of
				https://codeberg.org/forgejo/forgejo.git
				synced 2025-10-31 14:31:02 +00:00 
			
		
		
		
	fix(api): deactivate issue api for disabled or external issue-tracker (#8829)
- When the issue unit is disabled for a repository, don't allow issue related APIs. - Added integration tests. - Resolves #8408 Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8829 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Co-authored-by: zokki <zokki.softwareschmiede@gmail.com> Co-committed-by: zokki <zokki.softwareschmiede@gmail.com>
This commit is contained in:
		
					parent
					
						
							
								8f4ebab023
							
						
					
				
			
			
				commit
				
					
						4247c37300
					
				
			
		
					 7 changed files with 252 additions and 75 deletions
				
			
		|  | @ -6,7 +6,6 @@ package integration | |||
| import ( | ||||
| 	"bytes" | ||||
| 	"fmt" | ||||
| 	"io" | ||||
| 	"mime/multipart" | ||||
| 	"net/http" | ||||
| 	"testing" | ||||
|  | @ -110,17 +109,11 @@ func TestAPICreateCommentAttachment(t *testing.T) { | |||
| 	body := &bytes.Buffer{} | ||||
| 
 | ||||
| 	// Setup multi-part | ||||
| 	writer := multipart.NewWriter(body) | ||||
| 	part, err := writer.CreateFormFile("attachment", filename) | ||||
| 	require.NoError(t, err) | ||||
| 	_, err = io.Copy(part, &buff) | ||||
| 	require.NoError(t, err) | ||||
| 	err = writer.Close() | ||||
| 	require.NoError(t, err) | ||||
| 	contentType := tests.WriteImageBody(t, buff, filename, body) | ||||
| 
 | ||||
| 	req := NewRequestWithBody(t, "POST", fmt.Sprintf("/api/v1/repos/%s/%s/issues/comments/%d/assets", repoOwner.Name, repo.Name, comment.ID), body). | ||||
| 		AddTokenAuth(token). | ||||
| 		SetHeader("Content-Type", writer.FormDataContentType()) | ||||
| 		SetHeader("Content-Type", contentType) | ||||
| 	resp := session.MakeRequest(t, req, http.StatusCreated) | ||||
| 
 | ||||
| 	apiAttachment := new(api.Attachment) | ||||
|  | @ -150,16 +143,10 @@ func TestAPICreateCommentAttachmentAutoDate(t *testing.T) { | |||
| 		defer tests.PrintCurrentTest(t)() | ||||
| 
 | ||||
| 		// Setup multi-part | ||||
| 		writer := multipart.NewWriter(body) | ||||
| 		part, err := writer.CreateFormFile("attachment", filename) | ||||
| 		require.NoError(t, err) | ||||
| 		_, err = io.Copy(part, &buff) | ||||
| 		require.NoError(t, err) | ||||
| 		err = writer.Close() | ||||
| 		require.NoError(t, err) | ||||
| 		contentType := tests.WriteImageBody(t, buff, filename, body) | ||||
| 
 | ||||
| 		req := NewRequestWithBody(t, "POST", urlStr, body).AddTokenAuth(token) | ||||
| 		req.Header.Add("Content-Type", writer.FormDataContentType()) | ||||
| 		req.Header.Add("Content-Type", contentType) | ||||
| 		resp := session.MakeRequest(t, req, http.StatusCreated) | ||||
| 		apiAttachment := new(api.Attachment) | ||||
| 		DecodeJSON(t, resp, &apiAttachment) | ||||
|  | @ -181,16 +168,10 @@ func TestAPICreateCommentAttachmentAutoDate(t *testing.T) { | |||
| 		urlStr += fmt.Sprintf("?updated_at=%s", updatedAt.UTC().Format(time.RFC3339)) | ||||
| 
 | ||||
| 		// Setup multi-part | ||||
| 		writer := multipart.NewWriter(body) | ||||
| 		part, err := writer.CreateFormFile("attachment", filename) | ||||
| 		require.NoError(t, err) | ||||
| 		_, err = io.Copy(part, &buff) | ||||
| 		require.NoError(t, err) | ||||
| 		err = writer.Close() | ||||
| 		require.NoError(t, err) | ||||
| 		contentType := tests.WriteImageBody(t, buff, filename, body) | ||||
| 
 | ||||
| 		req := NewRequestWithBody(t, "POST", urlStr, body).AddTokenAuth(token) | ||||
| 		req.Header.Add("Content-Type", writer.FormDataContentType()) | ||||
| 		req.Header.Add("Content-Type", contentType) | ||||
| 		resp := session.MakeRequest(t, req, http.StatusCreated) | ||||
| 		apiAttachment := new(api.Attachment) | ||||
| 		DecodeJSON(t, resp, &apiAttachment) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue