< Summary - Estud

Information
Class: Estud.Mocks.Webhooks.WebhookTargetController
Assembly: Mocks
File(s): /home/runner/work/syki/syki/Mocks/Webhooks/WebhookTargetController.cs
Tag: 114_29044117136
Line coverage
100%
Covered lines: 6
Uncovered lines: 0
Coverable lines: 6
Total lines: 30
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Receive()100%11100%
ReceiveWithError()100%11100%

File(s)

/home/runner/work/syki/syki/Mocks/Webhooks/WebhookTargetController.cs

#LineLine coverage
 1using Microsoft.AspNetCore.Mvc;
 2
 3namespace Estud.Mocks.Webhooks;
 4
 5/// <summary>
 6/// Simula o sistema target de um cliente que configurou um webhook no Estud.
 7/// Ecoa de volta os headers e o corpo recebidos para que os testes possam
 8/// validar a entrega ponta a ponta, incluindo os custom headers configurados
 9/// na assinatura do webhook.
 10/// </summary>
 11[ApiController]
 12public class WebhookTargetController : ControllerBase
 13{
 14    [HttpPost("webhooks/target")]
 15    public async Task<IActionResult> Receive()
 16    {
 1617        using var reader = new StreamReader(Request.Body);
 1618        var body = await reader.ReadToEndAsync();
 19
 11620        var headers = Request.Headers.ToDictionary(h => h.Key, h => h.Value.ToString());
 21
 1622        return Ok(new { received = true, headers, body });
 1623    }
 24
 25    [HttpPost("webhooks/target/error")]
 26    public IActionResult ReceiveWithError()
 27    {
 228        return StatusCode(500, new { received = false, error = "target system unavailable" });
 29    }
 30}

Methods/Properties

Receive()
ReceiveWithError()