summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/dashboard/controller.go39
-rw-r--r--app/controllers/dashboard/controller_test.go3
-rw-r--r--test/integration/container_test.go2
3 files changed, 42 insertions, 2 deletions
diff --git a/app/controllers/dashboard/controller.go b/app/controllers/dashboard/controller.go
index cd1c44f..d805027 100644
--- a/app/controllers/dashboard/controller.go
+++ b/app/controllers/dashboard/controller.go
@@ -1,6 +1,7 @@
package dashboard
import (
+ "html/template"
"net/http"
"github.com/xlgmokha/x/pkg/context"
@@ -31,4 +32,42 @@ func (c *Controller) Show(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
w.Header().Add("Content-Type", "text/html")
+ const tpl = `
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <meta name="color-scheme" content="light dark">
+ <title>SparkleLab - {{.Title}}</title>
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css">
+ </head>
+ <body>
+ <main class="container">
+ <nav>
+ <ul>
+ <li><strong>SparkleLab</strong></li>
+ </ul>
+ <ul>
+ <li><a href="/session/new">Login</a></li>
+ </ul>
+ </nav>
+ {{range .Sparkles}}
+ <div>{{ . }}</div>
+ {{else}}
+ <div><strong>No Sparkles</strong></div>
+ {{end}}
+ </main>
+ </body>
+</html>`
+
+ t := x.Must(template.New("show").Parse(tpl))
+ data := struct {
+ Title string
+ Sparkles []string
+ }{
+ Title: "SparkleLab",
+ Sparkles: []string{},
+ }
+ t.Execute(w, data)
}
diff --git a/app/controllers/dashboard/controller_test.go b/app/controllers/dashboard/controller_test.go
index ac9e10d..ff2482f 100644
--- a/app/controllers/dashboard/controller_test.go
+++ b/app/controllers/dashboard/controller_test.go
@@ -4,9 +4,9 @@ import (
"net/http"
"testing"
+ "github.com/stretchr/testify/assert"
"gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/domain"
"gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/test"
- "gotest.tools/v3/assert"
)
func TestController(t *testing.T) {
@@ -35,6 +35,7 @@ func TestController(t *testing.T) {
mux.ServeHTTP(w, r)
assert.Equal(t, http.StatusOK, w.Code)
assert.Equal(t, "text/html", w.Header().Get("Content-Type"))
+ assert.Contains(t, w.Body.String(), "<html")
})
})
})
diff --git a/test/integration/container_test.go b/test/integration/container_test.go
index 76e6a03..625f955 100644
--- a/test/integration/container_test.go
+++ b/test/integration/container_test.go
@@ -9,11 +9,11 @@ import (
"testing"
"time"
+ "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/testcontainers/testcontainers-go"
"github.com/testcontainers/testcontainers-go/wait"
"github.com/xlgmokha/x/pkg/env"
- "gotest.tools/v3/assert"
)
func TestContainer(t *testing.T) {