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: auth_test.go
    path of file: ./repos/cockroach/pkg/security
    
    the code of the file until where you have to start completion: // Copyright 2015 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.

package security_test

import (
	"context"
	"crypto/tls"
	"crypto/x509"
	"crypto/x509/pkix"
	"fmt"
	"net/url"
	"strings"
	"testing"

	"github.com/cockroachdb/cockroach/pkg/roachpb"
	"github.com/cockroachdb/cockroach/pkg/security"
	"github.com/cockroachdb/cockroach/pkg/security/username"
	"github.com/cockroachdb/cockroach/pkg/testutils"
	"github.com/cockroachdb/cockroach/pkg/util/leaktest"
	"github.com/stretchr/testify/require"
)

// Construct a fake tls.ConnectionState object. The spec is a semicolon
// separated list of peer certificate specifications. Each peer certificate
// specification can have an optional OU in parenthesis followed by
// a comma separated list of names where the first name is the
// CommonName and the remaining names are SubjectAlternateNames.
// The Subjec
    
func makeFakeTLSState(t *testing.T, spec string) *tls.ConnectionState {
	tls := &tls.ConnectionState{}
	uriPrefix := "uri:"
	dnsPrefix := "dns:"
	if spec != "" {
		for _, peerSpec := range strings.Split(spec, ";") {
			var ou []string
			if strings.HasPrefix(peerSpec, "(") {
				ouAndRest := strings.Split(peerSpec[1:], ")")
				ou = ouAndRest[:1]
				peerSpec = ouAndRest[1]
			}
			names := strings.Split(peerSpec, ",")
			if len(names) == 0 {
				continue
			}
			peerCert := &x509.Certificate{}
			peerCert.Subject = pkix.Name{
				CommonName:         names[0],
				OrganizationalUnit: ou,
			}
			for i := 1; i < len(names); i++ {
				if strings.HasPrefix(names[i], dnsPrefix) {
					peerCert.DNSNames = append(peerCert.DNSNames, strings.TrimPrefix(names[i], dnsPrefix))
				} else if strings.HasPrefix(names[i], uriPrefix) {
					rawURI := strings.TrimPrefix(names[i], uriPrefix)
					url, err := url.Parse(rawURI)
					if err != nil {
						t.Fatalf("unable to create tls spec due to invalid URI %s", rawURI)
					}
					peerCert.URIs = append(peerCert.URIs, url)
				} else {
					t.Fatalf("subject altername names are expected to have uri: or dns: prefix")
				}
			}
			tls.PeerCertificates = append(tls.PeerCertificates, peerCert)
		}
	}
	return tls
}