diff --git a/TShockRestTestPlugin/Properties/AssemblyInfo.cs b/TShockRestTestPlugin/Properties/AssemblyInfo.cs deleted file mode 100644 index dfb6c9aa..00000000 --- a/TShockRestTestPlugin/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,54 +0,0 @@ -/* -TShock, a server mod for Terraria -Copyright (C) 2011-2016 Nyx Studios (fka. The TShock Team) - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("ClassLibrary1")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Multiplay")] -[assembly: AssemblyProduct("ClassLibrary1")] -[assembly: AssemblyCopyright("Copyright © Multiplay 2012")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("c6aed7ee-6282-49a2-8177-b79cad20d6d3")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/TShockRestTestPlugin/TShockRestTestPlugin.cs b/TShockRestTestPlugin/TShockRestTestPlugin.cs deleted file mode 100644 index 250ff087..00000000 --- a/TShockRestTestPlugin/TShockRestTestPlugin.cs +++ /dev/null @@ -1,210 +0,0 @@ -/* -TShock, a server mod for Terraria -Copyright (C) 2011-2016 Nyx Studios (fka. The TShock Team) - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Text; -using System.Web; -using System.Web.Script.Serialization; -using System.Text.RegularExpressions; -using Microsoft.VisualStudio.TestTools.WebTesting; -using Microsoft.VisualStudio.TestTools.WebTesting.Rules; -using Rests; - -namespace TshockRestTestPlugin -{ - [DisplayName("JSON Status")] - [Description("Checks to see the that the JSON response has the specified status response")] - public class JsonValidateStatus : JsonValidate - { - public override void Validate(object sender, ValidationEventArgs e) - { - if (null != ValidateJson(sender, e)) - e.IsValid = true; - } - } - - [DisplayName("JSON Regexp Property")] - [Description("Checks to see the that the JSON response contains the specified property and is matches the specified regexp")] - public class JsonValidateRegexpProperty : JsonValidateProperty - { - // The name of the desired JSON property - [DisplayName("Regexp")] - [DefaultValue(true)] - public new bool UseRegularExpression { get { return base.UseRegularExpression; } set { base.UseRegularExpression = value; } } - } - - [DisplayName("JSON Error")] - [Description("Checks to see the that the JSON response contains the specified error")] - public class JsonValidateError : JsonValidateProperty - { - // The status of the JSON request - [DisplayName("JSON Status")] - [DefaultValue("400")] - public new string JSonStatus { get { return base.JSonStatus; } set { base.JSonStatus = value; } } - - // The name of the desired JSON property - [DisplayName("Property")] - [DefaultValue("error")] - public new string PropertyName { get { return base.PropertyName; } set { base.PropertyName = value; } } - } - - [DisplayName("JSON Missing Parameter")] - [Description("Checks to see the that the JSON response indicates a missing or invalid parameter")] - public class JsonValidateMissingParameter : JsonValidateError - { - // The value of the desired JSON property - [DisplayName("Missing Value")] - public new string PropertyValue { get { return base.PropertyValue; } set { base.PropertyValue = String.Format("Missing or empty {0} parameter", value); } } - } - - [DisplayName("JSON Invalid Parameter")] - [Description("Checks to see the that the JSON response indicates a missing or invalid parameter")] - public class JsonValidateInvalidParameter : JsonValidateError - { - // The value of the desired JSON property - [DisplayName("Invalid Value")] - public new string PropertyValue { get { return base.PropertyValue; } set { base.PropertyValue = String.Format("Missing or invalid {0} parameter", value); } } - } - - [DisplayName("JSON Response")] - [Description("Checks to see the that the JSON response contains the specified message")] - public class JsonValidateResponse : JsonValidateProperty - { - // The name of the desired JSON property - [DisplayName("Response")] - [DefaultValue("response")] - public new string PropertyName { get { return base.PropertyName; } set { base.PropertyName = value; } } - } - - [DisplayName("JSON Property")] - [Description("Checks to see the that the JSON response contains the specified property and is set to the specified value")] - public class JsonValidateProperty : JsonValidate - { - // The name of the desired JSON property - [DisplayName("Property")] - public string PropertyName { get; set; } - - // The value of the desired JSON property - [DisplayName("Value")] - public string PropertyValue { get; set; } - - // Is the value a regexp of the desired JSON property - [DisplayName("Regexp")] - [DefaultValue(false)] - public bool UseRegularExpression { get; set; } - - public override void Validate(object sender, ValidationEventArgs e) - { - RestObject response = ValidateJson(sender, e); - if (null == response) - return; - - if (null == response[PropertyName]) - { - e.Message = String.Format("{0} Not Found", PropertyName); - e.IsValid = false; - return; - } - - if (UseRegularExpression) - { - var re = new Regex(PropertyValue); - if (!re.IsMatch((string)response[PropertyName])) - { - e.Message = String.Format("{0} => '{1}' !~ '{2}'", PropertyName, response[PropertyName], PropertyValue); - e.IsValid = false; - return; - } - } - else - { - if (PropertyValue != (string)response[PropertyName]) - { - e.Message = String.Format("{0} => '{1}' != '{2}'", PropertyName, response[PropertyName], PropertyValue); - e.IsValid = false; - return; - } - } - - e.IsValid = true; - //e.WebTest.Context.Add(ContextParameterName, propertyValue); - } - } - - [DisplayName("JSON Has Properties")] - [Description("Checks to see the that the JSON response contains the specified properties (comma seperated)")] - public class JsonHasProperties : JsonValidate - { - // The name of the desired JSON properties to check - [DisplayName("Properties")] - [Description("A comma seperated list of property names to check exist")] - public string PropertyNames { get; set; } - - //--------------------------------------------------------------------- - public override void Validate(object sender, ValidationEventArgs e) - { - RestObject response = ValidateJson(sender, e); - if (null == response) - return; - foreach (var p in PropertyNames.Split(',')) - { - if (null == response[p]) - { - e.Message = String.Format("'{0}' Not Found", p); - e.IsValid = false; - return; - } - } - e.IsValid = true; - - //e.WebTest.Context.Add(ContextParameterName, propertyValue); - } - } - - public abstract class JsonValidate : ValidationRule - { - // The status of the JSON request - [DisplayName("JSON Status")] - [DefaultValue("200")] - public string JSonStatus { get; set; } - - public RestObject ValidateJson(object sender, ValidationEventArgs e) - { - if (string.IsNullOrWhiteSpace(e.Response.BodyString)) - { - e.IsValid = false; - e.Message = String.Format("Empty or null response {0}", e.Response.StatusCode); - return null; - } - JavaScriptSerializer serialiser = new JavaScriptSerializer(); - //dynamic data = serialiser.Deserialize(e.Response.BodyString); - RestObject response = serialiser.Deserialize(e.Response.BodyString); - - if (JSonStatus != response.Status) - { - e.IsValid = false; - e.Message = String.Format("Response Status '{0}' not '{1}'", response.Status, JSonStatus); - return null; - } - - return response; - } - } -} \ No newline at end of file diff --git a/TShockRestTestPlugin/TShockRestTestPlugin.csproj b/TShockRestTestPlugin/TShockRestTestPlugin.csproj deleted file mode 100644 index e315c7d3..00000000 --- a/TShockRestTestPlugin/TShockRestTestPlugin.csproj +++ /dev/null @@ -1,62 +0,0 @@ - - - - Debug - AnyCPU - 8.0.30703 - 2.0 - {F2FEDAFB-58DE-4611-9168-A86112C346C7} - Library - Properties - TshockRestTestPlugin - TshockRestTestPlugin - v4.0 - 512 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - {49606449-072B-4CF5-8088-AA49DA586694} - TShockAPI - - - - - \ No newline at end of file