Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/redfish-api-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Redfish API Integration Tests

on:
push:
branches: [ main, develop, redfish ]
pull_request:
branches: [ main, develop, redfish ]

jobs:
redfish-newman-tests:
name: Redfish Newman/Postman Tests
runs-on: ubuntu-latest

steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit

- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683

- name: Set up Go
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a
with:
go-version: '1.24.x'

- name: Install dependencies
run: go mod download

- name: Install Newman
run: npm install -g newman newman-reporter-htmlextra --ignore-scripts

- name: Create results directory
run: mkdir -p redfish/tests/postman/results

- name: Make test script executable
run: chmod +x redfish/tests/run_tests.sh

- name: Run Redfish API tests with Newman
run: ./redfish/tests/run_tests.sh
env:
CI: "true"
REDFISH_USE_MOCK: "true"
HTTP_TLS_ENABLED: "false"
HTTP_PORT: "8181"

- name: Upload Newman test results
if: always()
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
with:
name: newman-redfish-results
path: redfish/tests/postman/results/
82 changes: 43 additions & 39 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,39 +1,43 @@
# IDE
.idea
.vscode
# Config
.env
.DS_store
#certs
**/*.pem
**/*.crt
**/*.key
**/*.yml
**/*.yaml
!config/config.yml
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
bin/
*.db
*.db-journal
__debug_bin*
*.app

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
vendor/
# ...ignore the ui folder
**/ui/*
# ...but keep the folder
!**/ui/.gitkeep
# Documentation files
doc/openapi.json
# IDE
.idea
.vscode
# Config
.env
.DS_store
#certs
**/*.pem
**/*.crt
**/*.key
**/*.yml
**/*.yaml
!config/config.yml
# Redfish OpenAPI files
!redfish/openapi/*.yaml
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
bin/
*.db
*.db-journal
__debug_bin*
*.app

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
vendor/
# ...ignore the ui folder
**/ui/*
# ...but keep the folder
!**/ui/.gitkeep
# Documentation files
doc/openapi.json
# Newman test results
**/postman/results/
8 changes: 8 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type (
EA `yaml:"ea"`
Auth `yaml:"auth"`
UI `yaml:"ui"`
Redfish `yaml:"redfish"`
}

// App -.
Expand Down Expand Up @@ -110,6 +111,10 @@ type (
UI struct {
ExternalURL string `yaml:"externalUrl" env:"UI_EXTERNAL_URL"`
}
// Redfish -.
Redfish struct {
EnvironmentUUID string `yaml:"environment_uuid" env:"REDFISH_ENV_UUID"`
}
)

// getPreferredIPAddress detects the most likely candidate IP address for this machine.
Expand Down Expand Up @@ -197,6 +202,9 @@ func defaultConfig() *Config {
UI: UI{
ExternalURL: "",
},
Redfish: Redfish{
EnvironmentUUID: "",
},
}
}

Expand Down
5 changes: 4 additions & 1 deletion config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,7 @@ ui:
# - Ignored: When building without 'noui' tag (embedded UI is served normally)
# Example: https://ui.example.com
externalUrl: ""

