-
Notifications
You must be signed in to change notification settings - Fork 2
fix: issues with letter sealing off groups #216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -211,6 +211,63 @@ func TestCacheGroupMemberMIDsPreservesRicherList(t *testing.T) { | |
| } | ||
| } | ||
|
|
||
| func TestGroupKeyFetchErrorAllowsLatestKeyPlaintextFallback(t *testing.T) { | ||
| err := groupKeyFetchError(0, errNotMember) | ||
|
|
||
| if !errors.Is(err, line.ErrNoUsableE2EEGroupKey) { | ||
| t.Fatalf("error = %v, want ErrNoUsableE2EEGroupKey", err) | ||
| } | ||
| if !errors.Is(err, errNotMember) { | ||
| t.Fatalf("error = %v, want not-member error to remain wrapped", err) | ||
| } | ||
| } | ||
|
|
||
| func TestGroupKeyFetchErrorPreservesSpecificKeyMembershipError(t *testing.T) { | ||
| err := groupKeyFetchError(123, errNotMember) | ||
|
|
||
| if !errors.Is(err, errNotMember) { | ||
| t.Fatalf("error = %v, want original not-member error", err) | ||
| } | ||
| if errors.Is(err, line.ErrNoUsableE2EEGroupKey) { | ||
| t.Fatalf("error = %v, specific group key lookup must not allow plaintext fallback", err) | ||
| } | ||
| } | ||
|
|
||
| func TestRegisterGroupKeyAllowsPlaintextFallbackWithoutKnownMembers(t *testing.T) { | ||
| lc := newPeerKeyTestClient() | ||
| lc.Mid = "U-self" | ||
|
|
||
| err := lc.registerGroupKey(context.Background(), "C-group", []string{"U-self"}) | ||
| if !errors.Is(err, line.ErrNoUsableE2EEGroupKey) { | ||
| t.Fatalf("error = %v, want ErrNoUsableE2EEGroupKey", err) | ||
| } | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test doesn't exercise the intended path: |
||
|
|
||
| func TestJoinedGroupMemberMIDsExcludeInvitees(t *testing.T) { | ||
| group := &line.GroupExtra{ | ||
| MemberMids: line.FlexibleMidMap{ | ||
| "U-self": true, | ||
| "U-member": true, | ||
| }, | ||
| InviteeMids: line.FlexibleMidMap{ | ||
| "U-invitee": true, | ||
| }, | ||
| } | ||
|
|
||
| mids, hasPendingInvitees := joinedGroupMemberMIDs(group, "U-self") | ||
| if !hasPendingInvitees { | ||
| t.Fatal("hasPendingInvitees = false, want true") | ||
| } | ||
| if len(mids) != 2 { | ||
| t.Fatalf("joined mids = %v, want self and joined member only", mids) | ||
| } | ||
| for _, mid := range mids { | ||
| if mid == "U-invitee" { | ||
| t.Fatalf("joined mids unexpectedly contain pending invitee: %v", mids) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| func TestResolveGroupMemberPublicKeysFillsPartialBatchResponse(t *testing.T) { | ||
| oldGetLast := getLastE2EEPublicKeysWithClient | ||
| oldNegotiate := negotiateE2EEPublicKeyWithClient | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| package line | ||
|
|
||
| import ( | ||
| "encoding/json" | ||
| "testing" | ||
| ) | ||
|
|
||
| func TestFlexibleMidMapUnmarshalJSON(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| data string | ||
| want []string | ||
| }{ | ||
| { | ||
| name: "string valued object", | ||
| data: `{"U-one":"first","U-two":"second"}`, | ||
| want: []string{"U-one", "U-two"}, | ||
| }, | ||
| { | ||
| name: "boolean valued object", | ||
| data: `{"U-one":true,"U-two":false}`, | ||
| want: []string{"U-one", "U-two"}, | ||
| }, | ||
| { | ||
| name: "array", | ||
| data: `["U-one","U-two"]`, | ||
| want: []string{"U-one", "U-two"}, | ||
| }, | ||
| } | ||
|
|
||
| for _, test := range tests { | ||
| t.Run(test.name, func(t *testing.T) { | ||
| var got FlexibleMidMap | ||
| if err := json.Unmarshal([]byte(test.data), &got); err != nil { | ||
| t.Fatalf("Unmarshal returned error: %v", err) | ||
| } | ||
| if len(got) != len(test.want) { | ||
| t.Fatalf("decoded MIDs = %v, want %v", got, test.want) | ||
| } | ||
| for _, mid := range test.want { | ||
| if !got[mid] { | ||
| t.Errorf("decoded MIDs = %v, missing %s", got, mid) | ||
| } | ||
| } | ||
| }) | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doc missing new return value: Comment above explains "why invitees are excluded" but doesn't document that the signature now returns
(mids []string, hasPendingInvitees bool, error). A short line noting that the bool is used byautoRegisterGroupKeyto gate self-only fallbacks would keep the contract clear for future readers.