MCPcopy Index your code
hub / github.com/coder/coder / NewWithAPI

Function NewWithAPI

enterprise/coderd/coderdenttest/coderdenttest.go:92–162  ·  view source on GitHub ↗
(t *testing.T, options *Options)

Source from the content-addressed store, hash-verified

90}
91
92func NewWithAPI(t *testing.T, options *Options) (
93 *codersdk.Client, io.Closer, *coderd.API, codersdk.CreateFirstUserResponse,
94) {
95 t.Helper()
96
97 if options == nil {
98 options = &Options{}
99 }
100 if options.Options == nil {
101 options.Options = &coderdtest.Options{}
102 }
103 require.False(t, options.DontAddFirstUser && !options.DontAddLicense, "DontAddFirstUser requires DontAddLicense")
104 setHandler, cancelFunc, serverURL, oop := coderdtest.NewOptions(t, options.Options)
105 coderAPI, err := coderd.New(context.Background(), &coderd.Options{
106 RBAC: true,
107 ConnectionLogging: options.ConnectionLogging,
108 AuditLogging: options.AuditLogging,
109 BrowserOnly: options.BrowserOnly,
110 SCIMAPIKey: options.SCIMAPIKey,
111 DERPServerRelayAddress: serverURL.String(),
112 DERPServerRegionID: int(oop.DeploymentValues.DERP.Server.RegionID.Value()),
113 ReplicaSyncUpdateInterval: options.ReplicaSyncUpdateInterval,
114 ReplicaErrorGracePeriod: options.ReplicaErrorGracePeriod,
115 Options: oop,
116 EntitlementsUpdateInterval: options.EntitlementsUpdateInterval,
117 LicenseKeys: Keys,
118 ProxyHealthInterval: options.ProxyHealthInterval,
119 DefaultQuietHoursSchedule: oop.DeploymentValues.UserQuietHoursSchedule.DefaultSchedule.Value(),
120 ProvisionerDaemonPSK: options.ProvisionerDaemonPSK,
121 ExternalTokenEncryption: options.ExternalTokenEncryption,
122 })
123 require.NoError(t, err)
124 setHandler(coderAPI.AGPL.RootHandler)
125 var provisionerCloser io.Closer = nopcloser{}
126 if options.IncludeProvisionerDaemon {
127 provisionerCloser = coderdtest.NewProvisionerDaemon(t, coderAPI.AGPL)
128 }
129
130 t.Cleanup(func() {
131 cancelFunc()
132 _ = provisionerCloser.Close()
133 _ = coderAPI.Close()
134 })
135 client := codersdk.New(serverURL)
136 client.HTTPClient = &http.Client{
137 Transport: &http.Transport{
138 TLSClientConfig: &tls.Config{
139 //nolint:gosec
140 InsecureSkipVerify: true,
141 },
142 },
143 }
144 var user codersdk.CreateFirstUserResponse
145 if !options.DontAddFirstUser {
146 user = coderdtest.CreateFirstUser(t, client)
147 if !options.DontAddLicense {
148 lo := LicenseOptions{}
149 if options.LicenseOptions != nil {

Callers 15

TestIntegrationFunction · 0.92
TestWorkspaceAppsFunction · 0.92
setupOIDCTestFunction · 0.92
TestRegionsFunction · 0.92
TestGetCryptoKeysFunction · 0.92
TestEntitlementsFunction · 0.92
TestAuditLoggingFunction · 0.92
startWithFirstUserMethod · 0.92

Calls 11

NewOptionsFunction · 0.92
NewFunction · 0.92
NewProvisionerDaemonFunction · 0.92
NewFunction · 0.92
CreateFirstUserFunction · 0.92
AddLicenseFunction · 0.85
HelperMethod · 0.65
CleanupMethod · 0.65
CloseMethod · 0.65
StringMethod · 0.45
ValueMethod · 0.45

Tested by 15

TestIntegrationFunction · 0.74
TestWorkspaceAppsFunction · 0.74
setupOIDCTestFunction · 0.74
TestRegionsFunction · 0.74
TestGetCryptoKeysFunction · 0.74
TestEntitlementsFunction · 0.74
TestAuditLoggingFunction · 0.74
startWithFirstUserMethod · 0.74