redfish:
# Optional: Set a fixed UUID for this Redfish service instance
# If not set, a persistent UUID will be auto-generated and stored in ~/.config/dmt-redfish-service/service_uuid
# environment_uuid: ""
7 changes: 6 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ go 1.25
require (
github.com/Masterminds/squirrel v1.5.4
github.com/coreos/go-oidc/v3 v3.17.0
github.com/getkin/kin-openapi v0.133.0
github.com/device-management-toolkit/go-wsman-messages/v2 v2.36.1
github.com/gin-contrib/cors v1.7.6
github.com/gin-contrib/pprof v1.5.3
Expand All @@ -17,6 +18,8 @@ require (
github.com/golang-migrate/migrate/v4 v4.19.1
github.com/gorilla/websocket v1.5.3
github.com/ilyakaznacheev/cleanenv v1.5.0
github.com/labstack/gommon v0.4.2
github.com/oapi-codegen/runtime v1.1.2
github.com/jackc/pgx/v5 v5.8.0
github.com/prometheus/client_golang v1.23.2
github.com/rs/zerolog v1.34.0
Expand All @@ -29,9 +32,9 @@ require (

require (
al.essio.dev/pkg/shellescape v1.5.1 // indirect
github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/danieljoos/wincred v1.2.2 // indirect
github.com/getkin/kin-openapi v0.133.0 // indirect
github.com/go-jose/go-jose/v4 v4.1.3 // indirect
github.com/go-openapi/swag/jsonname v0.25.4 // indirect
github.com/goccy/go-yaml v1.18.0 // indirect
Expand All @@ -57,6 +60,8 @@ require (
github.com/quic-go/qpack v0.6.0 // indirect
github.com/quic-go/quic-go v0.57.0 // indirect
github.com/ryanuber/go-glob v1.0.0 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
github.com/woodsbury/decimal128 v1.4.0 // indirect
github.com/zalando/go-keyring v0.2.6 // indirect
go.yaml.in/yaml/v2 v2.4.2 // indirect
Expand Down
14 changes: 14 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ github.com/Masterminds/squirrel v1.5.4 h1:uUcX/aBc8O7Fg9kaISIUsHXdKuqehiXAMQTYX8
github.com/Masterminds/squirrel v1.5.4/go.mod h1:NNaOrjSoIDfDA40n7sr2tPNZRfjzjA400rg+riTZj10=
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk=
github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ=
github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w=
github.com/bytedance/sonic v1.14.0 h1:/OfKt8HFw0kh2rj8N0F6C/qPGRESq0BbaNZgcNXXzQQ=
github.com/bytedance/sonic v1.14.0/go.mod h1:WoEbx8WTcFJfzCe0hbmyTGrfjt8PzNEBdxlNUO24NhA=
github.com/bytedance/sonic/loader v0.3.0 h1:dskwH8edlzNMctoruo8FPTJDF3vLtDT0sXZwvZJyqeA=
Expand Down Expand Up @@ -158,6 +162,7 @@ github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8Hm
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/juju/gnuflag v0.0.0-20171113085948-2ce1bb71843d/go.mod h1:2PavIy+JPciBPrBUjwbNvtwB6RQlve+hkpll6QSNmOE=
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
Expand All @@ -168,6 +173,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0=
github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU=
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 h1:SOEGU9fKiNWd/HOJuq6+3iTQz8KNCLtVX6idSoTLdUw=
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0/go.mod h1:dXGbAdH5GtBTC4WfIxhKZfyBF/HBFgRZSWwZ9g/He9o=
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 h1:P6pPBnrTSX3DEVR4fDembhRWSsG5rVo6hYhAB/ADZrk=
Expand Down Expand Up @@ -204,6 +211,8 @@ github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A=
github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/oapi-codegen/runtime v1.1.2 h1:P2+CubHq8fO4Q6fV1tqDBZHCwpVpvPg7oKiYzQgXIyI=
github.com/oapi-codegen/runtime v1.1.2/go.mod h1:SK9X900oXmPWilYR5/WKPzt3Kqxn/uS/+lbpREv+eCg=
github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOFAw7w=
github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037 h1:G7ERwszslrBzRxj//JalHPu/3yz+De2J+4aLtSRlHiY=
Expand Down Expand Up @@ -246,6 +255,7 @@ github.com/ryanuber/go-glob v1.0.0 h1:iQh3xXAumdQ+4Ufa5b25cRpC5TYKlno6hsv6Cb3pkB
github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad/go.mod h1:qLr4V1qq6nMqFKkMo8ZTx3f+BZEkzsRUY10Xsm2mwU0=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
Expand All @@ -265,6 +275,10 @@ github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/ugorji/go/codec v1.3.0 h1:Qd2W2sQawAfG8XSvzwhBeoGq71zXOC/Q1E9y/wUcsUA=
github.com/ugorji/go/codec v1.3.0/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
github.com/woodsbury/decimal128 v1.4.0 h1:xJATj7lLu4f2oObouMt2tgGiElE5gO6mSWUjQsBgUlc=
github.com/woodsbury/decimal128 v1.4.0/go.mod h1:BP46FUrVjVhdTbKT+XuQh2xfQaGki9LMIRJSFuh6THU=
github.com/zalando/go-keyring v0.2.6 h1:r7Yc3+H+Ux0+M72zacZoItR3UDxeWfKTcabvkI8ua9s=
Expand Down
6 changes: 3 additions & 3 deletions internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func Run(cfg *config.Config) {
// Use case
usecases := usecase.NewUseCases(database, log, CertStore)

handler := setupHTTPHandler(cfg, log, usecases)
handler := setupHTTPHandler(cfg, log, usecases, database)

ciraServer := setupCIRAServer(cfg, log, database, usecases)

Expand All @@ -65,7 +65,7 @@ func Run(cfg *config.Config) {
shutdownServers(log, httpServer, ciraServer)
}

func setupHTTPHandler(cfg *config.Config, log logger.Interface, usecases *usecase.Usecases) *gin.Engine {
func setupHTTPHandler(cfg *config.Config, log logger.Interface, usecases *usecase.Usecases, database *db.SQL) *gin.Engine {
if os.Getenv("GIN_MODE") != "debug" {
gin.SetMode(gin.ReleaseMode)
}
Expand All @@ -77,7 +77,7 @@ func setupHTTPHandler(cfg *config.Config, log logger.Interface, usecases *usecas
defaultConfig.AllowHeaders = cfg.AllowedHeaders

handler.Use(cors.New(defaultConfig))
httpapi.NewRouter(handler, log, *usecases, cfg)
httpapi.NewRouter(handler, log, *usecases, cfg, database)

// Optionally enable pprof endpoints (e.g., for staging) via env ENABLE_PPROF=true
if os.Getenv("ENABLE_PPROF") == "true" {
Expand Down
16 changes: 14 additions & 2 deletions internal/controller/httpapi/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,22 @@ import (
v2 "github.com/device-management-toolkit/console/internal/controller/httpapi/v2"
openapi "github.com/device-management-toolkit/console/internal/controller/openapi"
"github.com/device-management-toolkit/console/internal/usecase"
"github.com/device-management-toolkit/console/pkg/db"
"github.com/device-management-toolkit/console/pkg/logger"
redfish "github.com/device-management-toolkit/console/redfish"
)

// NewRouter -.
func NewRouter(handler *gin.Engine, l logger.Interface, t usecase.Usecases, cfg *config.Config) {
// NewRouter sets up the HTTP router with redfish support.
func NewRouter(handler *gin.Engine, l logger.Interface, t usecase.Usecases, cfg *config.Config, database *db.SQL) {
// Options
handler.Use(gin.Logger())
handler.Use(gin.Recovery())

// Initialize redfish directly
if err := redfish.Initialize(handler, l, database, &t, cfg); err != nil {
l.Fatal("Failed to initialize redfish: " + err.Error())
}

// Initialize Fuego adapter
fuegoAdapter := openapi.NewFuegoAdapter(t, l)
fuegoAdapter.RegisterRoutes()
Expand Down Expand Up @@ -72,4 +79,9 @@ func NewRouter(handler *gin.Engine, l logger.Interface, t usecase.Usecases, cfg
{
v2.NewAmtRoutes(h3, t.Devices, l)
}

// Register redfish routes directly
if err := redfish.RegisterRoutes(handler, l); err != nil {
l.Fatal("Failed to register redfish routes: " + err.Error())
}
}
Loading
Loading