Skip to content
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

[d16-2] [tests] wrench is long gone #6698

Merged
merged 3 commits into from
Aug 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 32 additions & 4 deletions tests/linker/ios/link all/LinkAllTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,26 @@ public void MEF_3862 ()
Assert.True (default_value, "DefaultValue");
}

public enum CertificateProblem : long {
CertEXPIRED = 0x800B0101,
CertVALIDITYPERIODNESTING = 0x800B0102,
CertROLE = 0x800B0103,
CertPATHLENCONST = 0x800B0104,
CertCRITICAL = 0x800B0105,
CertPURPOSE = 0x800B0106,
CertISSUERCHAINING = 0x800B0107,
CertMALFORMED = 0x800B0108,
CertUNTRUSTEDROOT = 0x800B0109,
CertCHAINING = 0x800B010A,
CertREVOKED = 0x800B010C,
CertUNTRUSTEDTESTROOT = 0x800B010D,
CertREVOCATION_FAILURE = 0x800B010E,
CertCN_NO_MATCH = 0x800B010F,
CertWRONG_USAGE = 0x800B0110,
CertUNTRUSTEDCA = 0x800B0112,
CertTRUSTEFAIL = 0x800B010B,
}

class TestPolicy : ICertificatePolicy {

const int RecoverableTrustFailure = 5; // SecTrustResult
Expand All @@ -156,10 +176,19 @@ public TestPolicy ()

public bool CheckValidationResult (ServicePoint srvPoint, X509Certificate certificate, WebRequest request, int certificateProblem)
{
Assert.That (certificateProblem, Is.EqualTo (0), "certificateProblem");
Assert.That (certificateProblem, Is.EqualTo (0), GetProblemMessage ((CertificateProblem) certificateProblem));
CheckCount++;
return true;
}

string GetProblemMessage (CertificateProblem problem)
{
var problemMessage = "";
CertificateProblem problemList = new CertificateProblem ();
var problemCodeName = Enum.GetName (problemList.GetType (), problem);
problemMessage = problemCodeName != null ? problemMessage + "-Certificateproblem:" + problemCodeName : "Unknown Certificate Problem";
return problemMessage;
}
}

static TestPolicy test_policy = new TestPolicy ();
Expand All @@ -177,12 +206,11 @@ public void TrustUsingOldPolicy ()
try {
ServicePointManager.CertificatePolicy = test_policy;
WebClient wc = new WebClient ();
Assert.IsNotNull (wc.DownloadString ("https://wrench.internalx.com/Wrench/Login.aspx"));
Assert.IsNotNull (wc.DownloadString ("https://xamarin.com"));
// caching means it will be called at least for the first run, but it might not
// be called again in subsequent requests (unless it expires)
Assert.That (test_policy.CheckCount, Is.GreaterThan (0), "policy checked");
}
finally {
} finally {
ServicePointManager.CertificatePolicy = old;
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/linker/ios/link sdk/CryptoTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void TrustUsingNewCallback ()
return true;
};
WebClient wc = new WebClient ();
Assert.IsNotNull (wc.DownloadString ("https://wrench.internalx.com/Wrench/Login.aspx"));
Assert.IsNotNull (wc.DownloadString ("https://xamarin.com"));
// caching means it will be called at least for the first run, but it might not
// be called again in subsequent requests (unless it expires)
Assert.That (trust_validation_callback, Is.GreaterThan (0), "validation done");
Expand Down