[#215] added server-side handlers for serving private files

This commit is contained in:
Gani Georgiev
2023-04-04 20:33:35 +03:00
parent 9f76ad234c
commit 64c3e3b3c5
21 changed files with 519 additions and 42 deletions

View File

@@ -52,3 +52,26 @@ func TestNewAdminResetPasswordToken(t *testing.T) {
t.Fatalf("Expected admin %v, got %v", admin, tokenAdmin)
}
}
func TestNewAdminFileToken(t *testing.T) {
app, _ := tests.NewTestApp()
defer app.Cleanup()
admin, err := app.Dao().FindAdminByEmail("test@example.com")
if err != nil {
t.Fatal(err)
}
token, err := tokens.NewAdminFileToken(app, admin)
if err != nil {
t.Fatal(err)
}
tokenAdmin, _ := app.Dao().FindAdminByToken(
token,
app.Settings().AdminFileToken.Secret,
)
if tokenAdmin == nil || tokenAdmin.Id != admin.Id {
t.Fatalf("Expected admin %v, got %v", admin, tokenAdmin)
}
}