update
This commit is contained in:
@@ -5,7 +5,7 @@ server {
|
||||
ssl_certificate /etc/nginx/ssl/tapm.scity.us/fullchain.pem;
|
||||
ssl_certificate_key /etc/nginx/ssl/tapm.scity.us/privkey.pem;
|
||||
|
||||
client_max_body_size 1g;
|
||||
client_max_body_size 1100m;
|
||||
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:8080;
|
||||
@@ -14,7 +14,9 @@ server {
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
proxy_read_timeout 5m;
|
||||
proxy_connect_timeout 30s;
|
||||
proxy_send_timeout 30m;
|
||||
proxy_read_timeout 30m;
|
||||
proxy_request_buffering off;
|
||||
proxy_buffering off;
|
||||
}
|
||||
|
||||
+12
-8
@@ -110,14 +110,7 @@ func New(cfg Config) (*Server, error) {
|
||||
return nil, fmt.Errorf("database: %w", err)
|
||||
}
|
||||
|
||||
templates, err := template.New("").Funcs(template.FuncMap{
|
||||
"formatTime": func(value time.Time) string {
|
||||
return value.Local().Format("Jan 2, 2006 3:04 PM")
|
||||
},
|
||||
"isActive": func(record authorizationRecord) bool {
|
||||
return !record.RevokedAt.Valid && time.Now().Before(record.ExpiresAt)
|
||||
},
|
||||
}).ParseFS(webFiles, "templates/*.html")
|
||||
templates, err := parseTemplates()
|
||||
if err != nil {
|
||||
_ = db.Close()
|
||||
return nil, err
|
||||
@@ -154,6 +147,17 @@ func New(cfg Config) (*Server, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func parseTemplates() (*template.Template, error) {
|
||||
return template.New("").Funcs(template.FuncMap{
|
||||
"formatTime": func(value time.Time) string {
|
||||
return value.Local().Format("Jan 2, 2006 3:04 PM")
|
||||
},
|
||||
"isActive": func(record authorizationRecord) bool {
|
||||
return !record.RevokedAt.Valid && time.Now().Before(record.ExpiresAt)
|
||||
},
|
||||
}).ParseFS(webFiles, "templates/*.html")
|
||||
}
|
||||
|
||||
func (s *Server) Close() error {
|
||||
return s.db.Close()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"io"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestPortalTemplateExecutes(t *testing.T) {
|
||||
t.Parallel()
|
||||
templates, err := parseTemplates()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
err = templates.ExecuteTemplate(io.Discard, "portal.html", pageData{
|
||||
Title: "Test",
|
||||
Technician: &technician{DisplayName: "Technician"},
|
||||
Packages: []packageRecord{{
|
||||
ID: 1,
|
||||
Slug: "sentinelone-linux",
|
||||
DisplayName: "SentinelOne Linux Agent",
|
||||
PackageVersion: "26.1.1.31",
|
||||
Enabled: true,
|
||||
}},
|
||||
Actions: []actionRecord{{
|
||||
Slug: "install-rmm",
|
||||
DisplayName: "Install RMM",
|
||||
Enabled: true,
|
||||
}},
|
||||
Authorizations: []authorizationRecord{{
|
||||
ID: 1,
|
||||
CreatedBy: "taiadmin",
|
||||
ExpiresAt: time.Now().Add(time.Hour),
|
||||
Packages: "SentinelOne Linux Agent",
|
||||
Actions: "Install RMM",
|
||||
}},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
@@ -184,6 +184,10 @@ func (s *Server) streamPackageToGitea(
|
||||
|
||||
response, err := s.packageClient.Do(request)
|
||||
if err != nil {
|
||||
var maxBytesError *http.MaxBytesError
|
||||
if errors.As(err, &maxBytesError) {
|
||||
return "", int64(size), http.StatusRequestEntityTooLarge, maxBytesError
|
||||
}
|
||||
return "", int64(size), http.StatusBadGateway, errors.New("package registry upload failed")
|
||||
}
|
||||
defer response.Body.Close()
|
||||
|
||||
Reference in New Issue
Block a user