当前位置: 首页>>代码示例>>C#>>正文


C# TestContext.AssertFail方法代码示例

本文整理汇总了C#中TestContext.AssertFail方法的典型用法代码示例。如果您正苦于以下问题:C# TestContext.AssertFail方法的具体用法?C# TestContext.AssertFail怎么用?C# TestContext.AssertFail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestContext的用法示例。


在下文中一共展示了TestContext.AssertFail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetParameters

		public static IEnumerable<CipherInstrumentParameters> GetParameters (TestContext ctx, InstrumentationCategory category)
		{
			switch (category) {
			case InstrumentationCategory.SelectClientCipher:
				return SelectAllCiphers ((protocol, cipher) => {
					var parameters = CreateParameters (category, CipherInstrumentType.SelectClientCipher, protocol, cipher);
					parameters.ProtocolVersion = protocol;
					parameters.ClientCiphers = new CipherSuiteCode[] { cipher };
					parameters.ExpectedClientCipher = cipher;
					return parameters;
				});

			case InstrumentationCategory.SelectServerCipher:
				return SelectAllCiphers ((protocol, cipher) => {
					var parameters = CreateParameters (category, CipherInstrumentType.SelectServerCipher, protocol, cipher);
					parameters.ProtocolVersion = protocol;
					parameters.ServerCiphers = new CipherSuiteCode[] { cipher };
					parameters.ExpectedServerCipher = cipher;
					return parameters;
				});

			case InstrumentationCategory.SelectCipher:
				return ConnectionTypes.Select (t => Create (ctx, category, t));

			default:
				ctx.AssertFail ("Unsupported instrumentation category: '{0}'.", category);
				return null;
			}
		}
开发者ID:modulexcite,项目名称:mono-tls,代码行数:29,代码来源:CipherInstrumentTestRunner.cs

示例2: GetParameters

		public static IEnumerable<CipherInstrumentParameters> GetParameters (TestContext ctx, InstrumentationCategory category)
		{
			switch (category) {
			case InstrumentationCategory.SelectClientCipher:
				return SelectClientCipherTypes.Select (t => Create (ctx, category, t));

			case InstrumentationCategory.SelectServerCipher:
				return SelectServerCipherTypes.Select (t => Create (ctx, category, t));

			case InstrumentationCategory.SelectCipher:
				return ConnectionTypes.Select (t => Create (ctx, category, t));

			default:
				ctx.AssertFail ("Unsupported instrumentation category: '{0}'.", category);
				return null;
			}
		}
开发者ID:VimalKumarS,项目名称:mono-tls,代码行数:17,代码来源:CipherInstrumentTestRunner.cs

示例3: GetConnectionFlags

		public static MonoConnectionFlags GetConnectionFlags (TestContext ctx, InstrumentationCategory category)
		{
			switch (category) {
			case InstrumentationCategory.AllClientSignatureAlgorithms:
			case InstrumentationCategory.ClientSignatureParameters:
			case InstrumentationCategory.ClientConnection:
				return MonoConnectionFlags.ClientInstrumentation;
			case InstrumentationCategory.AllServerSignatureAlgorithms:
			case InstrumentationCategory.ServerSignatureParameters:
			case InstrumentationCategory.ServerConnection:
				return MonoConnectionFlags.ServerInstrumentation;
			case InstrumentationCategory.SignatureAlgorithms:
			case InstrumentationCategory.Connection:
				return MonoConnectionFlags.ClientInstrumentation | MonoConnectionFlags.ServerInstrumentation;
			case InstrumentationCategory.MartinTest:
				return MonoConnectionFlags.ServerInstrumentation | MonoConnectionFlags.ClientInstrumentation;
			default:
				ctx.AssertFail ("Unsupported instrumentation category: '{0}'.", category);
				return MonoConnectionFlags.None;
			}
		}
开发者ID:peterdocter,项目名称:mono-tls,代码行数:21,代码来源:InstrumentationTestRunner.cs

示例4: GetParameters

		public static IEnumerable<SimpleConnectionParameters> GetParameters (TestContext ctx, InstrumentationCategory category)
		{
			switch (category) {
			case InstrumentationCategory.SimpleMonoClient:
				return ClientConnectionTypes.Select (t => Create (ctx, category, t));

			case InstrumentationCategory.SimpleMonoServer:
				return ServerConnectionTypes.Select (t => Create (ctx, category, t));

			case InstrumentationCategory.SimpleMonoConnection:
				return ConnectionTypes.Select (t => Create (ctx, category, t));

			case InstrumentationCategory.MonoProtocolVersions:
				return AllVersionTypes.Select (t => Create (ctx, category, t));

			case InstrumentationCategory.MartinTest:
				return MartinTestTypes.Select (t => Create (ctx, category, t));

			default:
				ctx.AssertFail ("Unsupported connection category: '{0}'.", category);
				return null;
			}
		}
