< Summary - Kestrun — Combined Coverage

Information
Class: Public.Middleware.Cors.Set-KrCorsCredential
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Middleware/Cors/Set-KrCorsCredential.ps1
Tag: Kestrun/Kestrun@0d738bf294e6281b936d031e1979d928007495ff
Line coverage
0%
Covered lines: 0
Uncovered lines: 5
Coverable lines: 5
Total lines: 53
Line coverage: 0%
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

Coverage history

Coverage history 0 25 50 75 100 12/14/2025 - 20:04:52 Line coverage: 0% (0/5) Total lines: 53 Tag: Kestrun/Kestrun@a05ac8de57c6207e227b92ba360e9d58869ac80a

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Middleware/Cors/Set-KrCorsCredential.ps1

#LineLine coverage
 1<#
 2.SYNOPSIS
 3    Set the CORS credentials policy for a given CorsPolicyBuilder object.
 4.DESCRIPTION
 5    This function sets the CORS credentials policy for a given CorsPolicyBuilder object.
 6    It can either allow or disallow credentials based on the provided parameters.
 7    The function uses the CorsPolicyBuilder object to configure the CORS policy.
 8    The function can be used in a pipeline to configure the CORS policy for a given CorsPolicy
 9    object.
 10.PARAMETER Builder
 11    The CorsPolicyBuilder object to configure.
 12.PARAMETER Allow
 13    Allows credentials in the CORS policy.
 14.PARAMETER Disallow
 15    Disallows credentials in the CORS policy.
 16.EXAMPLE
 17    $corsBuilder = New-KrCorsPolicyBuilder  | Set-KrCorsCredential -Allow
 18.EXAMPLE
 19    $corsBuilder = New-KrCorsPolicyBuilder  | Set-KrCorsCredential -Disallow
 20.OUTPUTS
 21    Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder
 22#>
 23function Set-KrCorsCredential {
 24    [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '')]
 25    [KestrunRuntimeApi('Definition')]
 26    [CmdletBinding(DefaultParameterSetName = 'Allow')]
 27    [OutputType([Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder])]
 28    param(
 29        [Parameter(Mandatory, ValueFromPipeline)]
 30        [Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder]$Builder,
 31
 32        [Parameter(ParameterSetName = 'Allow')]
 33        [switch]$Allow,
 34
 35        [Parameter(ParameterSetName = 'Disallow')]
 36        [switch]$Disallow
 37    )
 38    process {
 039        if ($Allow.IsPresent) {
 40            # This will throw later at runtime too, but it’s nicer to catch early:
 41            # AllowCredentials + AllowAnyOrigin is invalid.
 042            $Builder.AllowCredentials() | Out-Null
 43        }
 44
 045        if ($Disallow.IsPresent) {
 46            # This will throw later at runtime too, but it’s nicer to catch early:
 47            # DisallowCredentials + AllowAnyOrigin is invalid.
 048            $Builder.DisallowCredentials() | Out-Null
 49        }
 50
 051        return $Builder
 52    }
 53}

Methods/Properties

Set-KrCorsCredential()