Caplital OS name can not activate profile

This commit is contained in:
liutang123 2024-06-01 23:56:00 +08:00 committed by Konrad Windszus
parent 5e97703456
commit 0456c7c629
2 changed files with 18 additions and 4 deletions

View File

@ -105,14 +105,14 @@ public class OperatingSystemProfileActivator implements ProfileActivator {
reverse = true;
test = test.substring(1);
}
result = actualVersion.equals(test);
result = actualVersion.equalsIgnoreCase(test);
}
return reverse != result;
}
private boolean determineArchMatch(String expectedArch, String actualArch) {
String test = expectedArch;
String test = expectedArch.toLowerCase(Locale.ENGLISH);
boolean reverse = false;
if (test.startsWith("!")) {
@ -126,7 +126,7 @@ public class OperatingSystemProfileActivator implements ProfileActivator {
}
private boolean determineNameMatch(String expectedName, String actualName) {
String test = expectedName;
String test = expectedName.toLowerCase(Locale.ENGLISH);
boolean reverse = false;
if (test.startsWith("!")) {
@ -140,7 +140,7 @@ public class OperatingSystemProfileActivator implements ProfileActivator {
}
private boolean determineFamilyMatch(String family, String actualName) {
String test = family;
String test = family.toLowerCase(Locale.ENGLISH);
boolean reverse = false;
if (test.startsWith("!")) {

View File

@ -135,4 +135,18 @@ class OperatingSystemProfileActivatorTest extends AbstractProfileActivatorTest<O
assertActivation(false, profile, newContext(null, newProperties("windows", "99", "amd64")));
assertActivation(true, profile, newContext(null, newProperties("windows", "99", "aarch64")));
}
@Test
public void testCapitalOsName() {
Profile profile = newProfile(ActivationOS.newBuilder()
.family("Mac")
.name("Mac OS X")
.arch("aarch64")
.version("14.5"));
assertActivation(false, profile, newContext(null, newProperties("linux", "6.5.0-1014-aws", "amd64")));
assertActivation(false, profile, newContext(null, newProperties("windows", "1", "aarch64")));
assertActivation(false, profile, newContext(null, newProperties("windows", "99", "amd64")));
assertActivation(true, profile, newContext(null, newProperties("Mac OS X", "14.5", "aarch64")));
}
}