public void DownloadAndInstallPackage( ReportInstallProgress reportProgress, DownloadComplete downloadComplete, DownloadError downloadError, VerificationError verificationError, IsCancelled isCancelled ) { string downloadPath = PrepareDownloadFilePath(FileUtil.GetUniqueTempPathInProject(), config.Filename); new Detail.AsyncTaskRunnerBuilder <byte[]> ().Do((object[] args) => { return(Net.Validator.MakeRequest(() => { return API.V1.DownloadFile(config.PackageUrl, (progress) => reportProgress(progress), () => { return isCancelled(); }); })); }).OnError((System.Exception e) => { downloadError(e); return(Detail.AsyncTaskRunner <byte[]> .ErrorRecovery.Nothing); }).OnCompletion((byte[] downloadedBytes) => { if (downloadedBytes.Length == 0) { return; } try { System.IO.File.WriteAllBytes(downloadPath, downloadedBytes); string signatureUrl = SignatureUrlFromPackageUrl(config.PackageUrl); VerifySignature(signatureUrl, downloadedBytes, verificationError, downloadError, isCancelled, () => { downloadComplete(downloadPath); InstallPackage(downloadPath); }); } catch (IOException e) { downloadError(e as Exception); } }).Run(); }
public void DownloadAndInstallPackage( ReportInstallProgress reportProgress, DownloadComplete downloadComplete, DownloadError downloadError, VerificationError verificationError, IsCancelled isCancelled ) { string downloadPath = PrepareDownloadFilePath (FileUtil.GetUniqueTempPathInProject (), config.Filename); new Detail.AsyncTaskRunnerBuilder<byte[]> ().Do ((object[] args) => { return Net.Validator.MakeRequest (() => { return API.V1.DownloadFile (config.PackageUrl, (progress) => reportProgress(progress), () => { return isCancelled (); }); }); }).OnError ((System.Exception e) => { downloadError(e); return Detail.AsyncTaskRunner<byte[]>.ErrorRecovery.Nothing; }).OnCompletion ((byte[] downloadedBytes) => { if (downloadedBytes.Length == 0) { return; } try { System.IO.File.WriteAllBytes (downloadPath, downloadedBytes); string signatureUrl = SignatureUrlFromPackageUrl (config.PackageUrl); VerifySignature (signatureUrl, downloadedBytes, verificationError, downloadError, isCancelled, () => { downloadComplete (downloadPath); InstallPackage (downloadPath); }); } catch (IOException e) { downloadError (e as Exception); } }).Run (); }
private static void VerifySignature( string signatureUrl, byte[] fileToVerify, VerificationError verificationError, DownloadError downloadError, IsCancelled isCancelled, Action onSuccess ) { new Detail.AsyncTaskRunnerBuilder <byte[]> ().Do((object[] args) => { return(Net.Validator.MakeRequest(() => { return API.V1.DownloadFile(signatureUrl, (progress) => {}, () => { return isCancelled(); }); })); }).OnError((System.Exception e) => { downloadError(e); return(Detail.AsyncTaskRunner <byte[]> .ErrorRecovery.Nothing); }).OnCompletion((byte[] signature) => { if (SignatureMatches(signature, fileToVerify) == VerificationStatus.Success) { onSuccess(); return; } verificationError(); }).Run(); }
protected void CreateSignatureAndVerify(string signaturePath, DataHash documentHash, VerificationResultCode expectedResultCode, VerificationError expectedVerificationError = null) { TestVerificationContext context = new TestVerificationContext() { Signature = TestUtil.GetSignature(signaturePath), DocumentHash = documentHash }; Verify(context, expectedResultCode, expectedVerificationError); }
public bool VerificationResultMatch(VerificationError verificationError) { if (verificationError == null) { return(string.IsNullOrEmpty(ErrorCode)); } if (ErrorCode == verificationError.Code) { return(true); } return(false); }
public static void AddVerificationError(string errorText) { Log.Error("--> VerificationError Found: " + errorText); var error = new VerificationError(errorText, Config.settings.reportSettings.screenshotOnError); testData.VerificationErrors.Add(error); if (error.screenshot != null) { Log.Image(error.screenshot); } // TestContext.CurrentContext.IncrementAssertCount(); }
public ResultVerificationFailureException(VerificationError error) { Error = error; }
private static void VerifySignature( string signatureUrl, byte[] fileToVerify, VerificationError verificationError, DownloadError downloadError, IsCancelled isCancelled, Action onSuccess ) { new Detail.AsyncTaskRunnerBuilder<byte[]> ().Do ((object[] args) => { return Net.Validator.MakeRequest (() => { return API.V1.DownloadFile (signatureUrl, (progress) => {}, () => { return isCancelled (); }); }); }).OnError ((System.Exception e) => { downloadError (e); return Detail.AsyncTaskRunner<byte[]>.ErrorRecovery.Nothing; }).OnCompletion ((byte[] signature) => { if (SignatureMatches (signature, fileToVerify) == VerificationStatus.Success) { onSuccess (); return; } verificationError (); }).Run (); }
public void OnError(VerificationError verificationError) { }
protected void Verify(IVerificationContext context, VerificationResultCode expectedResultCode, VerificationError expectedVerificationError = null) { VerificationResult verificationResult = Rule.Verify(context); Assert.AreEqual(expectedResultCode, verificationResult.ResultCode, "Unexpected verification result code"); if (expectedResultCode == VerificationResultCode.Fail) { Assert.AreEqual(expectedVerificationError?.Code, verificationResult.VerificationError.Code, "Unexpected verification error code"); } }
protected void CreateSignatureAndVerify(string signaturePath, VerificationResultCode expectedResultCode, VerificationError expectedVerificationError = null) { CreateSignatureAndVerify(signaturePath, null, expectedResultCode, expectedVerificationError); }
private void CheckResult(VerificationResult result, VerificationResultCode expectedResultCode, VerificationError excpectedError, uint expectedChildResultCount, Type expectedLastChildResultType) { Assert.AreEqual(expectedResultCode, result.ResultCode, "Unexpected verification result code."); if (expectedResultCode != VerificationResultCode.Ok) { Assert.AreEqual(excpectedError, result.VerificationError, "Unexpected verification error"); } Assert.AreEqual(expectedChildResultCount, result.ChildResults.Count, "Unexpected child result count."); Assert.AreEqual(expectedLastChildResultType.Name, result.ChildResults[result.ChildResults.Count - 1].RuleName, "Unexpected last child result rule."); }