Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add verbosity profile, ngrok tunnel configuration #577

Merged
merged 1 commit into from
Oct 21, 2023
Merged

Conversation

awakecoding
Copy link
Contributor

Add verbosity profile configuration:

	It 'Sets log verbosity profile' {
		Set-DGatewayConfig -ConfigPath:$ConfigPath -VerbosityProfile 'All'
		$(Get-DGatewayConfig -ConfigPath:$ConfigPath).VerbosityProfile | Should -Be 'All'
		Set-DGatewayConfig -ConfigPath:$ConfigPath -VerbosityProfile 'Default'
		$(Get-DGatewayConfig -ConfigPath:$ConfigPath).VerbosityProfile | Should -Be 'Default'
		Set-DGatewayConfig -ConfigPath:$ConfigPath -VerbosityProfile 'Tls'
		$(Get-DGatewayConfig -ConfigPath:$ConfigPath).VerbosityProfile | Should -Be 'Tls'
		{ Set-DGatewayConfig -ConfigPath:$ConfigPath -VerbosityProfile 'yolo' } | Should -Throw
	}

Add ngrok tunnel configuration:

	It 'Sets ngrok configuration' {
		$AuthToken = '4nq9771bPxe8ctg7LKr_2ClH7Y15Zqe4bWLWF9p'
		$Metadata = '{"serial": "00012xa-33rUtz9", "comment": "For customer alan@example.com"}'
		$HeartbeatInterval = 15
		$HeartbeatTolerance = 5
		$ngrok = New-DGatewayNgrokConfig -AuthToken $AuthToken
		$ngrok.Metadata = $Metadata
		$ngrok.HeartbeatInterval = $HeartbeatInterval
		$ngrok.HeartbeatTolerance = $HeartbeatTolerance
		$httpTunnelParams = @{
			Http = $true
			Metadata = "c6481452-6f5d-11ee-b962-0242ac120002"
			AllowCidrs = @("0.0.0.0/0")
			Domain = "gateway.ngrok.io"
			CircuitBreaker = 0.5
			Compression = $true
		}
		$tcpTunnelParams = @{
			Tcp = $true
			AllowCidrs = @("0.0.0.0/0")
			RemoteAddr = "7.tcp.ngrok.io:20560"
		}
		$httpTunnel = New-DGatewayNgrokTunnel @httpTunnelParams
		$tcpTunnel = New-DGatewayNgrokTunnel @tcpTunnelParams
		$ngrok.Tunnels = [PSCustomObject]@{
			"http-endpoint" = $httpTunnel
			"tcp-endpoint" = $tcpTunnel
		}
		Set-DGatewayConfig -ConfigPath:$ConfigPath -Ngrok $ngrok
		$(Get-DGatewayConfig -ConfigPath:$ConfigPath).Ngrok.AuthToken | Should -Be $AuthToken
		$(Get-DGatewayConfig -ConfigPath:$ConfigPath).Ngrok.Metadata | Should -Be $Metadata
		$(Get-DGatewayConfig -ConfigPath:$ConfigPath).Ngrok.HeartbeatInterval | Should -Be $HeartbeatInterval
		$(Get-DGatewayConfig -ConfigPath:$ConfigPath).Ngrok.HeartbeatTolerance | Should -Be $HeartbeatTolerance
		$Tunnels = $(Get-DGatewayConfig -ConfigPath:$ConfigPath).Ngrok.Tunnels
		$Tunnels.'http-endpoint'.Proto | Should -Be 'http'
		$Tunnels.'http-endpoint'.Domain | Should -Be $httpTunnel.Domain
		$Tunnels.'http-endpoint'.Metadata | Should -Be $httpTunnel.Metadata
		$Tunnels.'http-endpoint'.AllowCidrs | Should -Be $httpTunnel.AllowCidrs
		$Tunnels.'tcp-endpoint'.Proto | Should -Be 'tcp'
		$Tunnels.'tcp-endpoint'.RemoteAddr | Should -Be $tcpTunnel.RemoteAddr
		$Tunnels.'tcp-endpoint'.AllowCidrs | Should -Be $tcpTunnel.AllowCidrs
	}

And lots of other PowerShell cleanup, including fixes for the tests in Windows PowerShell

Copy link
Member

@CBenoit CBenoit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@CBenoit CBenoit merged commit 51c4d9c into master Oct 21, 2023
15 checks passed
@CBenoit CBenoit deleted the DGW-112 branch October 21, 2023 05:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants