Skip to content

Commit

Permalink
change comment style
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbae committed Jan 2, 2019
1 parent abd362d commit bfa48c6
Showing 1 changed file with 87 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,99 +40,133 @@ public void testValidateServerName() throws Exception {
Method method = hsoObject.getClass().getDeclaredMethod("validateServerName", String.class);
method.setAccessible(true);

// Server Name = msjdbc.database.windows.net
// SAN = msjdbc.database.windows.net
// Expected result: true
/*
* Server Name = msjdbc.database.windows.net
* SAN = msjdbc.database.windows.net
* Expected result: true
*/
assertTrue((boolean) method.invoke(hsoObject, "msjdbc.database.windows.net"));

// Server Name = msjdbc.database.windows.net
// SAN = msjdbc***.database.windows.net
// Expected result: true
/*
* Server Name = msjdbc.database.windows.net
* SAN = msjdbc***.database.windows.net
* Expected result: true
*/
assertTrue((boolean) method.invoke(hsoObject, "msjdbc***.database.windows.net"));

// Server Name = msjdbc.database.windows.net
// SAN = ms*bc.database.windows.net
// Expected result: true
/*
* Server Name = msjdbc.database.windows.net
* SAN = ms*bc.database.windows.net
* Expected result: true
*/
assertTrue((boolean) method.invoke(hsoObject, "ms*bc.database.windows.net"));

// Server Name = msjdbc.database.windows.net
// SAN = *bc.database.windows.net
// Expected result: true
/*
* Server Name = msjdbc.database.windows.net
* SAN = *bc.database.windows.net
* Expected result: true
*/
assertTrue((boolean) method.invoke(hsoObject, "*bc.database.windows.net"));

// Server Name = msjdbc.database.windows.net
// SAN = ms*.database.windows.net
// Expected result: true
/*
* Server Name = msjdbc.database.windows.net
* SAN = ms*.database.windows.net
* Expected result: true
*/
assertTrue((boolean) method.invoke(hsoObject, "ms*.database.windows.net"));

// Server Name = msjdbc.database.windows.net
// SAN = *jd*.database.windows.net
// Expected result: true
/*
* Server Name = msjdbc.database.windows.net
* SAN = *jd*.database.windows.net
* Expected result: true
*/
assertTrue((boolean) method.invoke(hsoObject, "*jd*.database.windows.net"));

// Server Name = msjdbc.database.windows.net
// SAN = ms.*.net
// Expected result: false
/*
* Server Name = msjdbc.database.windows.net
* SAN = ms.*.net
* Expected result: false
*/
assertFalse((boolean) method.invoke(hsoObject, "ms.*.net"));

// Server Name = msjdbc.database.windows.net
// SAN = msjdbc.asd*dsa.windows.net
// Expected result: false
/*
* Server Name = msjdbc.database.windows.net
* SAN = msjdbc.asd*dsa.windows.net
* Expected result: false
*/
assertFalse((boolean) method.invoke(hsoObject, "msjdbc.asd*dsa.windows.net"));

// Server Name = msjdbc.database.windows.net
// SAN = .*.windows.net
// Expected result: false
/*
* Server Name = msjdbc.database.windows.net
* SAN = *.*.windows.net
* Expected result: false
*/
assertFalse((boolean) method.invoke(hsoObject, ".*.windows.net"));

// Server Name = msjdbc.database.windows.net
// SAN = msjdbc.*.windows.net
// Expected result: false
/*
* Server Name = msjdbc.database.windows.net
* SAN = msjdbc.*.windows.net
* Expected result: false
*/
assertFalse((boolean) method.invoke(hsoObject, "msjdbc.*.windows.net"));

// Server Name = msjdbc.database.windows.net
// SAN = *.*.windows.net
// Expected result: false
// Note: multiple wildcards are not allowed, so this case shouldn't happen, but we still make sure to fail this.
/*
* Server Name = msjdbc.database.windows.net
* SAN = *.*.windows.net
* Expected result: false
* Note: multiple wildcards are not allowed, so this case shouldn't happen, but we still make sure to fail this.
*/
assertFalse((boolean) method.invoke(hsoObject, "*.*.windows.net"));

// Server Name = msjdbc.database.windows.net
// SAN = *.com
// Expected result: false
// A cert with * plus a top-level domain is not allowed.
/*
* Server Name = msjdbc.database.windows.net
* SAN = *.com
* Expected result: false
* A cert with * plus a top-level domain is not allowed.
*/
assertFalse((boolean) method.invoke(hsoObject, "*.com"));

// Server Name = msjdbc.database.windows.net
// SAN = xn--ms*.database.windows.net
// Expected result: fail
/*
* Server Name = msjdbc.database.windows.net
* SAN = xn--ms*.database.windows.net
* Expected result: false
*/
assertFalse((boolean) method.invoke(hsoObject, "xn--ms*.database.windows.net"));

// Server Name = msjdbc.database.windows.net
// SAN = *
// Expected result: fail
/*
* Server Name = msjdbc.database.windows.net
* SAN = *
* Expected result: false
*/
assertFalse((boolean) method.invoke(hsoObject, "*"));

// Server Name = msjdbc.database.windows.net
// SAN = ms*atabase.windows.net
// Expected result: fail
/*
* Server Name = msjdbc.database.windows.net
* SAN = ms*atabase.windows.net
* Expected result: false
*/
assertFalse((boolean) method.invoke(hsoObject, "ms*atabase.windows.net"));

hsoObject = constructor.newInstance(null, tdsc, null, serverName2);
method = hsoObject.getClass().getDeclaredMethod("validateServerName", String.class);
method.setAccessible(true);

// Server Name = bbbbuuzzuzzzzzz.example.net
// SAN = b*zzz.example.net
// Expected result: true
/*
* Server Name = bbbbuuzzuzzzzzz.example.net
* SAN = b*zzz.example.net
* Expected result: true
*/
assertTrue((boolean) method.invoke(hsoObject, "b*zzz.example.net"));

hsoObject = constructor.newInstance(null, tdsc, null, serverName3);
method = hsoObject.getClass().getDeclaredMethod("validateServerName", String.class);
method.setAccessible(true);

// Server Name = xn--ms.database.windows.net
// SAN = xn--ms.database.windows.net
// Expected result: true
/*
* Server Name = xn--ms.database.windows.net
* SAN = xn--ms.database.windows.net
* Expected result: true
*/
assertTrue((boolean) method.invoke(hsoObject, "xn--ms.database.windows.net"));
}
}

0 comments on commit bfa48c6

Please sign in to comment.