kaypee90
Writing integration tests for .net core endpoints with authentication
I have built and endpoint using asp.net api controllers with the authorize attribute.
I am using the TestAuthHandler with a custom web app factory approach to test these endpoints but I still get unauthorized.
I realized HandleAuthenticateAsync method I have overriden in the TestAuthHandler is not being invoked.
This is a link to resource I was following https://gunnarpeipman.com/aspnet-core-integration-test-fake-user/
Kindly help me out.
2 replies
❔ I am getting CORS error when I deploy Duende Identity Server but it work fine locally
I get 400 Bad request trying to login on Duende identity server when I deploy it onto a remote server.
When I inspect the logs this is what I see:
Duende.IdentityServer.Hosting.CorsPolicyProvider
| CORS request made for path: /Account/Login from origin: null but was ignored because path was not for an allowed IdentityServer CORS endpoint
What am I missing?
3 replies
❔ How to add custom attributes to Winforms control events
I have added a custom attribute to a winforms control event but it is not being triggered. What is the right way to do that.
[AttributeUsage(AttributeTargets.Method)]
public class EventTimeAttribute : Attribute
{
private string EventName { get; set; }
public EventTimeAttribute(string eventName)
{
EventName = eventName;
Console.WriteLine($@"{DateTime.Now.ToShortDateString()}: {eventName}");
}
}
Using the attribute:
[EventTime("lvAccounts_SelectedIndexChanged")]
private void lvAccounts_SelectedIndexChanged(object sender, EventArgs e)
{
}
9 replies