开发者ID:modulexcite,项目名称:mono-tls,代码行数:23,代码来源:SimpleConnectionTestRunner.cs

示例5: GetParameters

		public static IEnumerable<SignatureInstrumentParameters> GetParameters (TestContext ctx, InstrumentationCategory category)
		{
			switch (category) {
			case InstrumentationCategory.AllClientSignatureAlgorithms:
				return SelectAlgorithmsAndCiphers (SignatureInstrumentType.ClientSignatureAlgorithmAndCipher).Select (t => Create (ctx, category, t.Item1, t.Item2, t.Item3));

			case InstrumentationCategory.AllServerSignatureAlgorithms:
				return SelectAlgorithmsAndCiphers (SignatureInstrumentType.ServerSignatureAlgorithmAndCipher).Select (t => Create (ctx, category, t.Item1, t.Item2, t.Item3));

			case InstrumentationCategory.ClientSignatureParameters:
				return ClientSignatureParameterTypes.Select (t => Create (ctx, category, t));

			case InstrumentationCategory.ServerSignatureParameters:
				return ServerSignatureParameterTypes.Select (t => Create (ctx, category, t));

			case InstrumentationCategory.SignatureAlgorithms:
				return SignatureParameterTypes.Select (t => Create (ctx, category, t));

			default:
				ctx.AssertFail ("Unsupported instrumentation category: '{0}'.", category);
				return null;
			}
		}
开发者ID:modulexcite,项目名称:mono-tls,代码行数:23,代码来源:SignatureInstrumentTestRunner.cs

示例6: TestDecryptWithInvalidPadding2

		public void TestDecryptWithInvalidPadding2 (TestContext ctx, [TestHost] IEncryptionTestHost host)
		{
			var input = GetBuffer (Data11Result);

			var modified = new TlsBuffer (input.Size);
			modified.Write (input.Buffer);

			// Flip a bit in the last byte, this will affect the padding size.
			modified.Buffer [modified.Size - 1] ^= 0x01;

			input = new BufferOffsetSize (modified.Buffer, 0, modified.Size);

			try {
				host.Decrypt (input);
				ctx.AssertFail ("#1");
			} catch (Exception ex) {
				ctx.Assert (ex, Is.InstanceOf<TlsException> (), "#2");
				var tlsEx = (TlsException)ex;
				ctx.Assert (tlsEx.Alert.Level, Is.EqualTo (AlertLevel.Fatal), "#3");
				ctx.Assert (tlsEx.Alert.Description, Is.EqualTo (AlertDescription.BadRecordMAC), "#4");
			}
		}
开发者ID:VimalKumarS,项目名称:mono-tls,代码行数:22,代码来源:TestCbcBlockCipher.cs

