Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
51b151aa26 |
@@ -8,8 +8,6 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"golang.org/x/crypto/bcrypt"
|
|
||||||
"sneak.berlin/go/neoirc/internal/dbtest"
|
|
||||||
"sneak.berlin/go/neoirc/internal/ircserver"
|
"sneak.berlin/go/neoirc/internal/ircserver"
|
||||||
"sneak.berlin/go/neoirc/internal/service"
|
"sneak.berlin/go/neoirc/internal/service"
|
||||||
)
|
)
|
||||||
@@ -585,10 +583,8 @@ func ownSessionCopies(
|
|||||||
|
|
||||||
// aliceWithHTTPClient connects alice to the IRC listener and
|
// aliceWithHTTPClient connects alice to the IRC listener and
|
||||||
// has her join #chan, which bob is on too, then adds an HTTP API
|
// has her join #chan, which bob is on too, then adds an HTTP API
|
||||||
// client to her session with a password, as POST /api/v1/login
|
// client to her session with the password her connection set,
|
||||||
// does. It stores that password without sending PASS. It hashes
|
// as POST /api/v1/login does. It returns her connection, bob's
|
||||||
// at bcrypt.MinCost, and a login compares at the cost stored in
|
|
||||||
// the hash, so both are fast. It returns her connection, bob's
|
|
||||||
// connection, her session and her HTTP API client.
|
// connection, her session and her HTTP API client.
|
||||||
func aliceWithHTTPClient(
|
func aliceWithHTTPClient(
|
||||||
t *testing.T, env *testEnv,
|
t *testing.T, env *testEnv,
|
||||||
@@ -598,24 +594,15 @@ func aliceWithHTTPClient(
|
|||||||
const password = "alicepass"
|
const password = "alicepass"
|
||||||
|
|
||||||
alice := env.dial(t)
|
alice := env.dial(t)
|
||||||
|
alice.send("PASS " + password)
|
||||||
alice.register("alice")
|
alice.register("alice")
|
||||||
|
// Registration stores the password before the JOIN runs.
|
||||||
alice.joinAndDrain("#chan")
|
alice.joinAndDrain("#chan")
|
||||||
|
|
||||||
bob := env.dial(t)
|
bob := env.dial(t)
|
||||||
bob.register("bob")
|
bob.register("bob")
|
||||||
bob.joinAndDrain("#chan")
|
bob.joinAndDrain("#chan")
|
||||||
|
|
||||||
hash, err := bcrypt.GenerateFromPassword(
|
|
||||||
[]byte(password), bcrypt.MinCost,
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("hash password: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
dbtest.Exec(t, env.dbURL,
|
|
||||||
"UPDATE sessions SET password_hash = '"+string(hash)+
|
|
||||||
"' WHERE nick = 'alice'")
|
|
||||||
|
|
||||||
sessionID, httpClientID, _, err := env.database.LoginUser(
|
sessionID, httpClientID, _, err := env.database.LoginUser(
|
||||||
t.Context(), "alice", password, "127.0.0.1", "localhost",
|
t.Context(), "alice", password, "127.0.0.1", "localhost",
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in new issue
Block a user