// ------------------------------------------------------------------------ // Copyright 2021 The Dapr Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // ------------------------------------------------------------------------ namespace Dapr.E2E.Test { using System; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; /// /// Test App invoked by the end-to-end tests /// [ApiController] public class TestController : ControllerBase { /// /// TestController Constructor with logger injection /// /// public TestController(ILogger logger) { this.logger = logger; } private readonly ILogger logger; /// /// Returns the account details /// /// Transaction to process. /// Account [HttpPost("accountDetails")] public ActionResult AccountDetails(Transaction transaction) { var account = new Account() { Id = transaction.Id, Balance = transaction.Amount + 100 }; return account; } [Authorize("Dapr")] [HttpPost("accountDetails-requires-api-token")] public ActionResult AccountDetailsRequiresApiToken(Transaction transaction) { var account = new Account() { Id = transaction.Id, Balance = transaction.Amount + 100 }; return account; } [Authorize("Dapr")] [HttpGet("DelayedResponse")] public async Task DelayedResponse() { await Task.Delay(TimeSpan.FromSeconds(2)); return Ok(); } } }