@@ -50,6 +50,7 @@ import (
5050 "github.com/gravitational/teleport/lib"
5151 "github.com/gravitational/teleport/lib/auth"
5252 "github.com/gravitational/teleport/lib/auth/authclient"
53+ "github.com/gravitational/teleport/lib/auth/testauthority"
5354 "github.com/gravitational/teleport/lib/backend"
5455 "github.com/gravitational/teleport/lib/client"
5556 "github.com/gravitational/teleport/lib/client/identityfile"
@@ -547,3 +548,43 @@ func UpsertAuthPrefAndWaitForCache(
547548 assert .Empty (t , cmp .Diff (& pref , & p ))
548549 }, 5 * time .Second , 100 * time .Millisecond )
549550}
551+
552+ // CreateTeleportTestInstance creates a new Teleport instance to be used for Web UI e2e tests.
553+ func CreateTeleportTestInstance (t * testing.T ) (instance * TeleInstance , ctx context.Context ) {
554+ privateKey , publicKey , err := testauthority .New ().GenerateKeyPair ()
555+ require .NoError (t , err )
556+
557+ cfg := InstanceConfig {
558+ ClusterName : "test-cluster" ,
559+ HostID : uuid .New ().String (),
560+ NodeName : Host ,
561+ Logger : utils .NewSlogLoggerForTests (),
562+ Priv : privateKey ,
563+ Pub : publicKey ,
564+ }
565+ cfg .Listeners = SingleProxyPortSetupOn (Host )(t , & cfg .Fds )
566+ rc := NewInstance (t , cfg )
567+
568+ rcConf := servicecfg .MakeDefaultConfig ()
569+ rcConf .DataDir = t .TempDir ()
570+ rcConf .Auth .Enabled = true
571+ rcConf .Auth .Preference .SetSecondFactor ("webauthn" )
572+ rcConf .Auth .Preference .SetWebauthn (& types.Webauthn {RPID : Host })
573+ rcConf .Proxy .Enabled = true
574+ rcConf .SSH .Enabled = false
575+ rcConf .Proxy .DisableWebInterface = false
576+ rcConf .Version = "v3"
577+
578+ ctx , contextCancel := context .WithCancel (context .Background ())
579+
580+ err = rc .CreateEx (t , nil , rcConf )
581+ require .NoError (t , err )
582+ err = rc .Start ()
583+ require .NoError (t , err )
584+ t .Cleanup (func () {
585+ assert .NoError (t , rc .StopAll ())
586+ contextCancel ()
587+ })
588+
589+ return rc , ctx
590+ }
0 commit comments