Skip to content

Conversation

lwsanty
Copy link
Contributor

@lwsanty lwsanty commented Sep 25, 2019

add github proxy + extend discovery and download tests

Signed-off-by: lwsanty lwsanty@gmail.com

@lwsanty lwsanty self-assigned this Sep 25, 2019
@lwsanty
Copy link
Contributor Author

lwsanty commented Sep 25, 2019

@lwsanty lwsanty changed the title [WIP] github proxy tests github proxy tests Sep 25, 2019
@lwsanty lwsanty removed the blocked label Sep 25, 2019
@jfontan
Copy link
Contributor

jfontan commented Sep 26, 2019

This new tests need certificates to be configured in the system and they are always executed. While this is ok to do in travis VMs I'm not sure this should be a requirement in the developer's computer. make test fails.

I would either enable insecure communication for tests so the certs don't need to be installed in the computer or only execute these tests if explicitly asked for. One way to do this is moving the test to a new file and add a build tag on top:

// +build proxy

package discovery

func TestProxyMockUps(t *testing.T) {
....

and calling make in travis script with GO_TAGS set

- GO_TAGS=proxy make ci-script

Either option is OK for me but I would prefer if tests could be run in my computer without installing certs.

@mcarmonaa thoughts?

@lwsanty
Copy link
Contributor Author

lwsanty commented Sep 26, 2019

@jfontan I like the tags version

@mcarmonaa
Copy link
Contributor

mcarmonaa commented Sep 26, 2019

Other way could be just check for the environment variables the CI sets, so if for any reason you want to run those tests you just have to set the variables instead of rebuild the project:

if os.Getenv("TRAVIS") == "" {
        t.Skip()
}

Anyway it's fine for me also the tag thing, not a strong preference for any of these solutions.

@lwsanty
Copy link
Contributor Author

lwsanty commented Sep 26, 2019

@mcarmonaa this one is the easiest :), I will pick it if @jfontan is ok with it

@jfontan
Copy link
Contributor

jfontan commented Sep 26, 2019

@lwsanty I believe there is a better way. When setting up the transport to use proxy you can configure Transport's to accept insecure certificates:

https://golang.org/pkg/net/http/#Transport
https://golang.org/pkg/crypto/tls/#Config

Something like:

// SetTransportProxy changes http.DefaultTransport to the one that uses current server as a proxy
func SetTransportProxy() error {
	u, err := url.Parse(URL)
	if err != nil {
		return err
	}

	http.DefaultTransport = &http.Transport{
		Proxy: http.ProxyURL(u),
		// Disable HTTP/2.
		TLSNextProto: make(map[string]func(authority string, c *tls.Conn) http.RoundTripper),
		TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
	}

	return nil
}

@lwsanty
Copy link
Contributor Author

lwsanty commented Sep 26, 2019

@jfontan got it! I will check it tomorrow!

add github proxy + extend discovery and download tests

Signed-off-by: lwsanty <lwsanty@gmail.com>
Signed-off-by: lwsanty <lwsanty@gmail.com>
@mcarmonaa mcarmonaa merged commit 98d2070 into master Sep 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants