Skip to content

Commit 05208bf

Browse files
committed
attempt at fix
1 parent b061e06 commit 05208bf

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/github.com/getlantern/flashlight/app/integration_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ func TestProxying(t *testing.T) {
6767
// We have to write out a config file so that Lantern doesn't try to use the
6868
// default config, which would go to some remote proxies that can't talk to
6969
// our fake config server.
70-
err = writeConfig(configAddr)
70+
err = writeConfig()
7171
if !assert.NoError(t, err) {
7272
return
7373
}
7474

7575
// Starts the Lantern App
76-
err = startApp(t)
76+
err = startApp(t, configAddr)
7777
if !assert.NoError(t, err) {
7878
return
7979
}
@@ -138,15 +138,14 @@ func startConfigServer(t *testing.T) (string, error) {
138138
if err != nil {
139139
return "", fmt.Errorf("Unable to listen for config server connection: %v", err)
140140
}
141-
configAddr := l.Addr().String()
142141
go func() {
143-
err := http.Serve(l, http.HandlerFunc(serveConfig(t, configAddr)))
142+
err := http.Serve(l, http.HandlerFunc(serveConfig(t)))
144143
assert.NoError(t, err, "Unable to serve config")
145144
}()
146-
return configAddr, nil
145+
return l.Addr().String(), nil
147146
}
148147

149-
func serveConfig(t *testing.T, configAddr string) func(http.ResponseWriter, *http.Request) {
148+
func serveConfig(t *testing.T) func(http.ResponseWriter, *http.Request) {
150149
return func(resp http.ResponseWriter, req *http.Request) {
151150
obfs4 := atomic.LoadUint32(&useOBFS4) == 1
152151
version := "1"
@@ -159,7 +158,7 @@ func serveConfig(t *testing.T, configAddr string) func(http.ResponseWriter, *htt
159158
return
160159
}
161160

162-
cfg, err := buildConfig(configAddr, obfs4)
161+
cfg, err := buildConfig(obfs4)
163162
if err != nil {
164163
t.Error(err)
165164
resp.WriteHeader(http.StatusInternalServerError)
@@ -175,22 +174,22 @@ func serveConfig(t *testing.T, configAddr string) func(http.ResponseWriter, *htt
175174
}
176175
}
177176

178-
func writeConfig(configAddr string) error {
177+
func writeConfig() error {
179178
filename := "lantern-9999.99.99.yaml"
180179
err := os.Remove(filename)
181180
if err != nil && !os.IsNotExist(err) {
182181
return fmt.Errorf("Unable to delete existing yaml config: %v", err)
183182
}
184183

185-
cfg, err := buildConfig(configAddr, false)
184+
cfg, err := buildConfig(false)
186185
if err != nil {
187186
return err
188187
}
189188

190189
return ioutil.WriteFile(filename, cfg, 0644)
191190
}
192191

193-
func buildConfig(configAddr string, obfs4 bool) ([]byte, error) {
192+
func buildConfig(obfs4 bool) ([]byte, error) {
194193
bytes, err := ioutil.ReadFile("./config-template.yaml")
195194
if err != nil {
196195
return nil, fmt.Errorf("Could not read config %v", err)
@@ -201,8 +200,6 @@ func buildConfig(configAddr string, obfs4 bool) ([]byte, error) {
201200
if err != nil {
202201
return nil, fmt.Errorf("Could not unmarshal config %v", err)
203202
}
204-
cfg.CloudConfig = "http://" + configAddr
205-
cfg.FrontedCloudConfig = cfg.CloudConfig
206203

207204
srv := cfg.Client.ChainedServers["fallback-template"]
208205
srv.AuthToken = Token
@@ -236,8 +233,11 @@ func buildConfig(configAddr string, obfs4 bool) ([]byte, error) {
236233
return out, nil
237234
}
238235

239-
func startApp(t *testing.T) error {
236+
func startApp(t *testing.T, configAddr string) error {
237+
configURL := "http://" + configAddr
240238
flags := map[string]interface{}{
239+
"cloudconfig": configURL,
240+
"frontedconfig": configURL,
241241
"addr": LocalProxyAddr,
242242
"headless": true,
243243
"proxyall": true,

0 commit comments

Comments
 (0)