Remove TShockRestTestPlugin

1. It hasn't been updated in 6 years.
2. Nobody is going to update it.
This commit is contained in:
Lucas Nicodemus 2017-12-14 08:33:34 -07:00
parent 5f647f087c
commit 0ac486ab5e
3 changed files with 0 additions and 326 deletions

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
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")]

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
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<dynamic>(e.Response.BodyString);
RestObject response = serialiser.Deserialize<RestObject>(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;
}
}
}

View file

@ -1,62 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{F2FEDAFB-58DE-4611-9168-A86112C346C7}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TshockRestTestPlugin</RootNamespace>
<AssemblyName>TshockRestTestPlugin</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.WebTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="TShockRestTestPlugin.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TShockAPI\TShockAPI.csproj">
<Project>{49606449-072B-4CF5-8088-AA49DA586694}</Project>
<Name>TShockAPI</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>