public void should_get_exception_when_content_to_be_sign_is_null()
        {
            //given
            string content = null;
            //then
            AopException ex = Assert.Throws <AopException>(() => Encryptor.Sign(content, "UTF-8", RSA_PrivateKey));

            Assert.AreEqual(ex.Message.Contains("待签名内容不可为Null"), true);
        }
        public void should_get_exception_when_private_key_is_invalid()
        {
            //given
            string content    = "test";
            string privateKey = @"BLSi7EW+cBAfuuepOfANrWGt5jSwSkD+6nf6PsWH2R07ZwRFDD3S3G9RiYS0aR9tgY1nggfTP0lz2uiVgAYO4A8=";

            //then
            AopException ex = Assert.Throws <AopException>(() => Encryptor.Sign(content, "UTF-8", privateKey));

            Assert.AreEqual(ex.Message.Contains("签名遭遇异常,请检查私钥格式是否正确"), true);
        }
        public void should_get_exeception_when_call_normal_execuet()
        {
            //given
            IAopClient client = new DefaultAopClient(TestAccount.ProdCert.Gateway, TestAccount.ProdCert.AppId,
                                                     TestAccount.ProdCert.AppPrivateKey, "json", "1.0", "RSA2", "utf-8", false, TestAccount.ProdCert.CertParams);
            AlipayOpenOperationOpenbizmockBizQueryRequest request = GetRequest();

            //then
            AopException ex = Assert.Throws <AopException>(() => client.Execute(request));

            Assert.AreEqual(ex.Message.Contains("检测到证书相关参数已初始化,证书模式下请改为调用CertificateExecute。"), true);
        }
Esempio n. 4
0
        public void should_get_exception_when_call_cert_execute()
        {
            //given
            IAopClient client = new DefaultAopClient(TestAccount.Sandbox.Gateway, TestAccount.Sandbox.AppId,
                                                     TestAccount.Sandbox.AppPrivateKey, "json", "1.0", "RSA2", TestAccount.Sandbox.AlipayPublicKey, "utf-8", false);
            AlipayTradeCreateRequest request = getTradeCreateRequest();

            //then
            AopException ex = Assert.Throws <AopException>(() => client.CertificateExecute(request));

            Assert.AreEqual(ex.Message.Contains("检测到证书相关参数未初始化,非证书模式下请改为调用Execute"), true);
        }
Esempio n. 5
0
        public void should_get_exception_when_sign_not_match()
        {
            Dictionary <String, String> paramters = new Dictionary <string, string>
            {
                { "biz_content", "test" },
                { "charset", "UTF-8" },
                { "sign", "DFM24dXl9tfymSvZvmwcjutWWDoCwF2b/6CqUY2ZdShmnucUGxKqpmDF0m4lu5cm2AKx2KxvrfyOHrpZUBhX9i3YKqj0CV1jDjWBdcFI2gGnNQeShdqGGDhuHgtVeQE8cH/Q7LWSfrJ3EZqKyvCXsAX2GQ7SuhTPbIrq8mlflcIQHIUxUfoucc2F/vBdumwYQ3bT+2P4+7z89AFrPIDQ5A4dh1l3dkHbMTaJrFAz5bSvo5gqNyVV/TLts28HeHvAAYDfGP4eWm5knnh/3AulLdOkj0+m8L/YUR9tUMvNMSB6IJFF7keKq4s6qovfXPJYGZUNfuWKp9EJwDALGD53zg==" }
            };

            AopException ex = Assert.Throws <AopException>(() => AlipaySignature.CheckSignAndDecrypt(
                                                               paramters, TestAccount.Sandbox.AlipayPublicKey, TestAccount.Sandbox.AppPrivateKey, true, true, "RSA", false));

            Assert.AreEqual(ex.Message.Contains("rsaCheck failure"), true);
        }