mirror of
https://github.com/project-zot/zot.git
synced 2025-01-06 22:40:28 -05:00
17d1338af1
This change introduces OpenID authn by using providers such as Github, Gitlab, Google and Dex. User sessions are now used for web clients to identify and persist an authenticated users session, thus not requiring every request to use credentials. Another change is apikey feature, users can create/revoke their api keys and use them to authenticate when using cli clients such as skopeo. eg: login: /auth/login?provider=github /auth/login?provider=gitlab and so on logout: /auth/logout redirectURL: /auth/callback/github /auth/callback/gitlab and so on If network policy doesn't allow inbound connections, this callback wont work! for more info read documentation added in this commit. Signed-off-by: Alex Stan <alexandrustan96@yahoo.ro> Signed-off-by: Petu Eusebiu <peusebiu@cisco.com> Co-authored-by: Alex Stan <alexandrustan96@yahoo.ro>
117 lines
3.4 KiB
Go
117 lines
3.4 KiB
Go
package dynamo
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/aws/aws-sdk-go-v2/aws"
|
|
"github.com/aws/aws-sdk-go-v2/config"
|
|
"github.com/aws/aws-sdk-go-v2/service/dynamodb"
|
|
guuid "github.com/gofrs/uuid"
|
|
"github.com/rs/zerolog"
|
|
. "github.com/smartystreets/goconvey/convey"
|
|
|
|
"zotregistry.io/zot/pkg/log" //nolint:go-staticcheck
|
|
"zotregistry.io/zot/pkg/meta/version"
|
|
)
|
|
|
|
func TestWrapperErrors(t *testing.T) {
|
|
const (
|
|
endpoint = "http://localhost:4566"
|
|
region = "us-east-2"
|
|
)
|
|
|
|
uuid, err := guuid.NewV4()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
repoMetaTablename := "RepoMetadataTable" + uuid.String()
|
|
manifestDataTablename := "ManifestDataTable" + uuid.String()
|
|
indexDataTablename := "IndexDataTable" + uuid.String()
|
|
userDataTablename := "UserDataTable" + uuid.String()
|
|
apiKeyTablename := "ApiKeyTable" + uuid.String()
|
|
|
|
versionTablename := "Version" + uuid.String()
|
|
|
|
Convey("Create table errors", t, func() {
|
|
badEndpoint := endpoint + "1"
|
|
|
|
customResolver := aws.EndpointResolverWithOptionsFunc(
|
|
func(service, region string, options ...interface{}) (aws.Endpoint, error) {
|
|
return aws.Endpoint{
|
|
PartitionID: "aws",
|
|
URL: badEndpoint,
|
|
SigningRegion: region,
|
|
}, nil
|
|
},
|
|
)
|
|
|
|
cfg, err := config.LoadDefaultConfig(context.Background(), config.WithRegion(region),
|
|
config.WithEndpointResolverWithOptions(customResolver))
|
|
So(err, ShouldBeNil)
|
|
|
|
dynamoWrapper := DBWrapper{
|
|
Client: dynamodb.NewFromConfig(cfg),
|
|
RepoMetaTablename: repoMetaTablename,
|
|
ManifestDataTablename: manifestDataTablename,
|
|
IndexDataTablename: indexDataTablename,
|
|
VersionTablename: versionTablename,
|
|
UserDataTablename: userDataTablename,
|
|
APIKeyTablename: apiKeyTablename,
|
|
Patches: version.GetDynamoDBPatches(),
|
|
Log: log.Logger{Logger: zerolog.New(os.Stdout)},
|
|
}
|
|
|
|
// The table creation should fail as the endpoint is not configured correctly
|
|
err = dynamoWrapper.createRepoMetaTable()
|
|
So(err, ShouldNotBeNil)
|
|
|
|
err = dynamoWrapper.createManifestDataTable()
|
|
So(err, ShouldNotBeNil)
|
|
|
|
err = dynamoWrapper.createIndexDataTable()
|
|
So(err, ShouldNotBeNil)
|
|
|
|
err = dynamoWrapper.createVersionTable()
|
|
So(err, ShouldNotBeNil)
|
|
|
|
err = dynamoWrapper.createAPIKeyTable()
|
|
So(err, ShouldNotBeNil)
|
|
})
|
|
|
|
Convey("Delete table errors", t, func() {
|
|
customResolver := aws.EndpointResolverWithOptionsFunc(
|
|
func(service, region string, options ...interface{}) (aws.Endpoint, error) {
|
|
return aws.Endpoint{
|
|
PartitionID: "aws",
|
|
URL: endpoint,
|
|
SigningRegion: region,
|
|
}, nil
|
|
},
|
|
)
|
|
|
|
cfg, err := config.LoadDefaultConfig(context.Background(), config.WithRegion(region),
|
|
config.WithEndpointResolverWithOptions(customResolver))
|
|
So(err, ShouldBeNil)
|
|
|
|
dynamoWrapper := DBWrapper{
|
|
Client: dynamodb.NewFromConfig(cfg),
|
|
RepoMetaTablename: repoMetaTablename,
|
|
ManifestDataTablename: manifestDataTablename,
|
|
VersionTablename: versionTablename,
|
|
IndexDataTablename: indexDataTablename,
|
|
UserDataTablename: userDataTablename,
|
|
Patches: version.GetDynamoDBPatches(),
|
|
Log: log.Logger{Logger: zerolog.New(os.Stdout)},
|
|
}
|
|
|
|
// The tables were not created so delete calls fail, but dynamoWrapper should not error
|
|
err = dynamoWrapper.deleteRepoMetaTable()
|
|
So(err, ShouldBeNil)
|
|
|
|
err = dynamoWrapper.deleteManifestDataTable()
|
|
So(err, ShouldBeNil)
|
|
})
|
|
}
|