mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-08-01 22:02:46 +00:00
Merge SenderID & Per Room User Key work (#3109)
This commit is contained in:
parent
7a2e325d10
commit
e4665979bf
75 changed files with 801 additions and 379 deletions
|
@ -193,6 +193,8 @@ type UserRoomKeys interface {
|
|||
InsertUserRoomPublicKey(ctx context.Context, txn *sql.Tx, userNID types.EventStateKeyNID, roomNID types.RoomNID, key ed25519.PublicKey) (ed25519.PublicKey, error)
|
||||
// SelectUserRoomPrivateKey selects the private key for the given user and room combination
|
||||
SelectUserRoomPrivateKey(ctx context.Context, txn *sql.Tx, userNID types.EventStateKeyNID, roomNID types.RoomNID) (ed25519.PrivateKey, error)
|
||||
// SelectUserRoomPublicKey selects the public key for the given user and room combination
|
||||
SelectUserRoomPublicKey(ctx context.Context, txn *sql.Tx, userNID types.EventStateKeyNID, roomNID types.RoomNID) (ed25519.PublicKey, error)
|
||||
// BulkSelectUserNIDs selects all userIDs for the requested senderKeys. Returns a map from publicKey -> types.UserRoomKeyPair.
|
||||
// If a senderKey can't be found, it is omitted in the result.
|
||||
BulkSelectUserNIDs(ctx context.Context, txn *sql.Tx, senderKeys map[types.RoomNID][]ed25519.PublicKey) (map[string]types.UserRoomKeyPair, error)
|
||||
|
|
|
@ -50,6 +50,7 @@ func TestUserRoomKeysTable(t *testing.T) {
|
|||
|
||||
err = sqlutil.WithTransaction(db, func(txn *sql.Tx) error {
|
||||
var gotKey, key2, key3 ed25519.PrivateKey
|
||||
var pubKey ed25519.PublicKey
|
||||
gotKey, err = tab.InsertUserRoomPrivatePublicKey(context.Background(), txn, userNID, roomNID, key)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, gotKey, key)
|
||||
|
@ -71,6 +72,9 @@ func TestUserRoomKeysTable(t *testing.T) {
|
|||
gotKey, err = tab.SelectUserRoomPrivateKey(context.Background(), txn, userNID, roomNID)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, key, gotKey)
|
||||
pubKey, err = tab.SelectUserRoomPublicKey(context.Background(), txn, userNID, roomNID)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, key.Public(), pubKey)
|
||||
|
||||
// try to update an existing key, this should only be done for users NOT on this homeserver
|
||||
var gotPubKey ed25519.PublicKey
|
||||
|
@ -82,6 +86,9 @@ func TestUserRoomKeysTable(t *testing.T) {
|
|||
gotKey, err = tab.SelectUserRoomPrivateKey(context.Background(), txn, userNID, 2)
|
||||
assert.NoError(t, err)
|
||||
assert.Nil(t, gotKey)
|
||||
pubKey, err = tab.SelectUserRoomPublicKey(context.Background(), txn, userNID, 2)
|
||||
assert.NoError(t, err)
|
||||
assert.Nil(t, pubKey)
|
||||
|
||||
// query user NIDs for senderKeys
|
||||
var gotKeys map[string]types.UserRoomKeyPair
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue