From 78ee588538721a2c65334f5da1b500198e674ff4 Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Wed, 9 Jun 2021 13:41:17 -0700 Subject: [PATCH] More test fixes --- model/profile_test.go | 8 ++++++++ storage/profile_store_test.go | 3 +++ storage/v1/profile_store_test.go | 6 ++++++ 3 files changed, 17 insertions(+) diff --git a/model/profile_test.go b/model/profile_test.go index 0dba56e..2cd8ae5 100644 --- a/model/profile_test.go +++ b/model/profile_test.go @@ -62,6 +62,8 @@ func TestRejectGroupInvite(t *testing.T) { alice := GenerateNewProfile("Alice") sarah.AddContact(alice.Onion, &alice.PublicProfile) alice.AddContact(sarah.Onion, &sarah.PublicProfile) + // The lightest weight server entry possible (usually we would import a key bundle...) + sarah.AddContact("2c3kmoobnyghj2zw6pwv7d57yzld753auo3ugauezzpvfak3ahc4bdyd", &PublicProfile{Attributes: map[string]string{string(KeyTypeServerOnion): "2c3kmoobnyghj2zw6pwv7d57yzld753auo3ugauezzpvfak3ahc4bdyd"}}) gid, invite, _ := alice.StartGroup("2c3kmoobnyghj2zw6pwv7d57yzld753auo3ugauezzpvfak3ahc4bdyd") sarah.ProcessInvite(invite) @@ -86,6 +88,9 @@ func TestProfileGroup(t *testing.T) { alice.AddContact(sarah.Onion, &sarah.PublicProfile) gid, invite, _ := alice.StartGroup("2c3kmoobnyghj2zw6pwv7d57yzld753auo3ugauezzpvfak3ahc4bdyd") + + // The lightest weight server entry possible (usually we would import a key bundle...) + sarah.AddContact("2c3kmoobnyghj2zw6pwv7d57yzld753auo3ugauezzpvfak3ahc4bdyd", &PublicProfile{Attributes: map[string]string{string(KeyTypeServerOnion): "2c3kmoobnyghj2zw6pwv7d57yzld753auo3ugauezzpvfak3ahc4bdyd"}}) sarah.ProcessInvite(invite) if len(sarah.GetGroups()) != 1 { t.Errorf("sarah should only be in 1 group instead: %v", sarah.GetGroups()) @@ -109,6 +114,9 @@ func TestProfileGroup(t *testing.T) { bob := GenerateNewProfile("bob") bob.AddContact(alice.Onion, &alice.PublicProfile) + // The lightest weight server entry possible (usually we would import a key bundle...) + bob.AddContact("2c3kmoobnyghj2zw6pwv7d57yzld753auo3ugauezzpvfak3ahc4bdyd", &PublicProfile{Attributes: map[string]string{string(KeyTypeServerOnion): "2c3kmoobnyghj2zw6pwv7d57yzld753auo3ugauezzpvfak3ahc4bdyd"}}) + bob.ProcessInvite(invite2) c3, s3, err := bob.EncryptMessageToGroup("Bobs Message", group2.GroupID) if err == nil { diff --git a/storage/profile_store_test.go b/storage/profile_store_test.go index e9f8a44..fcec0a3 100644 --- a/storage/profile_store_test.go +++ b/storage/profile_store_test.go @@ -4,6 +4,7 @@ package storage import ( "cwtch.im/cwtch/event" + "cwtch.im/cwtch/model" "cwtch.im/cwtch/storage/v0" "fmt" "git.openprivacy.ca/openprivacy/log" @@ -32,6 +33,8 @@ func TestProfileStoreUpgradeV0toV1(t *testing.T) { fmt.Println("Creating and initializing v0 profile and store...") profile := NewProfile(testProfileName) + profile.AddContact("2c3kmoobnyghj2zw6pwv7d57yzld753auo3ugauezzpvfak3ahc4bdyd", &model.PublicProfile{Attributes: map[string]string{string(model.KeyTypeServerOnion): "2c3kmoobnyghj2zw6pwv7d57yzld753auo3ugauezzpvfak3ahc4bdyd"}}) + ps1 := v0.NewProfileWriterStore(eventBus, testingDir, password, profile) groupid, invite, err := profile.StartGroup("2c3kmoobnyghj2zw6pwv7d57yzld753auo3ugauezzpvfak3ahc4bdyd") diff --git a/storage/v1/profile_store_test.go b/storage/v1/profile_store_test.go index ae23fd3..1fb8133 100644 --- a/storage/v1/profile_store_test.go +++ b/storage/v1/profile_store_test.go @@ -4,6 +4,7 @@ package v1 import ( "cwtch.im/cwtch/event" + "cwtch.im/cwtch/model" "fmt" "log" "os" @@ -22,6 +23,9 @@ func TestProfileStoreWriteRead(t *testing.T) { os.RemoveAll(testingDir) eventBus := event.NewEventManager() profile := NewProfile(testProfileName) + // The lightest weight server entry possible (usually we would import a key bundle...) + profile.AddContact("2c3kmoobnyghj2zw6pwv7d57yzld753auo3ugauezzpvfak3ahc4bdyd", &model.PublicProfile{Attributes: map[string]string{string(model.KeyTypeServerOnion): "2c3kmoobnyghj2zw6pwv7d57yzld753auo3ugauezzpvfak3ahc4bdyd"}}) + ps1 := CreateProfileWriterStore(eventBus, testingDir, password, profile) eventBus.Publish(event.NewEvent(event.SetAttribute, map[event.Field]string{event.Key: testKey, event.Data: testVal})) @@ -79,6 +83,8 @@ func TestProfileStoreChangePassword(t *testing.T) { eventBus.Subscribe(event.ChangePasswordSuccess, queue) profile := NewProfile(testProfileName) + profile.AddContact("2c3kmoobnyghj2zw6pwv7d57yzld753auo3ugauezzpvfak3ahc4bdyd", &model.PublicProfile{Attributes: map[string]string{string(model.KeyTypeServerOnion): "2c3kmoobnyghj2zw6pwv7d57yzld753auo3ugauezzpvfak3ahc4bdyd"}}) + ps1 := CreateProfileWriterStore(eventBus, testingDir, password, profile) groupid, invite, err := profile.StartGroup("2c3kmoobnyghj2zw6pwv7d57yzld753auo3ugauezzpvfak3ahc4bdyd")