Skip to content

Commit

Permalink
Merge branch 'main' into feat/auth
Browse files Browse the repository at this point in the history
Signed-off-by: marius-williams <marius-williams@users.noreply.github.com>
  • Loading branch information
marius-williams committed May 15, 2024
2 parents 16ce187 + 8e063e9 commit a9ee7e5
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 7 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/Guidewire/fern-reporter/badge)](https://securityscorecards.dev/viewer/?uri=github.com/Guidewire/fern-reporter)
![Coverage](https://img.shields.io/badge/Coverage-73.9%25-brightgreen)

![Fern](https://github.com/guidewire/fern-reporter/raw/main/docs/images/logo-no-background.png)

<p align="center">
Expand Down
6 changes: 6 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type config struct {
Db *dbConfig
Server *serverConfig
Auth *authConfig
Header string
}

type dbConfig struct {
Expand Down Expand Up @@ -76,6 +77,8 @@ func LoadConfig() (*config, error) {
}
if os.Getenv("AUTH_KEYS_ENDPOINT") != "" {
configuration.Auth.KeysEndpoint = os.Getenv("AUTH_KEYS_ENDPOINT")
if os.Getenv("FERN_HEADER_NAME") != "" {
configuration.Header = os.Getenv("FERN_HEADER_NAME")
}

return configuration, nil
Expand All @@ -91,4 +94,7 @@ func GetServer() *serverConfig {

func GetAuth() *authConfig {
return configuration.Auth

func GetHeaderName() string {

Check failure on line 98 in config/config.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

syntax error: unexpected GetHeaderName, expected (

Check failure on line 98 in config/config.go

View workflow job for this annotation

GitHub Actions / lint

syntax error: unexpected GetHeaderName, expected (

Check failure on line 98 in config/config.go

View workflow job for this annotation

GitHub Actions / unit-tests

syntax error: unexpected GetHeaderName, expected (
return configuration.Header

Check failure on line 99 in config/config.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

syntax error: unexpected return at end of statement

Check failure on line 99 in config/config.go

View workflow job for this annotation

GitHub Actions / lint

syntax error: unexpected return at end of statement (typecheck)

Check failure on line 99 in config/config.go

View workflow job for this annotation

GitHub Actions / unit-tests

syntax error: unexpected return at end of statement
}
1 change: 1 addition & 0 deletions config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ server:
port: :8080
auth:
keys-endpoint: ""
header: "Fern Acceptance Test Report"
3 changes: 3 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ var _ = Describe("When LoadConfig is invoked", func() {
Expect(appConfig.Db.DetailLog).To(BeTrue())
Expect(appConfig.Db.MaxOpenConns).To(Equal(100))
Expect(appConfig.Db.MaxIdleConns).To(Equal(10))
Expect(appConfig.Header).To(Equal("Fern Acceptance Test Report"))
})

It("should get non-nil DB", func() {
Expand Down Expand Up @@ -65,6 +66,7 @@ var _ = Describe("When LoadConfig is invoked", func() {
os.Setenv("FERN_HOST", "localhost")
os.Setenv("FERN_PORT", "5432")
os.Setenv("FERN_DATABASE", "fern")
os.Setenv("FERN_HEADER_NAME", "Custom Fern Report Header")

//v := viper.New()
result, err := config.LoadConfig()
Expand All @@ -77,6 +79,7 @@ var _ = Describe("When LoadConfig is invoked", func() {
Expect(result.Db.Port).To(Equal("5432"))
Expect(result.Db.Database).To(Equal("fern"))
Expect(result.Auth.KeysEndpoint).To(Equal("https://test-idp-base-url.com/oauth2/abc123/v1/keys"))
Expect(result.Header).To(Equal("Custom Fern Report Header"))
})

})
7 changes: 5 additions & 2 deletions pkg/api/handlers/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package handlers
import (
"errors"
"fmt"
"github.com/guidewire/fern-reporter/config"
"log"
"net/http"
"strconv"
Expand Down Expand Up @@ -149,7 +150,8 @@ func (h *Handler) ReportTestRunAll(c *gin.Context) {
var testRuns []models.TestRun
h.db.Preload("SuiteRuns.SpecRuns.Tags").Find(&testRuns)
c.HTML(http.StatusOK, "test_runs.html", gin.H{
"testRuns": testRuns,
"reportHeader": config.GetHeaderName(),
"testRuns": testRuns,
})
}

Expand All @@ -158,7 +160,8 @@ func (h *Handler) ReportTestRunById(c *gin.Context) {
id := c.Param("id")
h.db.Preload("SuiteRuns.SpecRuns").Where("id = ?", id).First(&testRun)
c.HTML(http.StatusOK, "test_runs.html", gin.H{
"testRuns": []models.TestRun{testRun},
"reportHeader": config.GetHeaderName(),
"testRuns": []models.TestRun{testRun},
})
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/views/test_runs.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ATMOS Acceptance Tests</title>
<title>{{ .reportHeader }}</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.3/css/bulma.min.css">
<style>
body {
Expand Down Expand Up @@ -66,7 +66,7 @@
</head>
<body>
<div class="container">
<h1 class="title is-3 has-text-centered has-background-primary has-text-white p-4">ATMOS Acceptance Tests</h1>
<h1 class="title is-3 has-text-centered has-background-primary has-text-white p-4">{{ .reportHeader }}</h1>
<div>
<table style="width: 100%;">
<tr>
Expand Down

0 comments on commit a9ee7e5

Please sign in to comment.