Skip to content

Commit bc3dfc6

Browse files
authored
Added support for ngrok authToken (#61)
* Added support for ngrok authToken * added auth token to test app * test fixes * CI tests * Fixes automation tests * CI fix * CI fix vNEXT * CI fix vNEXT * CI fix vNEXT * CI fix vNEXT * CI fix vNEXT * CI fix vNEXT * CI fix vNEXT * dependencies versions bump * added docs about authToken
1 parent 1de4d39 commit bc3dfc6

File tree

16 files changed

+127
-243
lines changed

16 files changed

+127
-243
lines changed

β€Ž.github/scripts/set-current-starter-version-macos.shβ€Ž

Lines changed: 0 additions & 9 deletions
This file was deleted.

β€Ž.github/scripts/set-current-starter-version.shβ€Ž

Lines changed: 0 additions & 9 deletions
This file was deleted.

β€Ž.github/test-app/pom.xmlβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<description>Dummy app for tests</description>
1616
<properties>
1717
<java.version>11</java.version>
18-
<ngrok-spring-boot-starter.version>ci-version-placeholder</ngrok-spring-boot-starter.version>
18+
<ngrok-spring-boot-starter.version>SNAPSHOT</ngrok-spring-boot-starter.version>
1919
</properties>
2020
<dependencies>
2121
<dependency>

β€Ž.github/test-app/src/test/java/io/github/kilmajster/AppTests.javaβ€Ž

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,12 @@
2020

2121
import static org.assertj.core.api.Assertions.assertThat;
2222

23-
@SpringBootTest(
24-
webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT,
25-
properties = {
26-
"ngrok.enabled=true"
27-
}
28-
)
23+
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
2924
@ExtendWith(OutputCaptureExtension.class)
3025
class AppTests {
3126

3227
private final static Logger log = LoggerFactory.getLogger(AppTests.class);
33-
private static final int WAIT_FOR_STARTUP_SECONDS = 30;
28+
private static final int WAIT_FOR_STARTUP_SECONDS = 90;
3429
private static final String HTTPS_NGROK_TUNNEL_REGEX = "(https:\\/\\/)?(([^.]+)\\.)?ngrok\\.io";
3530

3631
@Test
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ngrok.enabled=true
2+

β€Ž.github/workflows/automation-test-macos.ymlβ€Ž

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@ jobs:
1919
- name: Silent install main project
2020
run: mvn --batch-mode --no-transfer-progress install -Dmaven.test.skip=true
2121

22-
- name: Install xmllint
23-
run: brew install xmlstarlet
24-
25-
- name: Set current starter version in test-app
26-
working-directory: ./.github/scripts/
27-
run: sh set-current-starter-version-macos.sh
22+
- name: Add ngrok auth token application.properties
23+
run: |
24+
printf ${{secrets.NGROK_AUTH_TOKEN_PROPERTY}} >> .github/test-app/src/test/resources/application.properties
25+
shell: bash
2826

2927
- name: Run automation tests with latest ngrok-spring-boot-starter version on test-app
3028
working-directory: ./.github/test-app/

β€Ž.github/workflows/automation-test-ubuntu.ymlβ€Ž

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@ jobs:
1919
- name: Silent install main project
2020
run: mvn --batch-mode --no-transfer-progress install -Dmaven.test.skip=true
2121

22-
- name: Install xmllint
23-
run: sudo apt-get install libxml2-utils
24-
25-
- name: Set current starter version in test-app
26-
working-directory: ./.github/scripts/
27-
run: sh set-current-starter-version.sh
22+
- name: Add ngrok auth token application.properties
23+
run: |
24+
printf ${{secrets.NGROK_AUTH_TOKEN_PROPERTY}} >> .github/test-app/src/test/resources/application.properties
25+
shell: bash
2826

2927
- name: Run automation tests with latest ngrok-spring-boot-starter version on test-app
3028
working-directory: ./.github/test-app/

β€Ž.github/workflows/automation-test-windows.ymlβ€Ž

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ jobs:
1919
- name: Silent install main project
2020
run: mvn --batch-mode --no-transfer-progress install -DskipTests
2121

22-
- name: Set current starter version in test-app
23-
working-directory: ./.github/scripts/
24-
run: sh set-current-starter-version.sh
22+
- name: Add ngrok auth token application.properties
23+
run: |
24+
printf ${{secrets.NGROK_AUTH_TOKEN_PROPERTY}} >> .github/test-app/src/test/resources/application.properties
25+
shell: bash
2526

2627
- name: Run automation tests with latest ngrok-spring-boot-starter version on test-app
2728
working-directory: ./.github/test-app/

β€ŽREADME.mdβ€Ž

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,19 @@ compile('io.github.kilmajster:ngrok-spring-boot-starter:0.5.0')
5959
6060
## Configuration
6161
### πŸš€ Minimal configuration
62-
#### `ngrok.enabled` - one required configuration property
62+
#### `ngrok.enabled`
6363
For simple http tunneling to springs default server port, **only one configuration property is required**.
6464
There are many ways to provide spring config, for `application.property` based one, it will be:
6565
```properties
6666
ngrok.enabled=true
6767
```
68-
or yaml:
69-
```yaml
70-
ngrok:
71-
enabled: true
68+
69+
#### `ngrok.authToken`
70+
Ngrok requires `authToken` to be defined, to obtain one visit https://dashboard.ngrok.com/get-started/your-authtoken and then add it like below:
71+
```properties
72+
ngrok.authToken=<YOUR PERSONAL AUTH TOKEN>
7273
```
73-
or you can pass java execution attribute, like: `java -jar your-app.jar --ngrok.enabled=true`,
74-
or with spring-boot plugin `mvn spring-boot:run -Dspring-boot.run.arguments="--ngrok.enabled=true"`, or any other way 😊
74+
If you got already configured auth token in your ngrok config file there is no need to define this property.
7575

7676
βœ… **All done, configuration is ready!**
7777

@@ -121,21 +121,6 @@ ngrok.command=http -region=us -hostname=dev.example.com 8000
121121
# should be = /home/user/.ngrok2/ngrok http -region=us -hostname=dev.example.com 8000
122122
```
123123
124-
## Ngrok API
125-
To access ngrok tunneling details you can use `NgrokApiClient` bean. Example below:
126-
```java
127-
@Autowired
128-
private NgrokApiClient ngrok;
129-
130-
public void someMethod() {
131-
# returns https tunnel URL or null in case ngrok is not running
132-
String httpsTunnelUrl = ngrok.getHttpsTunnelUrl();
133-
134-
# returns http tunnel URL or null in case ngrok is not running
135-
String httpTunnelUrl = ngrok.getHttpTunnelUrl();
136-
}
137-
```
138-
139124
##### Optional properties & descriptions
140125
```properties
141126
# if you've got already running Ngrok instance somewhere else, you can specify its host & port, whoch defaults are:

β€ŽREADME_v2.mdβ€Ž

Lines changed: 0 additions & 175 deletions
This file was deleted.

0 commit comments

Comments
Β (0)