mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-11-29 18:38:56 +03:00
506b459842
Merge in DNS/adguard-home from 3225-bsd-dhcp to master Closes #3225. Closes #3417. Squashed commit of the following: commit e7ea691824c7ebc8cafd8c9e206679346cbc8592 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Aug 12 17:02:02 2021 +0300 all: imp code, docs commit 5b598fc18a9b69a0256569f4c691bb6a2193dfbd Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Aug 12 16:28:12 2021 +0300 all: mv logic, imp code, docs, log changes commit e3e1577a668fe3e5c61d075c390e4bd7268181ba Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Aug 12 14:15:10 2021 +0300 dhcpd: imp checkother commit 3cc8b058195c30a7ef0b7741ee8463270d9e47ff Author: Eugene Burkov <e.burkov@adguard.com> Date: Wed Aug 11 13:20:18 2021 +0300 all: imp bsd support
52 lines
1,009 B
Go
52 lines
1,009 B
Go
//go:build openbsd
|
|
// +build openbsd
|
|
|
|
package aghnet
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestHostnameIfStaticConfig(t *testing.T) {
|
|
const nl = "\n"
|
|
|
|
testCases := []struct {
|
|
name string
|
|
rcconfData string
|
|
wantHas bool
|
|
}{{
|
|
name: "simple",
|
|
rcconfData: `inet 127.0.0.253` + nl,
|
|
wantHas: true,
|
|
}, {
|
|
name: "case_sensitiveness",
|
|
rcconfData: `InEt 127.0.0.253` + nl,
|
|
wantHas: false,
|
|
}, {
|
|
name: "comments_and_trash",
|
|
rcconfData: `# comment 1` + nl +
|
|
`` + nl +
|
|
`# inet 127.0.0.253` + nl +
|
|
`inet` + nl,
|
|
wantHas: false,
|
|
}, {
|
|
name: "incorrect_config",
|
|
rcconfData: `inet6 127.0.0.253` + nl +
|
|
`inet 256.256.256.256` + nl,
|
|
wantHas: false,
|
|
}}
|
|
|
|
for _, tc := range testCases {
|
|
r := strings.NewReader(tc.rcconfData)
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
has, err := hostnameIfStaticConfig(r)
|
|
require.NoError(t, err)
|
|
|
|
assert.Equal(t, tc.wantHas, has)
|
|
})
|
|
}
|
|
}
|