bool ExpectChainItem(TestContext ctx, BtlsX509Chain nativeChain, int index) { using (var item = nativeChain[index]) { var expected = ResourceManager.GetCertificateInfo(Parameters.ExpectedChain[index]); return(ctx.Expect(item.GetCertHash(), Is.EqualTo(expected.Hash), "chain item " + index)); } }
protected override void PreRun(TestContext ctx) { base.PreRun(ctx); store = BtlsProvider.CreateNativeStore(); if (Parameters.AddTrustedRoots) { store.AddTrustedRoots(); } AddTrustedRoots(ctx); chain = BtlsProvider.CreateNativeChain(); SetupChain(ctx); storeCtx = BtlsProvider.CreateNativeStoreCtx(); storeCtx.Initialize(store, chain); verifyParam = SetupVerifyParameters(ctx); if (Parameters.CheckTime != null) { verifyParam.SetTime(Parameters.CheckTime.Value); } if (Parameters.Host != null) { verifyParam.SetHost(Parameters.Host); } if (verifyParam != null) { storeCtx.SetVerifyParam(verifyParam); } }
public Task Initialize(TestContext ctx, CancellationToken cancellationToken) { return(Task.Run(() => { chain = BtlsProvider.CreateNativeChain(); PopulateChain(ctx); })); }
public Task Destroy(TestContext ctx, CancellationToken cancellationToken) { return(Task.Run(() => { if (chain != null) { chain.Dispose(); chain = null; } })); }
bool ExpectNativeChain(TestContext ctx, BtlsX509Chain nativeChain) { bool ok = true; if (Parameters.ExpectedChain != null) { ok &= ctx.Expect(nativeChain.Count, Is.EqualTo(Parameters.ExpectedChain.Count), "chain length"); if (ok) { for (int i = 0; i < nativeChain.Count; i++) { ok &= ExpectChainItem(ctx, nativeChain, i); } } } return(ok); }
protected override void PostRun(TestContext ctx) { if (verifyParam != null) { verifyParam.Dispose(); verifyParam = null; } if (storeCtx != null) { storeCtx.Dispose(); storeCtx = null; } if (chain != null) { chain.Dispose(); chain = null; } if (store != null) { store.Dispose(); store = null; } base.PostRun(ctx); }