Skip to content

Commit

Permalink
#188509201, #188545343 : Fixed/Added test for lobBody and maxBodySize (
Browse files Browse the repository at this point in the history
…#25)

* Fixed test for lobBody and maxBodySize

* Removed the app id and use env var instead.

---------

Co-authored-by: Keyur <keyur.kv@gmail.com>
  • Loading branch information
praves77 and keyur9 authored Nov 21, 2024
1 parent 5ded782 commit ecc6010
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 17 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -351,3 +351,6 @@ MigrationBackup/

# Ionide (cross platform F# VS Code tools) working folder
.ionide/
.idea/
.DS_Store/

16 changes: 14 additions & 2 deletions Moesif.NetFramework.Example.sln
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30114.105
# Visual Studio Version 17
VisualStudioVersion = 17.8.34330.188
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Moesif.NetFramework.Example", "Moesif.NetFramework.Example\Moesif.NetFramework.Example.csproj", "{01CE4CC9-C236-4634-B462-E577A466E948}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Moesif.Api", "..\clean\moesifapi-csharp\Moesif.Api\Moesif.Api.csproj", "{35B87982-636E-4309-BADD-912972B9E433}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Moesif.Middleware", "..\clean\moesif-dotnet\Moesif.Middleware\Moesif.Middleware.csproj", "{AD22EB03-540E-493D-AEC1-1AE8FC8127A7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,6 +19,14 @@ Global
{01CE4CC9-C236-4634-B462-E577A466E948}.Debug|Any CPU.Build.0 = Debug|Any CPU
{01CE4CC9-C236-4634-B462-E577A466E948}.Release|Any CPU.ActiveCfg = Release|Any CPU
{01CE4CC9-C236-4634-B462-E577A466E948}.Release|Any CPU.Build.0 = Release|Any CPU
{35B87982-636E-4309-BADD-912972B9E433}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{35B87982-636E-4309-BADD-912972B9E433}.Debug|Any CPU.Build.0 = Debug|Any CPU
{35B87982-636E-4309-BADD-912972B9E433}.Release|Any CPU.ActiveCfg = Release|Any CPU
{35B87982-636E-4309-BADD-912972B9E433}.Release|Any CPU.Build.0 = Release|Any CPU
{AD22EB03-540E-493D-AEC1-1AE8FC8127A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AD22EB03-540E-493D-AEC1-1AE8FC8127A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AD22EB03-540E-493D-AEC1-1AE8FC8127A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AD22EB03-540E-493D-AEC1-1AE8FC8127A7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
46 changes: 41 additions & 5 deletions Moesif.NetFramework.Example/Controllers/ProductController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.Mvc;

namespace Moesif.NetFramework.Example
{
Expand Down Expand Up @@ -32,12 +33,25 @@ public IEnumerable<Product> Get()
// GET api/product/5
public Product Get(int id)
{
return new Product
if (id < 22)
{
Id = 1234,
Name = "Chair",
Category = "Furniture"
};
return new Product
{
Id = id,
Name = "Small Chair",
Category = "Furniture"
};
}
else
{
string content = GenerateLargeResponseBody(id);
return new Product
{
Id = id,
Name = $"Largggggggggggggge Chair [{id} KB]",
Category = content
};
}
}

// POST api/product
Expand All @@ -57,5 +71,27 @@ public IHttpActionResult Put(int id, [FromBody] Product value)
public void Delete(int id)
{
}

private static string GenerateLargeResponseBody(int sizeInKB)
{
const string baseString = "This is a test string. ";
int repetitions = (sizeInKB * 1024 * 1024) / baseString.Length;
return new string('A', repetitions); // Create a large string filled with 'A's
}

//[System.Web.Http.HttpGet("download")]
//public IHttpActionResult Download(int sizeInMB)
//{
// // byte[] fileBytes = File.ReadAllBytes("path/to/file");
// // return File(fileBytes, "application/octet-stream", "filename.ext");
// string content = GenerateLargeResponseBody(sizeInMB);
// return new Product
// {
// Id = sizeInMB,
// Name = "Chair",
// Category = content
// };
//}

}
}
19 changes: 13 additions & 6 deletions Moesif.NetFramework.Example/Moesif.NetFramework.Example.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,6 @@
<Reference Include="Microsoft.Owin.Host.SystemWeb, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Owin.Host.SystemWeb.4.1.0\lib\net45\Microsoft.Owin.Host.SystemWeb.dll</HintPath>
</Reference>
<Reference Include="Moesif.Api, Version=2.0.8.0, Culture=neutral, PublicKeyToken=b3d293efeab4ba1f, processorArchitecture=MSIL">
<HintPath>..\packages\Moesif.Api.2.0.8\lib\net45\Moesif.Api.dll</HintPath>
</Reference>
<Reference Include="Moesif.Middleware, Version=1.4.8.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Moesif.Middleware.1.4.8\lib\net461\Moesif.Middleware.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -291,6 +285,19 @@
<Content Include="Scripts\jquery-3.4.1.slim.min.map" />
<Content Include="Scripts\jquery-3.4.1.min.map" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\clean\moesif-dotnet\Moesif.Middleware\Moesif.Middleware.csproj">
<Project>{ad22eb03-540e-493d-aec1-1ae8fc8127a7}</Project>
<Name>Moesif.Middleware</Name>
</ProjectReference>
<ProjectReference Include="..\..\clean\moesifapi-csharp\Moesif.Api\Moesif.Api.csproj">
<Project>{35b87982-636e-4309-badd-912972b9e433}</Project>
<Name>Moesif.Api</Name>
</ProjectReference>
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
Expand Down
8 changes: 6 additions & 2 deletions Moesif.NetFramework.Example/Settings/MoesifOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,15 @@ public class MoesifOptions

static public Dictionary<string, object> moesifOptions = new Dictionary<string, object>
{
{"ApplicationId", "Your Moesif Application Id"},
string moesifApplicationId = Environment.GetEnvironmentVariable("MOESIF_APPLICATION_ID") ?? "<Moesif-Application-Id>";
{"ApplicationId", moesifApplicationId},
{"LocalDebug", true},
{"LogBody", true},
{"LogBodyOutgoing", true},
{"ApiVersion", "1.1.0"},
{"RequestMaxBodySize", 100000},
{"ResponseMaxBodySize", 300},
{"IsLambda", false},
{"ApiVersion", "3.1.0"},
{"IdentifyUser", IdentifyUser},
{"IdentifyCompany", IdentifyCompany},
{"GetSessionToken", GetSessionToken},
Expand Down
2 changes: 0 additions & 2 deletions Moesif.NetFramework.Example/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
<package id="Microsoft.Owin.Host.SystemWeb" version="4.1.0" targetFramework="net462" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net462" />
<package id="Modernizr" version="2.8.3" targetFramework="net462" />
<package id="Moesif.Api" version="2.0.8" targetFramework="net462" />
<package id="Moesif.Middleware" version="1.4.8" targetFramework="net462" />
<package id="Newtonsoft.Json" version="13.0.2" targetFramework="net462" />
<package id="Owin" version="1.0" targetFramework="net462" />
<package id="System.Buffers" version="4.5.1" targetFramework="net462" />
Expand Down

0 comments on commit ecc6010

Please sign in to comment.