示例7: Create

		static SimpleConnectionParameters Create (TestContext ctx, InstrumentationCategory category, SimpleConnectionType type)
		{
			var parameters = CreateParameters (category, type);

			var provider = DependencyInjector.Get<ICertificateProvider> ();
			var acceptSelfSigned = provider.AcceptThisCertificate (ResourceManager.SelfSignedServerCertificate);
			var acceptFromCA = provider.AcceptFromCA (ResourceManager.LocalCACertificate);

			switch (type) {
			case SimpleConnectionType.Simple:
				break;

			case SimpleConnectionType.ValidateCertificate:
				parameters.ServerParameters.ServerCertificate = ResourceManager.ServerCertificateFromCA;
				parameters.ClientCertificateValidator = acceptFromCA;
				break;

			case SimpleConnectionType.CheckDefaultCipher:
				parameters.ExpectedCipher = CipherSuiteCode.TLS_DHE_RSA_WITH_AES_256_GCM_SHA384;
				break;

			case SimpleConnectionType.SimpleTls10:
				parameters.ProtocolVersion = ProtocolVersions.Tls10;
				parameters.ExpectedCipher = CipherSuiteCode.TLS_DHE_RSA_WITH_AES_256_CBC_SHA;
				break;

			case SimpleConnectionType.SimpleTls11:
				parameters.ProtocolVersion = ProtocolVersions.Tls11;
				parameters.ExpectedCipher = CipherSuiteCode.TLS_DHE_RSA_WITH_AES_256_CBC_SHA;
				break;

			case SimpleConnectionType.SimpleTls12:
				parameters.ProtocolVersion = ProtocolVersions.Tls12;
				parameters.ExpectedCipher = CipherSuiteCode.TLS_DHE_RSA_WITH_AES_256_GCM_SHA384;
				break;

			case SimpleConnectionType.SelectCiphersTls10:
				parameters.ProtocolVersion = ProtocolVersions.Tls10;
				break;

			case SimpleConnectionType.SelectCiphersTls11:
				parameters.ProtocolVersion = ProtocolVersions.Tls11;
				break;

			case SimpleConnectionType.SelectCiphersTls12:
				parameters.ProtocolVersion = ProtocolVersions.Tls12;
				break;

			case SimpleConnectionType.RequestClientCertificate:
				/*
				 * Request client certificate, but do not require it.
				 *
				 * FIXME:
				 * SslStream with Mono's old implementation fails here.
				 */
				parameters.ClientCertificate = ResourceManager.MonkeyCertificate;
				parameters.ClientCertificateValidator = acceptSelfSigned;
				parameters.ServerFlags = ServerFlags.AskForClientCertificate;
				parameters.ServerCertificateValidator = acceptFromCA;
				break;

			case SimpleConnectionType.RequireClientCertificateRSA:
				/*
				 * Require client certificate.
				 *
				 */
				parameters.ClientCertificate = ResourceManager.MonkeyCertificate;
				parameters.ClientCertificateValidator = acceptSelfSigned;
				parameters.ServerFlags = ServerFlags.RequireClientCertificate;
				parameters.ServerCertificateValidator = acceptFromCA;
				parameters.ServerCiphers = new CipherSuiteCode[] { CipherSuiteCode.TLS_RSA_WITH_AES_128_CBC_SHA };
				break;

			case SimpleConnectionType.RequireClientCertificateDHE:
				/*
				 * Require client certificate.
				 *
				 */
				parameters.ClientCertificate = ResourceManager.MonkeyCertificate;
				parameters.ClientCertificateValidator = acceptSelfSigned;
				parameters.ServerFlags = ServerFlags.RequireClientCertificate;
				parameters.ServerCertificateValidator = acceptFromCA;
				parameters.ServerCiphers = new CipherSuiteCode[] { CipherSuiteCode.TLS_DHE_RSA_WITH_AES_256_CBC_SHA };
				break;

			case SimpleConnectionType.MartinTest:
				break;

			default:
				ctx.AssertFail ("Unsupported connection type: '{0}'.", type);
				break;
			}

			return parameters;
		}
开发者ID:modulexcite,项目名称:mono-tls,代码行数:95,代码来源:SimpleConnectionTestRunner.cs

示例8: GetTestTypes

		public static IEnumerable<SimpleConnectionType> GetTestTypes (TestContext ctx, InstrumentationCategory category)
		{
			switch (category) {
			case InstrumentationCategory.SimpleMonoClient:
				yield return SimpleConnectionType.SimpleTls10;
				yield return SimpleConnectionType.SimpleTls11;
				yield return SimpleConnectionType.SimpleTls12;
				yield break;

			case InstrumentationCategory.SimpleMonoServer:
				yield return SimpleConnectionType.SimpleTls10;
				yield return SimpleConnectionType.SimpleTls11;
				yield return SimpleConnectionType.SimpleTls12;
				yield break;

			case InstrumentationCategory.SimpleMonoConnection:
				yield return SimpleConnectionType.SimpleTls10;
				yield return SimpleConnectionType.SimpleTls11;
				yield return SimpleConnectionType.SimpleTls12;
				yield return SimpleConnectionType.CipherSelectionOrder;
				yield return SimpleConnectionType.CipherSelectionOrder2;
				yield break;

			case InstrumentationCategory.MonoProtocolVersions:
				yield return SimpleConnectionType.Simple;
				yield return SimpleConnectionType.ValidateCertificate;
				yield return SimpleConnectionType.RequestClientCertificate;
				yield return SimpleConnectionType.RequireClientCertificateRSA;
				yield return SimpleConnectionType.RequireClientCertificateDHE;
				yield break;

			case InstrumentationCategory.MartinTest:
				yield return SimpleConnectionType.MartinTest;
				yield break;

			default:
				ctx.AssertFail ("Unspported connection category: '{0}.", category);
				yield break;
			}
		}
开发者ID:VimalKumarS,项目名称:mono-tls,代码行数:40,代码来源:SimpleConnectionTestRunner.cs

