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_identities_test.go
    path of file: ./repos/ziti/tests
    
    the code of the file until where you have to start completion: //go:build apitests
// +build apitests

/*
	Copyright NetFoundry Inc.

	Licensed under the Apache License, Version 2.0 (the "License");
	you may not use this file except in compliance with the License.
	You may obtain a copy of the License at

	https://www.apache.org/licenses/LICENSE-2.0

	Unless required by applicable law or agreed to in writing, software
	distributed under the License is distributed on an "AS IS" BASIS,
	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	See the License for the specific language governing permissions and
	limitations under the License.
*/

package tests

import (
	"github.com/google/uuid"
	"net/http"
	"net/url"
	"testing"
)

func TestEdgeRouterIdentities(t *testing.T) {
	ctx := NewTestContext(t)
	defer ctx.Teardown()
	ctx.StartServer()
	ctx.RequireAdminManagementApiLogin()

	edgeRouter1 := ctx.AdminManagementSession.requireNewTunnelerEnabledEdgeRouter()

	// identity should have been created
	identities := ctx.AdminManagementSession.listIdentities("filter=" + url.QueryEscape(`type="Router"`))
	ctx.Req.Equal(1, len(identities))

	identity1 := identities[0]
	ctx.Req.Equal(edgeRouter1.name, identity1.name)

	resp := ctx.AdminManagementSession.deleteEntityOfType("identities", identity1.Id)
	ctx.Req.Equal(http.StatusBadRequest, resp.StatusCode())

	identity1.name = edgeRouter1.name
	identity1.roleAttributes = []string{"test", "hello"}
	ctx.AdminManagementSession.requireUpdateEntity(identity1)
	ctx.AdminManagementSession.validateEntityWithLookup(identity1)

	identity1.name = edgeRouter1.name
	identity1.roleAttributes = []string{"foo", "bar"}
	c
    
func TestEdgeRouterIdentitiesNotEnabled(t *testing.T) {
	ctx := NewTestContext(t)
	defer ctx.Teardown()
	ctx.StartServer()
	ctx.RequireAdminManagementApiLogin()

	edgeRouter1 := ctx.AdminManagementSession.requireNewEdgeRouter()

	identities := ctx.AdminManagementSession.listIdentities("filter=" + url.QueryEscape(`type="Router"`))
	ctx.Req.Equal(0, len(identities))

	edgeRouterPolicies := ctx.AdminManagementSession.listEdgeRouterPolicies("")
	ctx.Req.Equal(0, len(edgeRouterPolicies))

	edgeRouter1.isTunnelerEnabled = true
	ctx.AdminManagementSession.requireUpdateEntity(edgeRouter1)

	// identity should have been created
	identities = ctx.AdminManagementSession.listIdentities("filter=" + url.QueryEscape(`type="Router"`))
	ctx.Req.Equal(1, len(identities))

	identity1 := identities[0]
	ctx.Req.Equal(edgeRouter1.name, identity1.name)

	resp := ctx.AdminManagementSession.deleteEntityOfType("identities", identity1.Id)
	ctx.Req.Equal(http.StatusBadRequest, resp.StatusCode())

	identity1.name = edgeRouter1.name
	identity1.roleAttributes = []string{"test", "hello"}
	ctx.AdminManagementSession.requireUpdateEntity(identity1)
	ctx.AdminManagementSession.validateEntityWithLookup(identity1)

	identity1.name = edgeRouter1.name
	identity1.roleAttributes = []string{"foo", "bar"}
	ctx.AdminManagementSession.requirePatchEntity(identity1, "roleAttributes")
	ctx.AdminManagementSession.validateEntityWithLookup(identity1)

	identity1.name = uuid.NewString()
	resp = ctx.AdminManagementSession.patchEntity(identity1, "name")
	ctx.Req.Equal(http.StatusBadRequest, resp.StatusCode()) // should not be allowed to change name

	resp = ctx.AdminManagementSession.updateEntity(identity1)
	ctx.Req.Equal(http.StatusBadRequest, resp.StatusCode()) // should not be allowed to change name

	// edge router policy should have been created
	edgeRouterPolicies = ctx.AdminManagementSession.listEdgeRouterPolicies("")
	ctx.Req.Equal(1, len(edgeRouterPolicies))

	edgeRouterPolicy1 := edgeRouterPolicies[0]
	ctx.Req.Equal("edge-router-"+edgeRouter1.id+"-system", edgeRouterPolicy1.name)
	ctx.Req.Equal(1, len(edgeRouterPolicy1.edgeRouterRoles))
	ctx.Req.Equal("@"+edgeRouter1.id, edgeRouterPolicy1.edgeRouterRoles[0])
	ctx.Req.Equal(1, len(edgeRouterPolicy1.identityRoles))
	ctx.Req.Equal("@"+identity1.Id, edgeRouterPolicy1.identityRoles[0])

	edgeRouter1.isTunnelerEnabled = false
	ctx.AdminManagementSession.requireUpdateEntity(edgeRouter1)

	// setting flag to false should remove associated entities
	ctx.RequireNotFoundError(ctx.AdminManagementSession.query("identities/" + identity1.Id))
	ctx.RequireNotFoundError(ctx.AdminManagementSession.query("edge-router-policies/" + edgeRouterPolicy1.id))
}