-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fix case-sensitivity bug for port numbers in command #524
Changes from 1 commit
6ecd414
b9a04c5
5784244
704927c
399475a
f0a49e4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,31 +3,36 @@ | |
import com.google.common.collect.ImmutableSet; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could you please fix the indentation in this file? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh yes, sorry, will fix the indentation. I had a problem with netcat and the infinispan container before, it's not installed. I could imagine other containers not supporting it, too. In fact I thought this was the reason for the /proc/net/tcp solution here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah, ok, I see 👍 |
||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.testcontainers.containers.BindMode; | ||
import org.testcontainers.containers.GenericContainer; | ||
|
||
import static org.rnorth.visibleassertions.VisibleAssertions.assertThrows; | ||
import static org.rnorth.visibleassertions.VisibleAssertions.assertTrue; | ||
|
||
public class InternalCommandPortListeningCheckTest { | ||
|
||
@Rule | ||
public GenericContainer nginx = new GenericContainer<>("nginx:1.9.4"); | ||
// Linking a custom configuration into the container so that nginx is listening on port 8080. This is necessary to proof | ||
// that the command formatting uses the correct casing for hexadecimal numberd (i.e. 1F90 and not 1f90). | ||
@Rule | ||
public GenericContainer nginx = new GenericContainer<>("nginx:1.9.4") | ||
.withClasspathResourceMapping("nginx.conf", "/etc/nginx/conf.d/default.conf", BindMode.READ_ONLY); | ||
|
||
@Test | ||
public void singleListening() { | ||
final InternalCommandPortListeningCheck check = new InternalCommandPortListeningCheck(nginx, ImmutableSet.of(80)); | ||
@Test | ||
public void singleListening() { | ||
final InternalCommandPortListeningCheck check = new InternalCommandPortListeningCheck(nginx, ImmutableSet.of(8080)); | ||
|
||
final Boolean result = check.call(); | ||
final Boolean result = check.call(); | ||
|
||
assertTrue("InternalCommandPortListeningCheck identifies a single listening port", result); | ||
} | ||
assertTrue("InternalCommandPortListeningCheck identifies a single listening port", result); | ||
} | ||
|
||
@Test | ||
public void nonListening() { | ||
final InternalCommandPortListeningCheck check = new InternalCommandPortListeningCheck(nginx, ImmutableSet.of(80, 1234)); | ||
@Test | ||
public void nonListening() { | ||
final InternalCommandPortListeningCheck check = new InternalCommandPortListeningCheck(nginx, ImmutableSet.of(8080, 1234)); | ||
|
||
assertThrows("InternalCommandPortListeningCheck detects a non-listening port among many", | ||
IllegalStateException.class, | ||
(Runnable) check::call); | ||
} | ||
|
||
assertThrows("InternalCommandPortListeningCheck detects a non-listening port among many", | ||
IllegalStateException.class, | ||
(Runnable) check::call); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
server { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
listen 8080; | ||
server_name localhost; | ||
|
||
#charset koi8-r; | ||
#access_log /var/log/nginx/host.access.log main; | ||
|
||
location / { | ||
root /usr/share/nginx/html; | ||
index index.html index.htm; | ||
} | ||
|
||
#error_page 404 /404.html; | ||
|
||
# redirect server error pages to the static page /50x.html | ||
# | ||
error_page 500 502 503 504 /50x.html; | ||
location = /50x.html { | ||
root /usr/share/nginx/html; | ||
} | ||
|
||
# proxy the PHP scripts to Apache listening on 127.0.0.1:80 | ||
# | ||
#location ~ \.php$ { | ||
# proxy_pass http://127.0.0.1; | ||
#} | ||
|
||
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 | ||
# | ||
#location ~ \.php$ { | ||
# root html; | ||
# fastcgi_pass 127.0.0.1:9000; | ||
# fastcgi_index index.php; | ||
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; | ||
# include fastcgi_params; | ||
#} | ||
|
||
# deny access to .htaccess files, if Apache's document root | ||
# concurs with nginx's one | ||
# | ||
#location ~ /\.ht { | ||
# deny all; | ||
#} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
%x produces lower-case hexadecimal numbers, /proc/net/tcp has uppercase references. This only shows itself with ports that actually contain letters, of course. Hence the configuration change for the nginx instance to run on 8080, which is '1F90' in hex (as opposed to '1f90')...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoa! Nice one, thanks @dnno. We should probably change grep to
-i
to completely ignore the case in case of the case differences. WDYT?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, that sounds reasonable. Will change that!