- Add /grub/{hwaddr} route for serving GRUB configuration files,
replacing the shim handler with a config-based approach
- Add short URL aliases: 'system' for overlay-system, 'runtime' for
overlay-runtime, and 'grub' stage in parser
- Add 'grub' to status stage tracking in request handling
- Add comprehensive test coverage for EFI, GRUB, initramfs, iPXE,
overlay, and provision handlers (efi_test.go, grub_test.go,
initramfs_test.go, ipxe_test.go, overlay_test.go)
- Expand existing parser and provision tests
- Remove shim.go (functionality folded into grub.go)
- Add userdocs/server/routes.rst documenting all warewulfd HTTP routes
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Jonathon Anderson <janderson@ciq.com>
61 lines
1.3 KiB
Go
61 lines
1.3 KiB
Go
package warewulfd
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
warewulfconf "github.com/warewulf/warewulf/internal/pkg/config"
|
|
"github.com/warewulf/warewulf/internal/pkg/testenv"
|
|
)
|
|
|
|
var initramfsHandlerTests = []struct {
|
|
description string
|
|
url string
|
|
status int
|
|
ip string
|
|
}{
|
|
{"find initramfs", "/initramfs/00:00:00:ff:ff:ff", 200, "10.10.10.10:9873"},
|
|
}
|
|
|
|
func Test_HandleInitramfs(t *testing.T) {
|
|
env := testenv.New(t)
|
|
defer env.RemoveAll()
|
|
|
|
env.WriteFile("/etc/warewulf/nodes.conf", `nodeprofiles:
|
|
default:
|
|
image name: suse
|
|
nodes:
|
|
n1:
|
|
network devices:
|
|
default:
|
|
hwaddr: 00:00:00:ff:ff:ff
|
|
profiles:
|
|
- default`)
|
|
|
|
env.CreateFile("/var/lib/warewulf/chroots/suse/rootfs/boot/vmlinuz-1.1.0")
|
|
env.CreateFile("/var/lib/warewulf/chroots/suse/rootfs/boot/initramfs-1.1.0.img")
|
|
|
|
dbErr := LoadNodeDB()
|
|
assert.NoError(t, dbErr)
|
|
|
|
conf := warewulfconf.Get()
|
|
secureFalse := false
|
|
conf.Warewulf.SecureP = &secureFalse
|
|
|
|
for _, tt := range initramfsHandlerTests {
|
|
t.Run(tt.description, func(t *testing.T) {
|
|
req := httptest.NewRequest(http.MethodGet, tt.url, nil)
|
|
req.RemoteAddr = tt.ip
|
|
w := httptest.NewRecorder()
|
|
HandleInitramfs(w, req)
|
|
res := w.Result()
|
|
defer res.Body.Close()
|
|
|
|
assert.Equal(t, tt.status, res.StatusCode)
|
|
})
|
|
}
|
|
}
|