-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3db0a53
commit daa97f3
Showing
20 changed files
with
571 additions
and
594 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,47 @@ | ||
<Project ToolsVersion="15.0"> | ||
<Import Project="$(MSBuildThisFileDirectory)..\..\samples\Directory.Packages.props" /> | ||
<ItemGroup> | ||
<PackageVersion Include="CommunityToolkit.WinUI.UI" Version="7.1.2" /> | ||
<PackageVersion Include="FluentAssertions" Version="6.12.0" /> | ||
<PackageVersion Include="FluentValidation" Version="11.4.0" /> | ||
<PackageVersion Include="IdentityModel.OidcClient" Version="5.0.0" /> | ||
<PackageVersion Include="AspNet.Security.OAuth.Apple" Version="6.0.4" /> | ||
<PackageVersion Include="MSTest.TestAdapter" Version="2.2.9" /> | ||
<PackageVersion Include="MSTest.TestFramework" Version="2.2.9" /> | ||
<PackageVersion Include="Microsoft.AspNetCore.Authentication.Facebook" Version="6.0.7" /> | ||
<PackageVersion Include="Microsoft.AspNetCore.Authentication.Google" Version="6.0.7" /> | ||
<PackageVersion Include="Microsoft.AspNetCore.Authentication.MicrosoftAccount" Version="6.0.7" /> | ||
<PackageVersion Include="Microsoft.Extensions.Logging" Version="8.0.1" /> | ||
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="8.0.1" /> | ||
<PackageVersion Include="Microsoft.Identity.Client" Version="4.66.2" /> | ||
<PackageVersion Include="Microsoft.Net.Compilers.Toolset" Version="4.2.0" /> | ||
<PackageVersion Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="6.2.11" /> | ||
<PackageVersion Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" /> | ||
<!--<PackageVersion Include="Microsoft.Toolkit.Uwp.UI" Version="7.1.2" /> | ||
<Import Project="$(MSBuildThisFileDirectory)..\..\samples\Directory.Packages.props" /> | ||
<ItemGroup> | ||
<PackageVersion Include="CommunityToolkit.WinUI.UI" Version="7.1.2" /> | ||
<PackageVersion Include="FluentAssertions" Version="6.12.0" /> | ||
<PackageVersion Include="FluentValidation" Version="11.4.0" /> | ||
<PackageVersion Include="IdentityModel.OidcClient" Version="5.0.0" /> | ||
<PackageVersion Include="AspNet.Security.OAuth.Apple" Version="6.0.4" /> | ||
<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.12" /> | ||
<PackageVersion Include="MSTest.TestAdapter" Version="2.2.9" /> | ||
<PackageVersion Include="MSTest.TestFramework" Version="2.2.9" /> | ||
<PackageVersion Include="Microsoft.AspNetCore.Authentication.Facebook" Version="6.0.7" /> | ||
<PackageVersion Include="Microsoft.AspNetCore.Authentication.Google" Version="6.0.7" /> | ||
<PackageVersion Include="Microsoft.AspNetCore.Authentication.MicrosoftAccount" Version="6.0.7" /> | ||
<PackageVersion Include="Microsoft.Extensions.Logging" Version="8.0.1" /> | ||
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="8.0.1" /> | ||
<PackageVersion Include="Microsoft.Identity.Client" Version="4.66.2" /> | ||
<PackageVersion Include="Microsoft.Net.Compilers.Toolset" Version="4.2.0" /> | ||
<PackageVersion Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="6.2.11" /> | ||
<PackageVersion Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" /> | ||
<!--<PackageVersion Include="Microsoft.Toolkit.Uwp.UI" Version="7.1.2" /> | ||
<PackageVersion Include="Microsoft.UI.Xaml" Version="2.8.5" />--> | ||
<!--<PackageVersion Include="Microsoft.Web.WebView2" Version="1.0.2365.46" />--> | ||
<PackageVersion Include="Refit" Version="7.2.22" /> | ||
<PackageVersion Include="Refit.HttpClientFactory" Version="7.2.22" /> | ||
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.2.3" /> | ||
<PackageVersion Include="System.ComponentModel.Annotations" Version="5.0.0" /> | ||
<PackageVersion Include="Uno.CommunityToolkit.WinUI.UI" Version="7.1.100" /> | ||
<PackageVersion Include="Uno.UITest" Version="1.1.0-dev.70" /> | ||
<PackageVersion Include="Uno.UITest.Selenium" Version="1.1.0-dev.70" /> | ||
<PackageVersion Include="Uno.UITest.Xamarin" Version="1.1.0-dev.70" /> | ||
<PackageVersion Include="Uno.UITest.Helpers" Version="1.1.0-dev.70" /> | ||
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0" /> | ||
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" /> | ||
<PackageVersion Include="NUnit" Version="4.1.0" /> | ||
<PackageVersion Include="NUnit3TestAdapter" Version="4.5.0" /> | ||
<PackageVersion Include="NunitXml.TestLogger" Version="3.0.131" /> | ||
<PackageVersion Include="Xamarin.Google.Android.Material" Version="1.5.0.13" /> | ||
<PackageVersion Include="Xamarin.UITest" Version="4.3.4" /> | ||
<PackageVersion Include="coverlet.collector" Version="6.0.2" /> | ||
<PackageVersion Include="System.Collections.Immutable" Version="8.0.0" /> | ||
|
||
<PackageVersion Include="System.Private.Uri" Version="4.3.2" /> | ||
<PackageVersion Include="System.Net.Http" Version="4.3.4" /> | ||
<PackageVersion Include="System.Text.RegularExpressions" Version="4.3.1" /> | ||
<PackageVersion Include="System.Text.Json" Version="8.0.5" /> | ||
</ItemGroup> | ||
<!--<PackageVersion Include="Microsoft.Web.WebView2" Version="1.0.2365.46" />--> | ||
<PackageVersion Include="Refit" Version="7.2.22" /> | ||
<PackageVersion Include="Refit.HttpClientFactory" Version="7.2.22" /> | ||
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.2.3" /> | ||
<PackageVersion Include="System.ComponentModel.Annotations" Version="5.0.0" /> | ||
<PackageVersion Include="Uno.CommunityToolkit.WinUI.UI" Version="7.1.100" /> | ||
<PackageVersion Include="Uno.UITest" Version="1.1.0-dev.70" /> | ||
<PackageVersion Include="Uno.UITest.Selenium" Version="1.1.0-dev.70" /> | ||
<PackageVersion Include="Uno.UITest.Xamarin" Version="1.1.0-dev.70" /> | ||
<PackageVersion Include="Uno.UITest.Helpers" Version="1.1.0-dev.70" /> | ||
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0" /> | ||
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" /> | ||
<PackageVersion Include="NUnit" Version="4.1.0" /> | ||
<PackageVersion Include="NUnit3TestAdapter" Version="4.5.0" /> | ||
<PackageVersion Include="NunitXml.TestLogger" Version="3.0.131" /> | ||
<PackageVersion Include="Xamarin.Google.Android.Material" Version="1.5.0.13" /> | ||
<PackageVersion Include="Xamarin.UITest" Version="4.3.4" /> | ||
<PackageVersion Include="coverlet.collector" Version="6.0.2" /> | ||
<PackageVersion Include="System.Collections.Immutable" Version="8.0.0" /> | ||
<PackageVersion Include="System.Private.Uri" Version="4.3.2" /> | ||
<PackageVersion Include="System.Net.Http" Version="4.3.4" /> | ||
<PackageVersion Include="System.Text.RegularExpressions" Version="4.3.1" /> | ||
<PackageVersion Include="System.Text.Json" Version="8.0.5" /> | ||
</ItemGroup> | ||
</Project> |
71 changes: 71 additions & 0 deletions
71
testing/TestHarness/TestBackend/Controllers/KiotaController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using System.IdentityModel.Tokens.Jwt; | ||
using System.Security.Claims; | ||
using System.Text; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Cors; | ||
using Microsoft.IdentityModel.Tokens; | ||
using Microsoft.AspNetCore.Authentication.JwtBearer; | ||
|
||
namespace TestBackend.Controllers; | ||
|
||
[ApiController] | ||
[Route("[controller]")] | ||
[EnableCors("AllowAll")] | ||
public class KiotaController : ControllerBase | ||
{ | ||
private static readonly List<string> _testData = ["Item1", "Item2", "Item3"]; | ||
|
||
[AllowAnonymous] | ||
[HttpPost("login")] | ||
public IActionResult Login([FromBody] LoginRequest request) | ||
{ | ||
if (request.Username == "testuser" && request.Password == "password") | ||
{ | ||
var tokenHandler = new JwtSecurityTokenHandler(); | ||
var key = Encoding.UTF8.GetBytes("SuperSecureVeryLongSecretKey12345"); | ||
|
||
var tokenDescriptor = new SecurityTokenDescriptor | ||
{ | ||
Subject = new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, request.Username) }), | ||
Expires = DateTime.UtcNow.AddHours(1), | ||
SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature) | ||
}; | ||
|
||
var token = tokenHandler.CreateToken(tokenDescriptor); | ||
var tokenString = tokenHandler.WriteToken(token); | ||
|
||
return Ok(new { AccessToken = tokenString }); | ||
} | ||
|
||
return Unauthorized(new { Message = "Invalid credentials" }); | ||
} | ||
|
||
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] | ||
[HttpGet("data")] | ||
[ProducesResponseType(typeof(DataResponse), 200)] | ||
public IActionResult GetData() | ||
{ | ||
var username = User.Identity?.Name; | ||
var response = new DataResponse | ||
{ | ||
Data = _testData, | ||
Message = "Authenticated request", | ||
Username = username ?? "Unknown" | ||
}; | ||
return Ok(response); | ||
} | ||
} | ||
|
||
public class LoginRequest | ||
{ | ||
public string Username { get; set; } | ||
public string Password { get; set; } | ||
} | ||
public class DataResponse | ||
{ | ||
public List<string> Data { get; set; } = new(); | ||
public string Message { get; set; } = string.Empty; | ||
public string Username { get; set; } = string.Empty; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
testing/TestHarness/TestHarness/Ext/Http/Client/Kiota/Data/DataRequestBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// <auto-generated/> | ||
using Microsoft.Kiota.Abstractions.Extensions; | ||
using Microsoft.Kiota.Abstractions.Serialization; | ||
using Microsoft.Kiota.Abstractions; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
using System.Threading; | ||
using System; | ||
using TestHarness.Ext.Http.Kiota.Client.Models; | ||
namespace TestHarness.Ext.Http.Kiota.Client.Kiota.Data | ||
{ | ||
/// <summary> | ||
/// Builds and executes requests for operations under \Kiota\data | ||
/// </summary> | ||
[global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.16.0")] | ||
public partial class DataRequestBuilder : BaseRequestBuilder | ||
{ | ||
/// <summary> | ||
/// Instantiates a new <see cref="global::TestHarness.Ext.Http.Kiota.Client.Kiota.Data.DataRequestBuilder"/> and sets the default values. | ||
/// </summary> | ||
/// <param name="pathParameters">Path parameters for the request</param> | ||
/// <param name="requestAdapter">The request adapter to use to execute the requests.</param> | ||
public DataRequestBuilder(Dictionary<string, object> pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/Kiota/data", pathParameters) | ||
{ | ||
} | ||
/// <summary> | ||
/// Instantiates a new <see cref="global::TestHarness.Ext.Http.Kiota.Client.Kiota.Data.DataRequestBuilder"/> and sets the default values. | ||
/// </summary> | ||
/// <param name="rawUrl">The raw URL to use for the request builder.</param> | ||
/// <param name="requestAdapter">The request adapter to use to execute the requests.</param> | ||
public DataRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/Kiota/data", rawUrl) | ||
{ | ||
} | ||
/// <returns>A <see cref="global::TestHarness.Ext.Http.Kiota.Client.Models.DataResponse"/></returns> | ||
/// <param name="cancellationToken">Cancellation token to use when cancelling requests</param> | ||
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param> | ||
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER | ||
#nullable enable | ||
public async Task<global::TestHarness.Ext.Http.Kiota.Client.Models.DataResponse?> GetAsync(Action<RequestConfiguration<DefaultQueryParameters>>? requestConfiguration = default, CancellationToken cancellationToken = default) | ||
{ | ||
#nullable restore | ||
#else | ||
public async Task<global::TestHarness.Ext.Http.Kiota.Client.Models.DataResponse> GetAsync(Action<RequestConfiguration<DefaultQueryParameters>> requestConfiguration = default, CancellationToken cancellationToken = default) | ||
{ | ||
#endif | ||
var requestInfo = ToGetRequestInformation(requestConfiguration); | ||
return await RequestAdapter.SendAsync<global::TestHarness.Ext.Http.Kiota.Client.Models.DataResponse>(requestInfo, global::TestHarness.Ext.Http.Kiota.Client.Models.DataResponse.CreateFromDiscriminatorValue, default, cancellationToken).ConfigureAwait(false); | ||
} | ||
/// <returns>A <see cref="RequestInformation"/></returns> | ||
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param> | ||
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER | ||
#nullable enable | ||
public RequestInformation ToGetRequestInformation(Action<RequestConfiguration<DefaultQueryParameters>>? requestConfiguration = default) | ||
{ | ||
#nullable restore | ||
#else | ||
public RequestInformation ToGetRequestInformation(Action<RequestConfiguration<DefaultQueryParameters>> requestConfiguration = default) | ||
{ | ||
#endif | ||
var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); | ||
requestInfo.Configure(requestConfiguration); | ||
requestInfo.Headers.TryAdd("Accept", "application/json, text/plain;q=0.9"); | ||
return requestInfo; | ||
} | ||
/// <summary> | ||
/// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. | ||
/// </summary> | ||
/// <returns>A <see cref="global::TestHarness.Ext.Http.Kiota.Client.Kiota.Data.DataRequestBuilder"/></returns> | ||
/// <param name="rawUrl">The raw URL to use for the request builder.</param> | ||
public global::TestHarness.Ext.Http.Kiota.Client.Kiota.Data.DataRequestBuilder WithUrl(string rawUrl) | ||
{ | ||
return new global::TestHarness.Ext.Http.Kiota.Client.Kiota.Data.DataRequestBuilder(rawUrl, RequestAdapter); | ||
} | ||
/// <summary> | ||
/// Configuration for the request such as headers, query parameters, and middleware options. | ||
/// </summary> | ||
[Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")] | ||
[global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.16.0")] | ||
public partial class DataRequestBuilderGetRequestConfiguration : RequestConfiguration<DefaultQueryParameters> | ||
{ | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
testing/TestHarness/TestHarness/Ext/Http/Client/Kiota/KiotaRequestBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// <auto-generated/> | ||
using Microsoft.Kiota.Abstractions.Extensions; | ||
using Microsoft.Kiota.Abstractions; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
using System; | ||
using TestHarness.Ext.Http.Kiota.Client.Kiota.Data; | ||
using TestHarness.Ext.Http.Kiota.Client.Kiota.Login; | ||
namespace TestHarness.Ext.Http.Kiota.Client.Kiota | ||
{ | ||
/// <summary> | ||
/// Builds and executes requests for operations under \Kiota | ||
/// </summary> | ||
[global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.16.0")] | ||
public partial class KiotaRequestBuilder : BaseRequestBuilder | ||
{ | ||
/// <summary>The data property</summary> | ||
public global::TestHarness.Ext.Http.Kiota.Client.Kiota.Data.DataRequestBuilder Data | ||
{ | ||
get => new global::TestHarness.Ext.Http.Kiota.Client.Kiota.Data.DataRequestBuilder(PathParameters, RequestAdapter); | ||
} | ||
/// <summary>The login property</summary> | ||
public global::TestHarness.Ext.Http.Kiota.Client.Kiota.Login.LoginRequestBuilder Login | ||
{ | ||
get => new global::TestHarness.Ext.Http.Kiota.Client.Kiota.Login.LoginRequestBuilder(PathParameters, RequestAdapter); | ||
} | ||
/// <summary> | ||
/// Instantiates a new <see cref="global::TestHarness.Ext.Http.Kiota.Client.Kiota.KiotaRequestBuilder"/> and sets the default values. | ||
/// </summary> | ||
/// <param name="pathParameters">Path parameters for the request</param> | ||
/// <param name="requestAdapter">The request adapter to use to execute the requests.</param> | ||
public KiotaRequestBuilder(Dictionary<string, object> pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/Kiota", pathParameters) | ||
{ | ||
} | ||
/// <summary> | ||
/// Instantiates a new <see cref="global::TestHarness.Ext.Http.Kiota.Client.Kiota.KiotaRequestBuilder"/> and sets the default values. | ||
/// </summary> | ||
/// <param name="rawUrl">The raw URL to use for the request builder.</param> | ||
/// <param name="requestAdapter">The request adapter to use to execute the requests.</param> | ||
public KiotaRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/Kiota", rawUrl) | ||
{ | ||
} | ||
} | ||
} |
Oops, something went wrong.