MCPcopy Index your code
hub / github.com/ddev/ddev / TestInternalAndExternalAccessToURL

Function TestInternalAndExternalAccessToURL

pkg/ddevapp/ddevapp_test.go:4063–4175  ·  view source on GitHub ↗

TestInternalAndExternalAccessToURL checks we can access content from host and from inside container by URL (with port) Related test: TestNetworkAliases

(t *testing.T)

Source from the content-addressed store, hash-verified

4061// from host and from inside container by URL (with port)
4062// Related test: TestNetworkAliases
4063func TestInternalAndExternalAccessToURL(t *testing.T) {
4064 if nodeps.IsEnvFalse("DDEV_RUN_TEST_ANYWAY") && nodeps.IsAppleSilicon() {
4065 t.Skip("Skipping on mac Apple Silicon/Lima/Colima/Rancher to ignore problems with 'connection reset by peer'")
4066 }
4067
4068 assert := asrt.New(t)
4069
4070 runTime := util.TimeTrackC(t.Name())
4071
4072 site := TestSites[0]
4073 app := new(ddevapp.DdevApp)
4074
4075 err := app.Init(site.Dir)
4076 assert.NoError(err)
4077
4078 t.Cleanup(func() {
4079 // Set the ports back to the default was so we don't break any following tests.
4080 app.RouterHTTPSPort = ""
4081 app.RouterHTTPPort = ""
4082 app.AdditionalFQDNs = []string{}
4083 app.AdditionalHostnames = []string{}
4084
4085 err = app.WriteConfig()
4086 assert.NoError(err)
4087 err = app.Stop(true, false)
4088 assert.NoError(err)
4089 })
4090
4091 // Load files if provided
4092 if site.FilesTarballURL != "" {
4093 _, tarballPath, err := testcommon.GetCachedArchive(site.Name, "local-tarballs-files", "", site.FilesTarballURL)
4094 require.NoError(t, err)
4095 err = app.ImportFiles("", tarballPath, "")
4096 assert.NoError(err)
4097 }
4098
4099 // Add some additional hostnames
4100 app.AdditionalHostnames = []string{"sub1", "sub2", "sub3"}
4101 app.AdditionalFQDNs = []string{"junker99.example.com"}
4102
4103 for _, pair := range []testcommon.PortPair{{HTTPPort: "8000", HTTPSPort: "8143"}, {HTTPPort: "8080", HTTPSPort: "8443"}} {
4104 testcommon.ClearDockerEnv()
4105 app.RouterHTTPPort = pair.HTTPPort
4106 app.RouterHTTPSPort = pair.HTTPSPort
4107 err = app.WriteConfig()
4108 assert.NoError(err)
4109
4110 // Make sure that project is absolutely not running
4111 err = app.Stop(true, false)
4112 assert.NoError(err)
4113
4114 err = app.StartAndWait(5)
4115 assert.NoError(err)
4116
4117 expectedNumUrls := len(app.GetHostnames())*2 + 2
4118 httpURLs, _, urls := app.GetAllURLs()
4119
4120 // If no https/mkcert, number of hostnames is different

Callers

nothing calls this directly

Calls 15

IsEnvFalseFunction · 0.92
IsAppleSiliconFunction · 0.92
TimeTrackCFunction · 0.92
GetCachedArchiveFunction · 0.92
ClearDockerEnvFunction · 0.92
GetCAROOTFunction · 0.92
GetLocalHTTPResponseFunction · 0.92
EnsureLocalHTTPContentFunction · 0.92
RunHostCommandFunction · 0.92
CleanupMethod · 0.80
WriteConfigMethod · 0.80
StopMethod · 0.80

Tested by

no test coverage detected