示例9: Create


//.........这里部分代码省略.........
			case SignatureInstrumentType.VerifyClientSignatureAlgorithms:
				parameters.ExpectClientAlert = AlertDescription.IlegalParameter;
				goto case SignatureInstrumentType.ClientProvidesSomeUnsupportedSignatureAlgorithms;

			case SignatureInstrumentType.ClientProvidesSomeUnsupportedSignatureAlgorithms:
				parameters.ClientSignatureParameters = new SignatureParameters ();
				parameters.ClientSignatureParameters.Add (HashAlgorithmType.Sha1, SignatureAlgorithmType.Dsa);
				parameters.ClientSignatureParameters.Add (HashAlgorithmType.Unknown, SignatureAlgorithmType.Unknown);
				parameters.ClientSignatureParameters.Add (HashAlgorithmType.Sha256, SignatureAlgorithmType.Rsa);
				parameters.ClientCiphers = new CipherSuiteCode[] { CipherSuiteCode.TLS_DHE_RSA_WITH_AES_128_CBC_SHA };
				break;

			case SignatureInstrumentType.ClientProvidesNoSupportedSignatureAlgorithms:
				parameters.ClientSignatureParameters = new SignatureParameters ();
				parameters.ClientSignatureParameters.Add (HashAlgorithmType.Unknown, SignatureAlgorithmType.Dsa);
				parameters.ExpectServerSignatureAlgorithm = new SignatureAndHashAlgorithm (HashAlgorithmType.Sha1);
				parameters.ClientCiphers = new CipherSuiteCode[] { CipherSuiteCode.TLS_DHE_RSA_WITH_AES_128_CBC_SHA };
				parameters.ExpectServerAlert = AlertDescription.IlegalParameter;
				break;

			case SignatureInstrumentType.Tls10WithRsaExchange:
				parameters.ClientCiphers = parameters.ServerCiphers = new CipherSuiteCode[] { CipherSuiteCode.TLS_RSA_WITH_AES_256_CBC_SHA };
				parameters.ProtocolVersion = ProtocolVersions.Tls10;
				break;

			case SignatureInstrumentType.Tls10WithDheExchange:
				parameters.ClientCiphers = parameters.ServerCiphers = new CipherSuiteCode[] { CipherSuiteCode.TLS_DHE_RSA_WITH_AES_128_CBC_SHA };
				parameters.ProtocolVersion = ProtocolVersions.Tls10;
				break;

			case SignatureInstrumentType.ServerUsesUnsupportedSignatureAlgorithm:
				parameters.ClientCiphers = new CipherSuiteCode[] { CipherSuiteCode.TLS_DHE_RSA_WITH_AES_128_CBC_SHA };
				parameters.ClientSignatureParameters = new SignatureParameters ();
				parameters.ClientSignatureParameters.Add (HashAlgorithmType.Sha384);
				parameters.ServerSignatureAlgorithm = new SignatureAndHashAlgorithm (HashAlgorithmType.Sha512);
				parameters.ExpectClientAlert = AlertDescription.IlegalParameter;
				break;

			case SignatureInstrumentType.ServerUsesUnsupportedSignatureAlgorithm2:
				// MD5SHA1 is never allowed for TLS 1.2.
				parameters.ClientCiphers = new CipherSuiteCode[] { CipherSuiteCode.TLS_DHE_RSA_WITH_AES_128_CBC_SHA };
				parameters.ClientSignatureParameters = new SignatureParameters ();
				parameters.ClientSignatureParameters.Add (HashAlgorithmType.Sha1);
				// we'd normally not be allowed to request this from user settings, but there's an instrumentation override
				// in place for this test.
				parameters.ClientSignatureParameters.Add (HashAlgorithmType.Md5Sha1);
				// Instrumentation override lets us force set this.
				parameters.ServerSignatureAlgorithm = new SignatureAndHashAlgorithm (HashAlgorithmType.Md5Sha1);
				parameters.ExpectClientAlert = AlertDescription.IlegalParameter;
				parameters.ProtocolVersion = ProtocolVersions.Tls12;
				break;

			case SignatureInstrumentType.ServerSendsCertificateParametersWithoutAlgorithms:
				parameters.ServerCertificateParameters = new ClientCertificateParameters ();
				parameters.ExpectCertificateVerifySignatureAlgorithm = SignatureParameters.DefaultAlgorithm;
				break;

			case SignatureInstrumentType.ServerSendsCertificateParametersWithSomeUnsupportedAlgorithms:
				parameters.ServerCertificateParameters = new ClientCertificateParameters ();
				parameters.ServerCertificateParameters.SignatureParameters.Add (HashAlgorithmType.Unknown);
				parameters.ServerCertificateParameters.SignatureParameters.Add (HashAlgorithmType.Sha384);
				parameters.ExpectCertificateVerifySignatureAlgorithm = new SignatureAndHashAlgorithm (HashAlgorithmType.Sha384);
				break;

			case SignatureInstrumentType.ServerSendsCertificateParametersWithNoSupportedAlgorithms:
				parameters.ServerCertificateParameters = new ClientCertificateParameters ();
				parameters.ServerCertificateParameters.SignatureParameters.Add (HashAlgorithmType.Unknown);
				parameters.ExpectCertificateVerifySignatureAlgorithm = SignatureParameters.DefaultAlgorithm;
				parameters.ExpectClientAlert = AlertDescription.IlegalParameter;
				break;

			case SignatureInstrumentType.ClientSendsCertificateVerifyWithUnrequestedAlgorithm:
				parameters.ServerCertificateParameters = new ClientCertificateParameters ();
				parameters.ServerCertificateParameters.SignatureParameters.Add (HashAlgorithmType.Sha384);
				parameters.ServerCertificateParameters.SignatureParameters.Add (HashAlgorithmType.Sha512);
				parameters.ClientSignatureAlgorithm = new SignatureAndHashAlgorithm (HashAlgorithmType.Sha256);
				parameters.ExpectServerAlert = AlertDescription.IlegalParameter;
				break;

			case SignatureInstrumentType.CertificateVerifySignatureAlgorithmSelectionOrder:
				parameters.ServerCertificateParameters = new ClientCertificateParameters ();
				parameters.ServerCertificateParameters.SignatureParameters.Add (HashAlgorithmType.Sha384);
				parameters.ServerCertificateParameters.SignatureParameters.Add (HashAlgorithmType.Sha512);
				parameters.ExpectCertificateVerifySignatureAlgorithm = new SignatureAndHashAlgorithm (HashAlgorithmType.Sha384);
				break;

			case SignatureInstrumentType.CertificateVerifySignatureAlgorithmSelectionOrder2:
				parameters.ServerCertificateParameters = new ClientCertificateParameters ();
				parameters.ServerCertificateParameters.SignatureParameters.Add (HashAlgorithmType.Sha512);
				parameters.ServerCertificateParameters.SignatureParameters.Add (HashAlgorithmType.Sha384);
				parameters.ExpectCertificateVerifySignatureAlgorithm = new SignatureAndHashAlgorithm (HashAlgorithmType.Sha512);
				break;

			default:
				ctx.AssertFail ("Unsupported signature instrument: '{0}'.", type);
				break;
			}

			return parameters;
		}
