Beispiel #1
0
 public static TestFixture_WebServices   set_TM_Server(this TestFixture_WebServices tfWebServices, string websiteUrl = null)
 {
     tfWebServices.WebSite_Url = websiteUrl.valid()
                                         ? websiteUrl.uri()
                                         : tfWebServices.default_TM_Server();
     tfWebServices.webServices = new TM_WebServices_Configured(tfWebServices.WebSite_Url);
     return(tfWebServices);
 }
Beispiel #2
0
        public static HttpWebResponse           http_GET_WebResponse(this TestFixture_WebServices tfWebServices, string virtualPath)
        {
            var url        = tfWebServices.WebSite_Url.append(virtualPath);
            var webRequest = tfWebServices.webServices.getWebRequest_Configured(url);

            webRequest.AllowAutoRedirect = true;

            return(tfWebServices.webServices.getWebResponse());
        }
Beispiel #3
0
 public static string                    http_GET(this TestFixture_WebServices tfWebServices, string virtualPath)
 {
     if (tfWebServices.notNull() && virtualPath.valid())
     {
         var webResponse = tfWebServices.http_GET_WebResponse(virtualPath);
         var stream      = webResponse.GetResponseStream();
         return(stream.readToEnd());
     }
     return("");
 }
Beispiel #4
0
        public static Test_User                 login_As_Reader(this TestFixture_WebServices tfWebServices)
        {
            var readerUser = tfWebServices.QAConfig.testUser("qa-reader");
            var authToken  = readerUser.AuthToken;

            if (tfWebServices.webServices.login_with_AuthToken(authToken))
            {
                return(readerUser);
            }
            return(null);
        }
Beispiel #5
0
        public static Test_User                 login_As_Admin(this TestFixture_WebServices tfWebServices)
        {
            var adminUser = tfWebServices.QAConfig.testUser("qa-admin");
            var authToken = adminUser.AuthToken;

            if (tfWebServices.webServices.login_with_AuthToken(authToken))
            {
                return(adminUser);
            }
            return(null);
        }
Beispiel #6
0
        public static string                    http_METHOD(this TestFixture_WebServices tfWebServices, string method, string contentType, string virtualPath, string postData)
        {
            if (tfWebServices.notNull() && virtualPath.valid() && postData.valid())
            {
                var webResponse = tfWebServices.http_METHOD_WebResponse(method, contentType, virtualPath, postData);

                var stream = webResponse.GetResponseStream();
                return(stream.readToEnd());
            }
            return("");
        }
Beispiel #7
0
        public static HttpWebResponse           http_METHOD_WebResponse(this TestFixture_WebServices tfWebServices, string method, string contentType, string virtualPath, string postData)
        {
            var url        = tfWebServices.WebSite_Url.append(virtualPath);
            var webRequest = tfWebServices.webServices.getWebRequest_Configured(url);

            webRequest.AllowAutoRedirect = true;

            webRequest.Method      = method;
            webRequest.ContentType = contentType;

            var data = postData.asciiBytes();

            webRequest.ContentLength = data.Length;
            Stream myStream = webRequest.GetRequestStream();

            myStream.Write(data, 0, data.Length);
            myStream.Close();

            return(tfWebServices.webServices.getWebResponse());
        }
Beispiel #8
0
 public static Uri                       default_TM_Server(this TestFixture_WebServices tfWebServices)
 {
     return(tfWebServices.QAConfig.Url_Target_TM_Site.uri());
 }
Beispiel #9
0
 public static string                    http_PUT_JSON(this TestFixture_WebServices tfWebServices, string virtualPath, string postData)
 {
     return(tfWebServices.http_METHOD("PUT", "application/json", virtualPath, postData));
 }
Beispiel #10
0
 public static string                    http_PUT(this TestFixture_WebServices tfWebServices, string virtualPath, string postData)
 {
     return(tfWebServices.http_METHOD("PUT", "x-www-form-urlencoded", virtualPath, postData));
 }