feat: implement imprint/impressum support (#706)
* feat: implement imprint/impressum support Closes #362 Signed-off-by: Xe Iaso <me@xeiaso.net> * chore(docs/anubis): enable an imprint Signed-off-by: Xe Iaso <me@xeiaso.net> * chore: spelling Signed-off-by: Xe Iaso <me@xeiaso.net> * docs: fix the end of the sentence, comment out a default impressum Signed-off-by: Xe Iaso <me@xeiaso.net> * docs: link back to impressum page Signed-off-by: Xe Iaso <me@xeiaso.net> --------- Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
parent
3c1d95d61e
commit
5870f7072c
22 changed files with 530 additions and 130 deletions
62
lib/policy/config/impressum_test.go
Normal file
62
lib/policy/config/impressum_test.go
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestImpressumValid(t *testing.T) {
|
||||
for _, cs := range []struct {
|
||||
name string
|
||||
inp Impressum
|
||||
err error
|
||||
}{
|
||||
{
|
||||
name: "basic happy path",
|
||||
inp: Impressum{
|
||||
Footer: "<p>Website hosted by Techaro.<p>",
|
||||
Page: ImpressumPage{
|
||||
Title: "Techaro Imprint",
|
||||
Body: "<p>This is an imprint page.</p>",
|
||||
},
|
||||
},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
name: "no footer",
|
||||
inp: Impressum{
|
||||
Footer: "",
|
||||
Page: ImpressumPage{
|
||||
Title: "Techaro Imprint",
|
||||
Body: "<p>This is an imprint page.</p>",
|
||||
},
|
||||
},
|
||||
err: ErrMissingValue,
|
||||
},
|
||||
{
|
||||
name: "page not valid",
|
||||
inp: Impressum{
|
||||
Footer: "test page please ignore",
|
||||
},
|
||||
err: ErrMissingValue,
|
||||
},
|
||||
} {
|
||||
t.Run(cs.name, func(t *testing.T) {
|
||||
if err := cs.inp.Valid(); !errors.Is(err, cs.err) {
|
||||
t.Logf("want: %v", cs.err)
|
||||
t.Logf("got: %v", err)
|
||||
t.Error("validation failed")
|
||||
}
|
||||
|
||||
var buf bytes.Buffer
|
||||
if err := cs.inp.Render(t.Context(), &buf); err != nil {
|
||||
t.Errorf("can't render footer: %v", err)
|
||||
}
|
||||
|
||||
if err := cs.inp.Page.Render(t.Context(), &buf); err != nil {
|
||||
t.Errorf("can't render page: %v", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue