Exemple #1
0
        public void CalcSignature_IgnoresCase()
        {
            // Example taken from the CloudStack documentation example
            const string input = "apiKey=plgwjfzk4gys3momtvmjuvg-x-jlwlnfauj9gabbbf9edm-kaymmailqzzq1elzlyq_u38zcm0bewzgudp66mg&command=listUsers&response=json";
            const string key   = "VDaACYb0LV9eNjTetIOElcVQkvJck_J_QljX_FcHRj87ZKiy0z0ty0ZsYBkoXkY9b7eq1EhwJaw7FF3akA3KBQ";

            string signature1 = CloudStackAPIProxy.CalcSignature(input, key);
            string signature2 = CloudStackAPIProxy.CalcSignature(input.ToLower(), key);

            signature2.ShouldBe(signature1, "CalcSignature did not internally perform ToLower");
        }
Exemple #2
0
        public void CalcSignature_CorrectlyCalculatesSignature()
        {
            // Example taken from the CloudStack documentation example
            const string input    = "apikey=plgwjfzk4gys3momtvmjuvg-x-jlwlnfauj9gabbbf9edm-kaymmailqzzq1elzlyq_u38zcm0bewzgudp66mg&command=listusers&response=json";
            const string key      = "VDaACYb0LV9eNjTetIOElcVQkvJck_J_QljX_FcHRj87ZKiy0z0ty0ZsYBkoXkY9b7eq1EhwJaw7FF3akA3KBQ";
            const string expected = "TTpdDq%2F7j%2FJ58XCRHomKoQXEQds%3D";

            string signature = CloudStackAPIProxy.CalcSignature(input, key);

            signature.ShouldBe(expected);
        }
Exemple #3
0
        public void CalcSignature_CorrectlyEncodesSignature()
        {
            // This results in a signature containing '+'.  This must be encoded to be understood!

            const string input    = "apikey=i-mcqzbmwigid0sohwvjk60pwxwmfc1wsenvzy1zpuou1ay-c66elwlnabeb5ylpf1f_uu_1peytzobumnll8g&command=listzones&response=json";
            const string key      = "bezaSxCEjrWxutJzRdJTStGl4nEWVUDx4YX9Q8DJo6kBiUXWfdq7P8z46zaWbQBeVMTu0YiP9tVbsjbG4QFV3g";
            const string expected = "RNlqbyJYiXMGYXI5g7%2B0zB6Y%2B5w%3D";     // Un-encoded form: RNlqbyJYiXMGYXI5g7+0zB6Y+5w=

            string signature = CloudStackAPIProxy.CalcSignature(input, key);

            signature.ShouldBe(expected);
        }