开发者ID:VimalKumarS,项目名称:mono-tls,代码行数:101,代码来源:SignatureInstrumentTestRunner.cs

示例10: Create

		static ConnectionInstrumentParameters Create (TestContext ctx, InstrumentationCategory category, ConnectionInstrumentType type)
		{
			var parameters = CreateParameters (category, type);

			switch (type) {
			case ConnectionInstrumentType.FragmentHandshakeMessages:
				parameters.HandshakeInstruments = new HandshakeInstrumentType[] { HandshakeInstrumentType.FragmentHandshakeMessages };
				break;

			case ConnectionInstrumentType.SendBlobAfterReceivingFinish:
				parameters.HandshakeInstruments = new HandshakeInstrumentType[] { HandshakeInstrumentType.SendBlobAfterReceivingFinish };
				break;

			case ConnectionInstrumentType.MartinTest:
				parameters.RequestRenegotiation = true;
				parameters.EnableDebugging = true;
				break;

			default:
				ctx.AssertFail ("Unsupported connection instrument: '{0}'.", type);
				break;
			}

			return parameters;
		}
开发者ID:peterdocter,项目名称:mono-tls,代码行数:25,代码来源:ConnectionInstrumentTestRunner.cs

示例11: GetInstrumentationTypes

		public static IEnumerable<GenericConnectionInstrumentType> GetInstrumentationTypes (TestContext ctx, InstrumentationCategory category)
		{
			switch (category) {
			case InstrumentationCategory.ClientConnection:
				yield return GenericConnectionInstrumentType.FragmentHandshakeMessages;
				yield return GenericConnectionInstrumentType.SendBlobAfterReceivingFinish;
				yield return GenericConnectionInstrumentType.InvalidClientCertificateV1;
				break;

			case InstrumentationCategory.ServerConnection:
				yield return GenericConnectionInstrumentType.FragmentHandshakeMessages;
				yield return GenericConnectionInstrumentType.InvalidServerCertificateV1;
				yield return GenericConnectionInstrumentType.InvalidServerCertificateRsa512;
				break;

			case InstrumentationCategory.Connection:
				yield return GenericConnectionInstrumentType.FragmentHandshakeMessages;
				yield return GenericConnectionInstrumentType.ServerProvidesInvalidCertificate;
				yield return GenericConnectionInstrumentType.ClientProvidesInvalidCertificate;
				yield return GenericConnectionInstrumentType.RequireRsaKeyExchange;
				yield return GenericConnectionInstrumentType.RsaKeyExchangeNotAllowed;
				yield return GenericConnectionInstrumentType.RequireDheKeyExchange;
				yield return GenericConnectionInstrumentType.DheKeyExchangeNotAllowed;
				break;

			case InstrumentationCategory.CertificateChecks:
				yield return GenericConnectionInstrumentType.InvalidServerCertificateV1;
				yield return GenericConnectionInstrumentType.InvalidServerCertificateRsa512;
				yield return GenericConnectionInstrumentType.InvalidClientCertificateV1;
				yield return GenericConnectionInstrumentType.InvalidServerCertificateRsa512;
				yield return GenericConnectionInstrumentType.ServerProvidesInvalidCertificate;
				yield return GenericConnectionInstrumentType.ClientProvidesInvalidCertificate;
				yield return GenericConnectionInstrumentType.RequireRsaKeyExchange;
				yield return GenericConnectionInstrumentType.RsaKeyExchangeNotAllowed;
				yield return GenericConnectionInstrumentType.RequireDheKeyExchange;
				yield return GenericConnectionInstrumentType.DheKeyExchangeNotAllowed;
				yield return GenericConnectionInstrumentType.ClientCertificateInvalidForRsa;
				yield return GenericConnectionInstrumentType.ClientProvidesCertificateThatsInvalidForRsa;
				yield return GenericConnectionInstrumentType.ClientCertificateInvalidForDhe;
				yield return GenericConnectionInstrumentType.ClientProvidesCertificateThatsInvalidForDhe;
				yield return GenericConnectionInstrumentType.ClientCertificateRequiresRsaKeyExchange;
				yield return GenericConnectionInstrumentType.ClientCertificateRequiresDheKeyExchange;
				break;

			case InstrumentationCategory.MartinTest:
				yield return GenericConnectionInstrumentType.MartinTest;
				break;

			default:
				ctx.AssertFail ("Unsupported instrumentation category: '{0}'.", category);
				break;
			}
		}
