more tests and make github run ALL tests. Also print default creds + add windows specific tests
This commit is contained in:
@@ -7,7 +7,11 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
server-tests:
|
server-tests:
|
||||||
runs-on: ubuntu-latest
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
working-directory: Overlord-Server
|
working-directory: Overlord-Server
|
||||||
@@ -27,7 +31,11 @@ jobs:
|
|||||||
run: bun test
|
run: bun test
|
||||||
|
|
||||||
client-tests:
|
client-tests:
|
||||||
runs-on: ubuntu-latest
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
working-directory: Overlord-Client
|
working-directory: Overlord-Client
|
||||||
|
|||||||
@@ -17,6 +17,12 @@ import (
|
|||||||
"github.com/kbinani/screenshot"
|
"github.com/kbinani/screenshot"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
monitorCountFn = capture.MonitorCount
|
||||||
|
displayBoundsFn = capture.DisplayBounds
|
||||||
|
captureDisplayRGBABitBltFn = capture.CaptureDisplayRGBABitBlt
|
||||||
|
)
|
||||||
|
|
||||||
func HandleScreenshot(ctx context.Context, env *rt.Env, cmdID string, allDisplays bool) error {
|
func HandleScreenshot(ctx context.Context, env *rt.Env, cmdID string, allDisplays bool) error {
|
||||||
if allDisplays {
|
if allDisplays {
|
||||||
log.Printf("screenshot: capturing all displays")
|
log.Printf("screenshot: capturing all displays")
|
||||||
@@ -154,13 +160,13 @@ func captureScreenshotImage(allDisplays bool) (*image.RGBA, int, image.Rectangle
|
|||||||
}
|
}
|
||||||
|
|
||||||
func captureScreenshotImageWindows(allDisplays bool) (*image.RGBA, int, image.Rectangle, error) {
|
func captureScreenshotImageWindows(allDisplays bool) (*image.RGBA, int, image.Rectangle, error) {
|
||||||
monitorCount := capture.MonitorCount()
|
monitorCount := monitorCountFn()
|
||||||
if monitorCount <= 0 {
|
if monitorCount <= 0 {
|
||||||
return nil, 0, image.Rectangle{}, errors.New("no active displays available")
|
return nil, 0, image.Rectangle{}, errors.New("no active displays available")
|
||||||
}
|
}
|
||||||
|
|
||||||
if !allDisplays {
|
if !allDisplays {
|
||||||
img, err := capture.CaptureDisplayRGBABitBlt(0)
|
img, err := captureDisplayRGBABitBltFn(0)
|
||||||
if err != nil || img == nil {
|
if err != nil || img == nil {
|
||||||
return nil, 0, image.Rectangle{}, err
|
return nil, 0, image.Rectangle{}, err
|
||||||
}
|
}
|
||||||
@@ -176,8 +182,8 @@ func captureScreenshotImageWindows(allDisplays bool) (*image.RGBA, int, image.Re
|
|||||||
maxX, maxY := int(-1e9), int(-1e9)
|
maxX, maxY := int(-1e9), int(-1e9)
|
||||||
|
|
||||||
for i := 0; i < monitorCount; i++ {
|
for i := 0; i < monitorCount; i++ {
|
||||||
bounds := capture.DisplayBounds(i)
|
bounds := displayBoundsFn(i)
|
||||||
img, err := capture.CaptureDisplayRGBABitBlt(i)
|
img, err := captureDisplayRGBABitBltFn(i)
|
||||||
if err != nil || img == nil {
|
if err != nil || img == nil {
|
||||||
return nil, 0, image.Rectangle{}, err
|
return nil, 0, image.Rectangle{}, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,107 @@
|
|||||||
|
//go:build windows
|
||||||
|
|
||||||
|
package handlers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"image"
|
||||||
|
"image/color"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestCaptureScreenshotImageWindows_PrimaryOnly(t *testing.T) {
|
||||||
|
origMonitorCountFn := monitorCountFn
|
||||||
|
origCaptureFn := captureDisplayRGBABitBltFn
|
||||||
|
t.Cleanup(func() {
|
||||||
|
monitorCountFn = origMonitorCountFn
|
||||||
|
captureDisplayRGBABitBltFn = origCaptureFn
|
||||||
|
})
|
||||||
|
|
||||||
|
monitorCountFn = func() int { return 2 }
|
||||||
|
captureDisplayRGBABitBltFn = func(display int) (*image.RGBA, error) {
|
||||||
|
img := image.NewRGBA(image.Rect(0, 0, 3, 2))
|
||||||
|
img.SetRGBA(0, 0, color.RGBA{R: 255, A: 255})
|
||||||
|
return img, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
img, displayIndex, bounds, err := captureScreenshotImageWindows(false)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("captureScreenshotImageWindows(false) failed: %v", err)
|
||||||
|
}
|
||||||
|
if img == nil {
|
||||||
|
t.Fatal("expected image, got nil")
|
||||||
|
}
|
||||||
|
if displayIndex != 0 {
|
||||||
|
t.Fatalf("expected displayIndex 0, got %d", displayIndex)
|
||||||
|
}
|
||||||
|
if bounds.Dx() != 3 || bounds.Dy() != 2 {
|
||||||
|
t.Fatalf("expected bounds 3x2, got %dx%d", bounds.Dx(), bounds.Dy())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCaptureScreenshotImageWindows_AllDisplaysStitched(t *testing.T) {
|
||||||
|
origMonitorCountFn := monitorCountFn
|
||||||
|
origBoundsFn := displayBoundsFn
|
||||||
|
origCaptureFn := captureDisplayRGBABitBltFn
|
||||||
|
t.Cleanup(func() {
|
||||||
|
monitorCountFn = origMonitorCountFn
|
||||||
|
displayBoundsFn = origBoundsFn
|
||||||
|
captureDisplayRGBABitBltFn = origCaptureFn
|
||||||
|
})
|
||||||
|
|
||||||
|
monitorCountFn = func() int { return 2 }
|
||||||
|
displayBoundsFn = func(idx int) image.Rectangle {
|
||||||
|
if idx == 0 {
|
||||||
|
return image.Rect(0, 0, 2, 2)
|
||||||
|
}
|
||||||
|
return image.Rect(2, 0, 4, 2)
|
||||||
|
}
|
||||||
|
captureDisplayRGBABitBltFn = func(display int) (*image.RGBA, error) {
|
||||||
|
img := image.NewRGBA(image.Rect(0, 0, 2, 2))
|
||||||
|
if display == 0 {
|
||||||
|
img.SetRGBA(0, 0, color.RGBA{R: 255, A: 255})
|
||||||
|
} else {
|
||||||
|
img.SetRGBA(0, 0, color.RGBA{G: 255, A: 255})
|
||||||
|
}
|
||||||
|
return img, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
img, displayIndex, bounds, err := captureScreenshotImageWindows(true)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("captureScreenshotImageWindows(true) failed: %v", err)
|
||||||
|
}
|
||||||
|
if img == nil {
|
||||||
|
t.Fatal("expected stitched image, got nil")
|
||||||
|
}
|
||||||
|
if displayIndex != 0 {
|
||||||
|
t.Fatalf("expected displayIndex 0, got %d", displayIndex)
|
||||||
|
}
|
||||||
|
if bounds.Dx() != 4 || bounds.Dy() != 2 {
|
||||||
|
t.Fatalf("expected stitched bounds 4x2, got %dx%d", bounds.Dx(), bounds.Dy())
|
||||||
|
}
|
||||||
|
|
||||||
|
left := img.RGBAAt(0, 0)
|
||||||
|
right := img.RGBAAt(2, 0)
|
||||||
|
if left.R != 255 || left.G != 0 {
|
||||||
|
t.Fatalf("expected left monitor red marker, got %+v", left)
|
||||||
|
}
|
||||||
|
if right.G != 255 || right.R != 0 {
|
||||||
|
t.Fatalf("expected right monitor green marker, got %+v", right)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCaptureScreenshotImageWindows_NoDisplays(t *testing.T) {
|
||||||
|
origMonitorCountFn := monitorCountFn
|
||||||
|
t.Cleanup(func() {
|
||||||
|
monitorCountFn = origMonitorCountFn
|
||||||
|
})
|
||||||
|
|
||||||
|
monitorCountFn = func() int { return 0 }
|
||||||
|
|
||||||
|
img, _, _, err := captureScreenshotImageWindows(false)
|
||||||
|
if err == nil {
|
||||||
|
t.Fatal("expected error for no displays, got nil")
|
||||||
|
}
|
||||||
|
if img != nil {
|
||||||
|
t.Fatal("expected nil image on error")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -81,6 +81,9 @@ if (userCount.count === 0) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
logger.info(`[users] Initial admin account created (username: ${initialUsername})`);
|
logger.info(`[users] Initial admin account created (username: ${initialUsername})`);
|
||||||
|
logger.warn(
|
||||||
|
`[users] Bootstrap login credentials -> username: ${initialUsername} | password: ${initialPassword}`,
|
||||||
|
);
|
||||||
logger.warn(
|
logger.warn(
|
||||||
"[users] ⚠️ SECURITY WARNING: Rotate the bootstrap password after first login. If it was auto-generated, retrieve it from data/save.json.",
|
"[users] ⚠️ SECURITY WARNING: Rotate the bootstrap password after first login. If it was auto-generated, retrieve it from data/save.json.",
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user