Exemplo n.º 1
0
func TestConvertPathForQueue(t *testing.T) {
	services := tc.NewServices()

	for _, test := range urlConversions {
		expected, _ := url.Parse(test.expected)
		given, _ := url.Parse(test.given)

		realEndpoint, err := services.ConvertPath(given)

		if err != nil {
			t.Errorf("Conversion must be a success")
		}

		if expected.String() != realEndpoint.String() {
			t.Errorf("Failed conversion %s expected to be %s", expected, realEndpoint)
		}
	}
}
Exemplo n.º 2
0
	"github.com/taskcluster/taskcluster-client-go/tcclient"
	tc "github.com/taskcluster/taskcluster-proxy/taskcluster"
)

type Routes struct {
	tcclient.ConnectionData
	lock sync.RWMutex
}

type CredentialsUpdate struct {
	ClientId    string `json:"clientId"`
	AccessToken string `json:"accessToken"`
	Certificate string `json:"certificate"`
}

var tcServices = tc.NewServices()
var httpClient = &http.Client{}

func (self *Routes) signUrl(res http.ResponseWriter, req *http.Request) {
	// Using ReadAll could be sketchy here since we are reading unbounded data
	// into memory...
	body, err := ioutil.ReadAll(req.Body)

	if err != nil {
		res.WriteHeader(500)
		fmt.Fprintf(res, "Error reading body")
		return
	}

	urlString := strings.TrimSpace(string(body))
	cd := tcclient.ConnectionData(self.ConnectionData)