开发者ID:VimalKumarS,项目名称:mono-tls,代码行数:53,代码来源:GenericConnectionInstrumentTestRunner.cs

示例12: Create

		static CipherInstrumentParameters Create (TestContext ctx, InstrumentationCategory category, CipherInstrumentType type)
		{
			var parameters = CreateParameters (category, type);

			switch (type) {
			case CipherInstrumentType.InvalidCipher:
				parameters.ServerCiphers = new CipherSuiteCode[] { CipherSuiteCode.TLS_DHE_RSA_WITH_AES_128_CBC_SHA };
				parameters.ClientCiphers = new CipherSuiteCode[] { CipherSuiteCode.TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 };
				parameters.ProtocolVersion = ProtocolVersions.Tls12;
				parameters.ExpectServerAlert = AlertDescription.HandshakeFailure;
				break;

			default:
				ctx.AssertFail ("Unsupported cipher instrument: '{0}'.", type);
				break;
			}

			return parameters;
		}
开发者ID:modulexcite,项目名称:mono-tls,代码行数:19,代码来源:CipherInstrumentTestRunner.cs

示例13: Create


//.........这里部分代码省略.........
				parameters.ServerCiphers = new CipherSuiteCode[] { CipherSuiteCode.TLS_RSA_WITH_AES_128_CBC_SHA };
				parameters.ExpectServerAlert = AlertDescription.HandshakeFailure;
				break;

			case GenericConnectionInstrumentType.RequireDheKeyExchange:
				parameters.ProtocolVersion = ProtocolVersions.Tls12;
				parameters.ServerCertificate = ResourceManager.ServerCertificateDheOnly;
				parameters.ClientCiphers = new CipherSuiteCode[] {
					CipherSuiteCode.TLS_RSA_WITH_AES_128_CBC_SHA, CipherSuiteCode.TLS_DHE_RSA_WITH_AES_128_CBC_SHA
				};
				parameters.ExpectedServerCipher = CipherSuiteCode.TLS_DHE_RSA_WITH_AES_128_CBC_SHA;
				break;

			case GenericConnectionInstrumentType.DheKeyExchangeNotAllowed:
				parameters.ProtocolVersion = ProtocolVersions.Tls12;
				parameters.ServerCertificate = ResourceManager.ServerCertificateRsaOnly;
				parameters.ServerCiphers = new CipherSuiteCode[] { CipherSuiteCode.TLS_DHE_RSA_WITH_AES_128_CBC_SHA };
				parameters.ExpectServerAlert = AlertDescription.HandshakeFailure;
				break;

			case GenericConnectionInstrumentType.MartinClientPuppy:
			case GenericConnectionInstrumentType.MartinServerPuppy:
				goto case GenericConnectionInstrumentType.MartinTest;

			case GenericConnectionInstrumentType.ClientCertificateRequiresRsaKeyExchange:
				parameters.ServerCertificate = ResourceManager.ServerCertificateRsaOnly;
				parameters.ClientCiphers = new CipherSuiteCode[] { CipherSuiteCode.TLS_RSA_WITH_AES_128_CBC_SHA };
				parameters.ClientCertificate = ResourceManager.ClientCertificateRsaOnly;
				parameters.RequireClientCertificate = true;
				parameters.ClientCertificateValidator = AcceptAnyCertificate;
				parameters.ServerCertificateValidator = AcceptAnyCertificate;
				break;

			case GenericConnectionInstrumentType.ClientCertificateRequiresDheKeyExchange:
				parameters.ServerCertificate = ResourceManager.ServerCertificateDheOnly;
				parameters.ClientCiphers = new CipherSuiteCode[] { CipherSuiteCode.TLS_DHE_RSA_WITH_AES_128_CBC_SHA };
				parameters.ClientCertificate = ResourceManager.ClientCertificateDheOnly;
				parameters.RequireClientCertificate = true;
				parameters.ClientCertificateValidator = AcceptAnyCertificate;
				parameters.ServerCertificateValidator = AcceptAnyCertificate;
				break;

			case GenericConnectionInstrumentType.ClientCertificateInvalidForRsa:
				parameters.ServerCertificate = ResourceManager.ServerCertificateRsaOnly;
				parameters.ClientCiphers = new CipherSuiteCode[] { CipherSuiteCode.TLS_RSA_WITH_AES_128_CBC_SHA };
				parameters.ClientCertificate = ResourceManager.ClientCertificateDheOnly;
				parameters.RequireClientCertificate = true;
				parameters.ClientCertificateValidator = AcceptAnyCertificate;
				parameters.ServerCertificateValidator = AcceptAnyCertificate;
				parameters.ExpectClientAlert = AlertDescription.UnsupportedCertificate;
				break;

			case GenericConnectionInstrumentType.ClientCertificateInvalidForDhe:
				parameters.ServerCertificate = ResourceManager.ServerCertificateDheOnly;
				parameters.ClientCiphers = new CipherSuiteCode[] { CipherSuiteCode.TLS_DHE_RSA_WITH_AES_128_CBC_SHA };
				parameters.ClientCertificate = ResourceManager.ClientCertificateRsaOnly;
				parameters.RequireClientCertificate = true;
				parameters.ClientCertificateValidator = AcceptAnyCertificate;
				parameters.ServerCertificateValidator = AcceptAnyCertificate;
				parameters.ExpectClientAlert = AlertDescription.UnsupportedCertificate;
				break;

			case GenericConnectionInstrumentType.ClientProvidesCertificateThatsInvalidForRsa:
				parameters.ServerCertificate = ResourceManager.ServerCertificateRsaOnly;
				parameters.ClientCiphers = new CipherSuiteCode[] { CipherSuiteCode.TLS_RSA_WITH_AES_128_CBC_SHA };
				parameters.ClientCertificate = ResourceManager.ClientCertificateDheOnly;
				parameters.RequireClientCertificate = true;
				parameters.ClientCertificateValidator = AcceptAnyCertificate;
				parameters.ServerCertificateValidator = AcceptAnyCertificate;
				parameters.ExpectServerAlert = AlertDescription.UnsupportedCertificate;
				parameters.Add (HandshakeInstrumentType.OverrideClientCertificateSelection);
				break;

			case GenericConnectionInstrumentType.ClientProvidesCertificateThatsInvalidForDhe:
				parameters.ServerCertificate = ResourceManager.ServerCertificateDheOnly;
				parameters.ClientCiphers = new CipherSuiteCode[] { CipherSuiteCode.TLS_DHE_RSA_WITH_AES_128_CBC_SHA };
				parameters.ClientCertificate = ResourceManager.ClientCertificateRsaOnly;
				parameters.RequireClientCertificate = true;
				parameters.ClientCertificateValidator = AcceptAnyCertificate;
				parameters.ServerCertificateValidator = AcceptAnyCertificate;
				parameters.ExpectServerAlert = AlertDescription.UnsupportedCertificate;
				parameters.Add (HandshakeInstrumentType.OverrideClientCertificateSelection);
				break;

			case GenericConnectionInstrumentType.MartinTest:
				parameters.ClientCiphers = parameters.ServerCiphers = new CipherSuiteCode[] {
					CipherSuiteCode.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
				};
				break;

			default:
				ctx.AssertFail ("Unsupported connection instrument: '{0}'.", type);
				break;
			}

			if (parameters.ExpectClientAlert != null || parameters.ExpectServerAlert != null)
				parameters.Add (HandshakeInstrumentType.DontSendAlerts);

			return parameters;
		}
