From a2354704fc91bb96e7496f0fff3c4a75552853d2 Mon Sep 17 00:00:00 2001 From: Roland Osborne Date: Fri, 21 Jan 2022 15:08:52 -0800 Subject: [PATCH] adding profile test --- net/server/internal/cardUtil.go | 1 + net/server/internal/contact_test.go | 16 +++++++++- .../internal/ucProfileNotification_test.go | 32 +++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 net/server/internal/ucProfileNotification_test.go diff --git a/net/server/internal/cardUtil.go b/net/server/internal/cardUtil.go index 1ef5d052..e3b5efe9 100644 --- a/net/server/internal/cardUtil.go +++ b/net/server/internal/cardUtil.go @@ -31,6 +31,7 @@ func getCardModel(card *store.Card) *Card { Revision: card.DataRevision, Status: card.Status, Notes: card.Notes, + Token: card.OutToken, Groups: groups, }, } diff --git a/net/server/internal/contact_test.go b/net/server/internal/contact_test.go index 7692dfa7..24a8521e 100644 --- a/net/server/internal/contact_test.go +++ b/net/server/internal/contact_test.go @@ -51,11 +51,13 @@ func AddTestContacts(t *testing.T, prefix string, count int) []string { return access } -func ConnectTestContacts(t *testing.T, access [2]string) { +func ConnectTestContacts(t *testing.T, accessA string, accessB string) (contact [2]string) { var card Card var msg DataMessage var vars map[string]string var contactStatus ContactStatus + var id string + access := [2]string{accessA, accessB} // get A identity message r, w, _ := NewRequest("GET", "/profile/message", nil) @@ -84,6 +86,7 @@ func ConnectTestContacts(t *testing.T, access [2]string) { SetBearerAuth(r, access[1]) GetOpenMessage(w, r) assert.NoError(t, ReadResponse(w, &msg)) + id = card.CardId // set open message in A r, w, _ = NewRequest("PUT", "/contact/openMessage", msg) @@ -136,4 +139,15 @@ func ConnectTestContacts(t *testing.T, access [2]string) { SetCardStatus(w, r) assert.NoError(t, ReadResponse(w, &card)) + // extract contact tokens + contact[0] = card.CardData.Token + r, w, _ = NewRequest("GET", "/contact/cards/{cardId}", nil) + vars = map[string]string{ "cardId": id } + r = mux.SetURLVars(r, vars) + SetBearerAuth(r, access[1]) + GetCard(w, r) + assert.NoError(t, ReadResponse(w, &card)) + contact[1] = card.CardData.Token + + return } diff --git a/net/server/internal/ucProfileNotification_test.go b/net/server/internal/ucProfileNotification_test.go new file mode 100644 index 00000000..52b04bdd --- /dev/null +++ b/net/server/internal/ucProfileNotification_test.go @@ -0,0 +1,32 @@ +package databag + +import ( + "testing" +) + +func TestProfileNotification(t *testing.T) { + + // start notifcation thread + go SendNotifications() + + access := AddTestContacts(t, "profilenotification", 2); + contact := ConnectTestContacts(t, access[0], access[1]) + + PrintMsg(access) + PrintMsg(contact) + + // connect revision websocket for A + + // get profile revision of B + + // update profile of B + + // read revision message + + // check card increment + + // check B profile incremented + + // stop notification thread + ExitNotifications() +}