Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start ngrok if the current listened port is not the expected one #55

Merged
merged 3 commits into from
Apr 30, 2021

Conversation

juherr
Copy link
Contributor

@juherr juherr commented Apr 27, 2021

For #51

Copy link
Owner

@kilmajster kilmajster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First of all, big thanks for contributing! Code changes are fine to me, I put 2 small comments but they are more like ideas to discuss :)

log.info("Ngrok was already running! Dashboard url -> [ {} ]", ngrokApiClient.getNgrokApiUrl());
tunnels = ngrokApiClient.fetchTunnels(port);
} else {
NgrokTunnel httpTunnel = ngrokApiClient.startTunnel(port, "http", "springboot-http-" + port);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe its a good idea to make this prefix (I mean onlyspringboot- part) configurable, or taking it from spring.application.name property with springboot- as a default value? wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using spring.application.name is an excellent idea

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

.thenReturn(Collections.singletonList(tunnel));
}

when(ngrokApiClient.startTunnel(anyInt(), anyString(), anyString()))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then this test could use some more serious values :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't want to make too much complexity in mocks.
But to be honest I was a bit lazy too.
Do you have any values you'd like?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant something like:

when(ngrokApiClient.startTunnel(eq(8080), eq("http"), anyString()))
        .thenReturn(ngrokTunnelsList.getTunnels().get(0));
when(ngrokApiClient.startTunnel(eq(8080), eq("https"), anyString()))
        .thenReturn(...

but you can leave it like this, because I got work in progress done in NgrokApiClient in order to cover full ngrok api, just need to add some tests so anyways I'll need to update this one :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will let you do better in the next step ;)

@juherr
Copy link
Contributor Author

juherr commented Apr 29, 2021

Fyi, I didn't make real-life tests, only unit tests with mocks.
How do you usually manage it?

@kilmajster
Copy link
Owner

kilmajster commented Apr 29, 2021

Basically I don't have any particular way before making new release. I just test manually if new functionality works with dummy app, and when I touched some other part I test also that. Then github checks are testing if minimal configuration works with .github/test-app with real ngrok tunnels in containers of windows, macos, and linux and if yes I'm assuming that everything is ready

@juherr
Copy link
Contributor Author

juherr commented Apr 30, 2021

Ok, so feel free to ping me if something is going wrong with my changes :)

@kilmajster kilmajster merged commit 763e765 into kilmajster:main Apr 30, 2021
@kilmajster
Copy link
Owner

Hi, I made tests on real app and it turns out https is not a valid name for proto, so it was failing with HTTP 400. I spent a moment on figuring out how to start https tunnel, but after a few tests with postman, I found that after starting a tunnel via API it creates http and also https tunnel. Moreover https tunnel gets name that was used in the creation request, http tunnel name gets (http) sufix with space on the begining, that was not mentioned in any way in the documentation 🙄 so my conclusion is that ngrok treats https as a default for http tunneling.
Anyways I replaced second call of NgrokApiClient#startTunnel with search for tunnel by name, did some other polishing like version bump etc and released everything as 0.3.7 version

fyi, what I did - eb29737

:)

@juherr
Copy link
Contributor Author

juherr commented May 1, 2021

Awesome! I can't wait to test it.

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.

2 participants