开发者ID:VimalKumarS,项目名称:mono-tls,代码行数:101,代码来源:GenericConnectionInstrumentTestRunner.cs

示例14: TestDecryptWithInvalidPadding

		public void TestDecryptWithInvalidPadding (TestContext ctx, [TestHost] IEncryptionTestHost host)
		{
			var input = GetBuffer (ExtraPaddingResult);

			var modified = new TlsBuffer (input.Size);
			modified.Write (input.Buffer);

			var theOffset = modified.Size - (2 * host.BlockSize) - 5;
			modified.Buffer [theOffset] ^= 0x01;

			input = new BufferOffsetSize (modified.Buffer, 0, modified.Size);

			try {
				host.Decrypt (input);
				ctx.AssertFail ("#1");
			} catch (Exception ex) {
				ctx.Assert (ex, Is.InstanceOf<TlsException> (), "#2");
				var tlsEx = (TlsException)ex;
				ctx.Assert (tlsEx.Alert.Level, Is.EqualTo (AlertLevel.Fatal), "#3");
				ctx.Assert (tlsEx.Alert.Description, Is.EqualTo (AlertDescription.BadRecordMAC), "#4");
			}
		}
开发者ID:VimalKumarS,项目名称:mono-tls,代码行数:22,代码来源:TestCbcBlockCipher.cs

