cloudapi: add multi-tenancy test

This commit adds a very in-depth test for multi-tenancy. It queues several
composes and then runs all jobs belonging to them while checking that
they are run by the correct tenant.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
This commit is contained in:
Ondřej Budai 2022-03-03 11:18:33 +01:00 committed by Ondřej Budai
parent ad5a135b56
commit d2d70c1e95
2 changed files with 280 additions and 2 deletions

View file

@ -26,7 +26,7 @@ import (
func newV2Server(t *testing.T, dir string, depsolveChannels []string, enableJWT bool) (*v2.Server, *worker.Server, jobqueue.JobQueue, context.CancelFunc) {
q, err := fsjobqueue.New(dir)
require.NoError(t, err)
workerServer := worker.NewServer(nil, q, worker.Config{BasePath: "/api/worker/v1", JWTEnabled: enableJWT, TenantProviderFields: []string{"rh-org-id"}})
workerServer := worker.NewServer(nil, q, worker.Config{BasePath: "/api/worker/v1", JWTEnabled: enableJWT, TenantProviderFields: []string{"rh-org-id", "account_id"}})
distros, err := distro_mock.NewDefaultRegistry()
require.NoError(t, err)
@ -35,7 +35,7 @@ func newV2Server(t *testing.T, dir string, depsolveChannels []string, enableJWT
config := v2.ServerConfig{
AWSBucket: "image-builder.service",
JWTEnabled: enableJWT,
TenantProviderFields: []string{"rh-org-id"},
TenantProviderFields: []string{"rh-org-id", "account_id"},
}
v2Server := v2.NewServer(workerServer, distros, config)
require.NotNil(t, v2Server)