46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
/*
|
|
* Copyright 2026 Oleg Borodin <onborodin@gmail.com>
|
|
*
|
|
* This work is published and licensed under a Creative Commons
|
|
* Attribution-NonCommercial-NoDerivatives 4.0 International License.
|
|
*
|
|
* Distribution of this work is permitted, but commercial use and
|
|
* modifications are strictly prohibited.
|
|
*/
|
|
|
|
package repocli
|
|
|
|
import (
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"context"
|
|
"fmt"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func xxxTestClientGetToken(t *testing.T) {
|
|
var token string
|
|
var err error
|
|
{
|
|
cli := NewClient(nil, nil)
|
|
//cli.UseMiddleware(NewBasicAuthMiddleware("xxxxxxx", "xxxxxxxxxx"))
|
|
ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
|
|
token, err = cli.GetToken(ctx, "https://auth.docker.io/token")
|
|
require.NoError(t, err)
|
|
|
|
}
|
|
fmt.Printf("Token: %s\n", token)
|
|
{
|
|
rawrepo := "docker.io/onborodin/toolbox:0.18"
|
|
cli := NewClient(nil, nil)
|
|
//cli.UseMiddleware(NewBearerAuthMiddleware(token))
|
|
ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
|
|
id, loc, err := cli.GetUpload(ctx, rawrepo)
|
|
require.NoError(t, err)
|
|
fmt.Printf("Upload ID: %s\n", id)
|
|
fmt.Printf("Upload Location: %s\n", loc)
|
|
}
|
|
|
|
}
|