示例15: GetInstrumentationTypes

		public static IEnumerable<RenegotiationInstrumentType> GetInstrumentationTypes (TestContext ctx, InstrumentationCategory category)
		{
			switch (category) {
			case InstrumentationCategory.ClientRenegotiation:
				yield return RenegotiationInstrumentType.RequestClientRenegotiation;
				break;

			case InstrumentationCategory.ServerRenegotiation:
				yield return RenegotiationInstrumentType.RequestRenegotiation;
				yield return RenegotiationInstrumentType.SendBlobBeforeHelloRequest;
				yield return RenegotiationInstrumentType.SendBlobAfterHelloRequest;
				yield return RenegotiationInstrumentType.SendBlobBeforeAndAfterHelloRequest;
				yield return RenegotiationInstrumentType.SendDuplicateHelloRequest;
				yield return RenegotiationInstrumentType.RequestServerRenegotiation;
				yield return RenegotiationInstrumentType.RequestServerRenegotiationWithPendingRead;
				break;

			case InstrumentationCategory.Renegotiation:
				yield return RenegotiationInstrumentType.SendBlobBeforeRenegotiatingHello;
				yield return RenegotiationInstrumentType.SendBlobBeforeRenegotiatingHelloNoPendingRead;
				yield return RenegotiationInstrumentType.RequestClientRenegotiationWithPendingWrite;
				break;

			case InstrumentationCategory.MartinTest:
			case InstrumentationCategory.MartinTestClient:
			case InstrumentationCategory.MartinTestServer:
				yield return RenegotiationInstrumentType.MartinTest;
				break;

			default:
				ctx.AssertFail ("Unsupported instrumentation category: '{0}'.", category);
				break;
			}
		}
开发者ID:VimalKumarS,项目名称:mono-tls,代码行数:34,代码来源:RenegotiationInstrumentTestRunner.cs


注:本文中的TestContext.AssertFail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。