<commit_before>package api

import (
	"net/http"

	. "gopkg.in/check.v1"
)

type AuthorizationPutTests struct {
	AuthorizationTests
}

var _ = Suite(&AuthorizationPutTests{getAuthorizationTest()})

func (t *AuthorizationPutTests) SetUpTest(c *C) {
	t.AuthorizationTests.SetUpTest(c)
	t.httpMethod = "PUT"
	t.req = t.requestEmptyBody(c)
}

func (t *AuthorizationPutTests) TestRepositoryNotExists(c *C) {
	resp := t.getResponse(t.req)
	c.Assert(resp.Code, Equals, http.StatusUnauthorized)
}

func (t *AuthorizationPutTests) TestNotSigned(c *C) {
	t.createRepository(c)
	resp := t.getResponse(t.req)
	c.Assert(resp.Code, Equals, http.StatusUnauthorized)
}

func (t *AuthorizationPutTests) setUpWithExist(c *C) {
	t.createRepository(c)
	auth := t.testAuthorization(c)
	t.addAuthorization(c, auth)
}

func (t *AuthorizationPutTests) TestPut(c *C) {
	t.setUpWithExist(c)
	repo := t.getRepository(c)
	reader, err := repo.GetAuthorizationReader(t.authPublicKey)
	reader.Close()
	c.Assert(err, IsNil)
	t.req = t.requestWithReader(c, reader)
	t.signRequest()

	resp := t.getResponse(t.req)
	c.Assert(resp.Code, Equals, http.StatusCreated)
}<commit_msg>api: Fixed error which occured due to the file leak fix try.<commit_after>package api

import (
	"net/http"
	"io"
	"bytes"

	. "gopkg.in/check.v1"
)

type AuthorizationPutTests struct {
	AuthorizationTests
}

var _ = Suite(&AuthorizationPutTests{getAuthorizationTest()})

func (t *AuthorizationPutTests) SetUpTest(c *C) {
	t.AuthorizationTests.SetUpTest(c)
	t.httpMethod = "PUT"
	t.req = t.requestEmptyBody(c)
}

func (t *AuthorizationPutTests) TestRepositoryNotExists(c *C) {
	resp := t.getResponse(t.req)
	c.Assert(resp.Code, Equals, http.StatusUnauthorized)
}

func (t *AuthorizationPutTests) TestNotSigned(c *C) {
	t.createRepository(c)
	resp := t.getResponse(t.req)
	c.Assert(resp.Code, Equals, http.StatusUnauthorized)
}

func (t *AuthorizationPutTests) setUpWithExist(c *C) {
	t.createRepository(c)
	auth := t.testAuthorization(c)
	t.addAuthorization(c, auth)
}

func (t *AuthorizationPutTests) TestPut(c *C) {
	t.setUpWithExist(c)
	repo := t.getRepository(c)
	reader, err := repo.GetAuthorizationReader(t.authPublicKey)
	c.Assert(err, IsNil)
	buff := &bytes.Buffer{}
	_, err = io.Copy(buff, reader)
	c.Assert(err, IsNil)
	reader.Close()
	
	t.req = t.requestWithReader(c, buff)
	t.signRequest()

	resp := t.getResponse(t.req)
	c.Assert(resp.Code, Equals, http.StatusCreated)
}
{'fraction_non_alphanumeric': 0.14268041237113402, 'fraction_numerical': 0.0008247422680412372, 'mean_word_length': 5.43501326259947, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1657699', 'n_tokens_mistral': 924, 'n_tokens_neox': 939, 'n_words': 170}