You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: router_middleware_auth_permission_test.go
    path of file: ./repos/cds/engine/api
    
    the code of the file until where you have to start completion: package api

import (
	"context"
	"github.com/ovh/cds/engine/api/organization"
	"reflect"
	"testing"
	"time"

	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"

	"github.com/ovh/cds/engine/api/action"
	"github.com/ovh/cds/engine/api/authentication"
	"github.com/ovh/cds/engine/api/authentication/local"
	"github.com/ovh/cds/engine/api/group"
	"github.com/ovh/cds/engine/api/test/assets"
	"github.com/ovh/cds/engine/api/user"
	"github.com/ovh/cds/engine/api/workermodel"
	"github.com/ovh/cds/engine/api/workflowtemplate"
	"github.com/ovh/cds/sdk"
)

func Test_checkWorkflowPermissions(t *testing.T) {
	api, db, _ := newTestAPI(t)

	wctx := testRunWorkflow(t, api, ap
    
func Test_checkUserPublicPermissions(t *testing.T) {
	api, db, _ := newTestAPI(t)

	authUser, _ := assets.InsertLambdaUser(t, db)
	authUserMaintainer, _ := assets.InsertMaintainerUser(t, db)
	authUserAdmin, _ := assets.InsertAdminUser(t, db)

	cases := []struct {
		Name                     string
		ConsumerAuthentifiedUser *sdk.AuthentifiedUser
		TargetAuthentifiedUser   *sdk.AuthentifiedUser
		Permission               int
		Granted                  bool
	}{
		{
			Name:                     "RW on himself",
			ConsumerAuthentifiedUser: authUser,
			TargetAuthentifiedUser:   authUser,
			Permission:               sdk.PermissionReadWriteExecute,
			Granted:                  true,
		},
		{
			Name:                     "R on other by lambda user",
			ConsumerAuthentifiedUser: authUser,
			TargetAuthentifiedUser:   authUserAdmin,
			Permission:               sdk.PermissionRead,
			Granted:                  true,
		},
		{
			Name:                     "R on other by admin user",
			ConsumerAuthentifiedUser: authUserAdmin,
			TargetAuthentifiedUser:   authUser,
			Permission:               sdk.PermissionRead,
			Granted:                  true,
		},
		{
			Name:                     "R on other by maintainer user",
			ConsumerAuthentifiedUser: authUserMaintainer,
			TargetAuthentifiedUser:   authUser,
			Permission:               sdk.PermissionRead,
			Granted:                  true,
		},
		{
			Name:                     "RW on other by lambda user",
			ConsumerAuthentifiedUser: authUser,
			TargetAuthentifiedUser:   authUserAdmin,
			Permission:               sdk.PermissionReadWriteExecute,
			Granted:                  false,
		},
		{
			Name:                     "RW on other by maintainer user",
			ConsumerAuthentifiedUser: authUserMaintainer,
			TargetAuthentifiedUser:   authUser,
			Permission:               sdk.PermissionReadWriteExecute,
			Granted:                  false,
		},
		{
			Name:                     "RW on other by admin user",
			ConsumerAuthentifiedUser: authUserAdmin,
			TargetAuthentifiedUser:   authUser,
			Permission:               sdk.PermissionReadWriteExecute,
			Granted:                  true,
		},
	}

	for _, c := range cases {
		t.Run(c.Name, func(t *testing.T) {
			ctx := context.WithValue(context.TODO(), contextUserConsumer, &sdk.AuthUserConsumer{
				AuthConsumer: sdk.AuthConsumer{
					ValidityPeriods: sdk.NewAuthConsumerValidityPeriod(time.Now(), 0),
				},
				AuthConsumerUser: sdk.AuthUserConsumerData{
					AuthentifiedUserID: c.ConsumerAuthentifiedUser.ID,
					AuthentifiedUser:   c.ConsumerAuthentifiedUser,
				},
			})
			ctx = context.WithValue(ctx, contextDriverManifest, &sdk.AuthDriverManifest{})
			err := api.checkUserPublicPermissions(ctx, &responseTracker{}, c.TargetAuthentifiedUser.Username, c.Permission, nil)
			if c.Granted {
				assert.NoError(t, err, "should be granted")
			} else {
				assert.Error(t, err, "should not be granted")
			}
		})
	}
}