Skip to content

Commit

Permalink
Fix parsing lsb-release files
Browse files Browse the repository at this point in the history
  • Loading branch information
gschneider-r7 committed Jun 20, 2019
1 parent 8316a41 commit 32b232e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ private OperatingSystem parseOsRelease(InputStream input, String architecture) t
String value = matcher.group("value");
switch (name) {
case "ID":
case "DISTRIB_ID":
id = value.replaceAll("\"", "").toLowerCase();
break;
case "NAME":
case "DISTRIB_ID":
product = value.replaceAll("\"", "");
break;
case "VERSION_ID":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,18 @@ void parseUbuntu() throws IOException {
assertEquals("16.04", os.getVersion());
assertEquals("Ubuntu Linux 16.04", os.getDescription());
}

@Test
void parseUbuntuLsbRelease() throws IOException {
// Given
Fingerprinter fp = new Fingerprinter();

// When
OperatingSystem os = fp.parse(FingerprinterTest.class.getResourceAsStream("ubuntu-lsb-release.txt"), "/etc/lsb-release", "x86_64");

// Then
assertEquals("Ubuntu", os.getVendor());
assertEquals("16.04", os.getVersion());
assertEquals("Ubuntu Linux 16.04", os.getDescription());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.6 LTS"

0 comments on commit 32b232e

Please sign in to comment.