Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
696ac05a45 | ||
|
|
2a2c52074d |
@@ -27,6 +27,12 @@ regress.
|
||||
and `.dockerignore` are always sent. An ignore file that cannot be read, or
|
||||
holds a pattern Docker rejects, fails the build (#274).
|
||||
|
||||
- 2026-10-03: `make test`, and so `docker build .`, fits a machine with 4 GiB of
|
||||
memory: tests hash passwords with 1 MiB instead of upaasd's 64 MiB, so
|
||||
`GOMAXPROCS=4 make test` peaks at about 1.4 GiB instead of 2.7 GiB. upaasd
|
||||
still hashes with 64 MiB, and one test hashes and verifies a password at that
|
||||
cost (#261).
|
||||
|
||||
- 2026-10-02: In a window too narrow for the top bar, such as 390 px, the New
|
||||
App and Logout buttons move to a second row instead of running into "by
|
||||
@sneak"; the bar keeps a gap between its two sides at every width (#272).
|
||||
|
||||
@@ -60,6 +60,20 @@ func readDockerignore(contextDir, dockerfile string) ([]string, error) {
|
||||
|
||||
defer func() { _ = root.Close() }()
|
||||
|
||||
// When a Dockerfile named Dockerfile is missing, Docker builds a
|
||||
// lowercase dockerfile in the same directory instead, and docker build
|
||||
// then reads dockerfile.dockerignore as its ignore file.
|
||||
if filepath.Base(dockerfile) == defaultDockerfileName {
|
||||
lowercase := filepath.Join(filepath.Dir(dockerfile), "dockerfile")
|
||||
|
||||
_, dockerfileErr := root.Lstat(dockerfile)
|
||||
_, lowercaseErr := root.Lstat(lowercase)
|
||||
|
||||
if errors.Is(dockerfileErr, fs.ErrNotExist) && lowercaseErr == nil {
|
||||
dockerfile = lowercase
|
||||
}
|
||||
}
|
||||
|
||||
name := dockerfile + defaultDockerignoreName
|
||||
|
||||
file, err := root.Open(name)
|
||||
|
||||
@@ -19,9 +19,10 @@ import (
|
||||
// File names used in more than one test build context, as constants to
|
||||
// satisfy the goconst linter.
|
||||
const (
|
||||
testMainGo = "main.go"
|
||||
testSecretFile = "secret.txt"
|
||||
testDeployDockerfile = "deploy/Dockerfile"
|
||||
testMainGo = "main.go"
|
||||
testSecretFile = "secret.txt"
|
||||
testDeployDockerfile = "deploy/Dockerfile"
|
||||
testLowercaseDockerfile = "dockerfile"
|
||||
)
|
||||
|
||||
// TestPerformBuildFollowsDockerignore runs builds against a fake Docker API
|
||||
@@ -67,6 +68,32 @@ func TestPerformBuildFollowsDockerignore(t *testing.T) {
|
||||
},
|
||||
want: []string{defaultDockerignoreName, defaultDockerfileName, testMainGo},
|
||||
},
|
||||
{
|
||||
name: "keeps a lowercase dockerfile built in place of a missing Dockerfile",
|
||||
dockerfile: defaultDockerfileName,
|
||||
files: map[string]string{
|
||||
defaultDockerignoreName: "*\n",
|
||||
testLowercaseDockerfile: "",
|
||||
},
|
||||
want: []string{defaultDockerignoreName, testLowercaseDockerfile},
|
||||
},
|
||||
{
|
||||
name: "reads a lowercase dockerfile's own ignore file",
|
||||
dockerfile: defaultDockerfileName,
|
||||
files: map[string]string{
|
||||
defaultDockerignoreName: "main.go\n",
|
||||
testLowercaseDockerfile: "",
|
||||
"dockerfile.dockerignore": "secret.txt\n",
|
||||
testMainGo: "",
|
||||
testSecretFile: "",
|
||||
},
|
||||
want: []string{
|
||||
defaultDockerignoreName,
|
||||
testLowercaseDockerfile,
|
||||
"dockerfile.dockerignore",
|
||||
testMainGo,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "an ignore file next to the Dockerfile wins over .dockerignore",
|
||||
dockerfile: testDeployDockerfile,
|
||||
|
||||
@@ -109,6 +109,9 @@ func createAppServices(
|
||||
})
|
||||
require.NoError(t, authErr)
|
||||
|
||||
// 1 MiB per password hash instead of 64 MiB; see auth.Service.ArgonMemory.
|
||||
authSvc.ArgonMemory = 1024
|
||||
|
||||
appSvc, appErr := app.New(fx.Lifecycle(nil), app.ServiceParams{
|
||||
Logger: logInstance,
|
||||
Database: dbInstance,
|
||||
|
||||
@@ -59,6 +59,13 @@ type ServiceParams struct {
|
||||
|
||||
// Service provides authentication functionality.
|
||||
type Service struct {
|
||||
// ArgonMemory is the memory each argon2id hash takes, in KiB. New sets
|
||||
// argonMemory, 64 MiB, and upaasd never changes it. Tests lower it, since
|
||||
// many 64 MiB hashes at once under the race detector need more memory
|
||||
// than a 4 GiB build machine has. A hash verifies only with the value it
|
||||
// was made with.
|
||||
ArgonMemory uint32
|
||||
|
||||
log *slog.Logger
|
||||
db *database.Database
|
||||
store *sessions.CookieStore
|
||||
@@ -77,10 +84,11 @@ func New(_ fx.Lifecycle, params ServiceParams) (*Service, error) {
|
||||
}
|
||||
|
||||
return &Service{
|
||||
log: params.Logger.Get(),
|
||||
db: params.Database,
|
||||
store: store,
|
||||
params: ¶ms,
|
||||
ArgonMemory: argonMemory,
|
||||
log: params.Logger.Get(),
|
||||
db: params.Database,
|
||||
store: store,
|
||||
params: ¶ms,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -97,7 +105,7 @@ func (svc *Service) HashPassword(password string) (string, error) {
|
||||
[]byte(password),
|
||||
salt,
|
||||
argonTime,
|
||||
argonMemory,
|
||||
svc.ArgonMemory,
|
||||
argonThreads,
|
||||
argonKeyLen,
|
||||
)
|
||||
@@ -132,7 +140,7 @@ func (svc *Service) VerifyPassword(hashedPassword, password string) bool {
|
||||
[]byte(password),
|
||||
salt,
|
||||
argonTime,
|
||||
argonMemory,
|
||||
svc.ArgonMemory,
|
||||
argonThreads,
|
||||
argonKeyLen,
|
||||
)
|
||||
|
||||
@@ -65,6 +65,10 @@ func setupTestService(t *testing.T) (*auth.Service, func()) {
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
// 1 MiB per hash instead of 64 MiB; see Service.ArgonMemory. The tests
|
||||
// that use setupAuthService keep 64 MiB.
|
||||
svc.ArgonMemory = 1024
|
||||
|
||||
// t.TempDir() automatically cleans up after test
|
||||
cleanup := func() {}
|
||||
|
||||
@@ -237,6 +241,21 @@ func TestVerifyPassword(testingT *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
// TestHashPasswordWithUpaasdMemory hashes and verifies a password with the
|
||||
// memory New sets, which upaasd uses. setupTestService lowers it.
|
||||
func TestHashPasswordWithUpaasdMemory(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
svc := setupAuthService(t, false)
|
||||
require.Equal(t, uint32(64*1024), svc.ArgonMemory)
|
||||
|
||||
hash, err := svc.HashPassword("correctpassword")
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.True(t, svc.VerifyPassword(hash, "correctpassword"))
|
||||
assert.False(t, svc.VerifyPassword(hash, "wrongpassword"))
|
||||
}
|
||||
|
||||
func TestIsSetupRequired(testingT *testing.T) {
|
||||
testingT.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user