Skip to content

Commit

Permalink
- Added test improvements.
Browse files Browse the repository at this point in the history
- Fixed pParse issue from `ngrok` config file with `inspect` and `bind_tls` in `tunnels` definitions.
- Fixed full `ngrok` log line now passed to Java logger (was previously just the `msg` field).
  • Loading branch information
alexdlaird committed Sep 28, 2021
1 parent fb236f9 commit 4b43c62
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 19 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ All notable changes to this project will be documented in this file.

This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased](https://github.com/alexdlaird/java-ngrok/compare/1.4.4...java8-ngrok)

## [1.4.4](https://github.com/alexdlaird/java-ngrok/compare/1.4.3...1.4.4) - 2021-09-28
### Added
- Test improvements.

### Fixed
- Parse issue from `ngrok` config file with `inspect` and `bind_tls` in `tunnels` definitions.
- Full `ngrok` log line now passed to Java logger (was previously just the `msg` field).

## [1.4.3](https://github.com/alexdlaird/java-ngrok/compare/1.4.0...1.4.3) - 2021-08-26
### Added
- Build improvements.
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ on [Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.a
<dependency>
<groupId>com.github.alexdlaird</groupId>
<artifactId>java-ngrok</artifactId>
<version>1.5.3</version>
<version>1.5.5</version>
</dependency>
```

#### Gradle

```groovy
implementation "com.github.alexdlaird:java-ngrok:1.5.3"
implementation "com.github.alexdlaird:java-ngrok:1.5.5"
```

If we want `ngrok` to be available from the command line, [pyngrok](https://github.com/alexdlaird/pyngrok) can be
Expand Down Expand Up @@ -92,7 +92,7 @@ include the `java8-ngrok` dependency from
<dependency>
<groupId>com.github.alexdlaird</groupId>
<artifactId>java8-ngrok</artifactId>
<version>1.4.3</version>
<version>1.4.4</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
}

group "com.github.alexdlaird"
version "1.4.3"
version "1.4.4"

java {
withJavadocJar()
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/github/alexdlaird/ngrok/NgrokClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public class NgrokClient {

private static final Logger LOGGER = Logger.getLogger(String.valueOf(NgrokClient.class));

private static final String VERSION = "1.4.3";
private static final String VERSION = "1.4.4";

private final JavaNgrokConfig javaNgrokConfig;
private final NgrokProcess ngrokProcess;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ private NgrokLog logLine(final String line) {
return null;
}

LOGGER.log(Level.parse(ngrokLog.getLvl()), ngrokLog.getMsg());
LOGGER.log(Level.parse(ngrokLog.getLvl()), ngrokLog.getLine());
logs.add(ngrokLog);
if (logs.size() > javaNgrokConfig.getMaxLogs()) {
logs.remove(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,10 @@ public void withTunnelDefinition(Map<String, Object> tunnelDefinition) {
this.addr = (String) tunnelDefinition.get("addr");
}
if (isNull(this.inspect) && tunnelDefinition.containsKey("inspect")) {
this.inspect = Boolean.valueOf((String) tunnelDefinition.get("inspect"));
this.inspect = Boolean.valueOf(String.valueOf(tunnelDefinition.get("inspect")));
}
if (isNull(this.bindTls) && tunnelDefinition.containsKey("bind_tls")) {
this.bindTls = BindTls.valueOf(((String) tunnelDefinition.get("bind_tls")).toUpperCase());
this.bindTls = BindTls.valueOf((String.valueOf(tunnelDefinition.get("bind_tls"))).toUpperCase());
}
if (isNull(this.auth) && tunnelDefinition.containsKey("auth")) {
this.auth = (String) tunnelDefinition.get("auth");
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ <h3>Maven</h3>
&lt;dependency&gt;
&lt;groupId&gt;com.github.alexdlaird&lt;/groupId&gt;
&lt;artifactId&gt;java-ngrok&lt;/artifactId&gt;
&lt;version&gt;1.5.3&lt;/version&gt;
&lt;version&gt;1.5.5&lt;/version&gt;
&lt;/dependency&gt;
</pre>

<h3>Gradle</h3>

<pre>
implementation "com.github.alexdlaird:java-ngrok:1.5.3"
implementation "com.github.alexdlaird:java-ngrok:1.5.5"
</pre>

If we want <code>ngrok</code> to be available from the command line,
Expand Down Expand Up @@ -61,12 +61,12 @@ <h2>Java 8</h2>
&lt;dependency&gt;
&lt;groupId&gt;com.github.alexdlaird&lt;/groupId&gt;
&lt;artifactId&gt;java8-ngrok&lt;/artifactId&gt;
&lt;version&gt;1.4.3&lt;/version&gt;
&lt;version&gt;1.4.4&lt;/version&gt;
&lt;/dependency&gt;
</pre>

The <a href="https://docs.oracle.com/javase/9/docs/api/java/lang/ProcessHandle.html">Process API</a> was introduced in
Java 9, so certain convenience methods around managing the <code>ngrok</code> process (for instance, tearing it down)
are not available in the Java 8 build.

</body>
</body>
18 changes: 11 additions & 7 deletions src/test/java/com/github/alexdlaird/ngrok/NgrokClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -409,16 +409,18 @@ public void testTunnelDefinitions() {

// GIVEN
final String subdomain = createUniqueSubdomain();
final Map<String, Object> httpTunnelConfig = new HashMap<String, Object>() {{
final Map<String, Object> httpTunnelConfig = new HashMap<>() {{
put("proto", "http");
put("addr", "8000");
put("subdomain", subdomain);
put("inspect", Boolean.FALSE);
put("bind_tls", Boolean.TRUE);
}};
final Map<String, Object> tcpTunnelConfig = new HashMap<String, Object>() {{
final Map<String, Object> tcpTunnelConfig = new HashMap<>() {{
put("proto", "tcp");
put("addr", "22");
}};
final Map<String, Object> tunnelsConfig = new HashMap<String, Object>() {{
final Map<String, Object> tunnelsConfig = new HashMap<>() {{
put("http-tunnel", httpTunnelConfig);
put("tcp-tunnel", tcpTunnelConfig);
}};
Expand All @@ -445,15 +447,17 @@ public void testTunnelDefinitions() {
.withName("tcp-tunnel")
.build();
final Tunnel sshTunnel = ngrokClient2.connect(createSshTunnel);
final List<Tunnel> tunnels = ngrokClient2.getTunnels();

// THEN
assertEquals("http-tunnel (http)", httpTunnel.getName());
assertEquals(2, tunnels.size());
assertEquals("http-tunnel", httpTunnel.getName());
assertEquals("http://localhost:8000", httpTunnel.getConfig().getAddr());
assertEquals(Proto.HTTP.toString(), httpTunnel.getProto());
assertEquals(String.format("http://%s.ngrok.io", subdomain), httpTunnel.getPublicUrl());
assertEquals("https", httpTunnel.getProto());
assertEquals(String.format("https://%s.ngrok.io", subdomain), httpTunnel.getPublicUrl());
assertEquals("tcp-tunnel", sshTunnel.getName());
assertEquals("localhost:22", sshTunnel.getConfig().getAddr());
assertEquals(Proto.TCP.toString(), sshTunnel.getProto());
assertEquals("tcp", sshTunnel.getProto());
assertThat(sshTunnel.getPublicUrl(), startsWith("tcp://"));
}

Expand Down

0 comments on commit 4b43c62

Please sign in to comment.