예제 #1
0
        public void QueryStringTest()
        {
            var queryString = @"?aa=aa&aa%3Daa=&aa=aa%3D&aa=&aa=aaa&aaa=aaa&aaa=aa&aaa=a&ab=aa&ab=aa&cc=&cc=&bb=aa&bb=";

            var result = JDCloudSignerV3.ProcessQueryString(queryString);

            _output.WriteLine(result);
        }
예제 #2
0
        public void TestProcessQueryString()
        {
            string queryString = "? =blank&%20=blank&+= 2&%2b= 1&blank= &blank=+&blank=%20";
            string request     = JDCloudSignerV3.ProcessQueryString(queryString);

            _output.WriteLine(request);
            _output.WriteLine("%20=%202&%20=blank&%20=blank&%2B=%201&blank=%20&blank=%20&blank=%20");
            Assert.Equal("%20=%202&%20=blank&%20=blank&%2B=%201&blank=%20&blank=%20&blank=%20", request);
        }
예제 #3
0
        public void TestSignCase()
        {
            List <TestCaseModel> readCaseExcel = GetTestCase();

            if (readCaseExcel != null && readCaseExcel.Count > 0)
            {
                WriteJsonFile(readCaseExcel);
            }

            IJDCloudSigner            jDCloudSigner       = new JDCloudSignerV3();
            List <SignedRequestModel> signedRequestModels = new List <SignedRequestModel>();
            StringBuilder             stringBuilder       = new StringBuilder();
            int i = 0;

            foreach (var item in readCaseExcel)
            {
                var result = jDCloudSigner.Sign(item.RequestModel, new Credentials("ak", "sk"));
                stringBuilder.Append(System.Environment.NewLine).
                Append("-------------------------------------------------------")
                .Append(System.Environment.NewLine)
                .Append(item.CaseName).
                Append(System.Environment.NewLine).
                Append("-------------------------------------------------------").Append(System.Environment.NewLine);
                //signedRequestModels.Add(result);
                stringBuilder.Append("MC:").Append(System.Environment.NewLine).Append(result.CanonicalRequest).Append(System.Environment.NewLine)
                .Append("SC:").Append(System.Environment.NewLine).Append(item.CanonicalRequest).Append(System.Environment.NewLine);

                stringBuilder.Append("MSH:").Append(System.Environment.NewLine).Append(result.SignedHeaders).Append(System.Environment.NewLine)
                .Append("SSH:").Append(System.Environment.NewLine).Append(item.Authorization).Append(System.Environment.NewLine);
                stringBuilder.Append(System.Environment.NewLine).Append("StringToSign:").Append(" ").Append(System.Environment.NewLine)
                .Append(result.StringToSign).Append(System.Environment.NewLine);
                if (result.SignedHeaders != item.Authorization)
                {
                    _output.WriteLine($"test case Authorization error, , case name is {item.CaseName}");
                }
                string filePath = Directory.GetCurrentDirectory() + "\\ TestCase.log";
                if (File.Exists(filePath))
                {
                    File.Delete(filePath);
                }

                using (FileStream fs = new FileStream(filePath, FileMode.Create))
                {
                    byte[] data = System.Text.Encoding.UTF8.GetBytes(stringBuilder.ToString());
                    fs.Write(data, 0, data.Length);
                    //清空缓冲区、关闭流
                    fs.Flush();
                    fs.Close();
                }
                i++;
            }
        }