preparing connect use case

This commit is contained in:
Roland Osborne 2022-01-19 20:25:20 -08:00
parent 4d2ccfb6e4
commit 060f826da4
2 changed files with 60 additions and 10 deletions

View File

@ -20,18 +20,14 @@ func TestAttachAccount(t *testing.T) {
SetBasicAuth(r, "admin:pass")
AddNodeAccount(w, r)
var account string
if ReadResponse(w, &account) != nil {
panic("failed to create token")
}
assert.NoError(t, ReadResponse(w, &account))
// set account profile
r, w, _ = NewRequest("GET", "/account/profile", nil)
SetBearerAuth(r, account);
SetCredentials(r, "attachapp:pass")
AddAccount(w, r)
if ReadResponse(w, nil) != nil {
panic("failed to create account")
}
assert.NoError(t, ReadResponse(w, nil))
// acquire new token for attaching app
r, w, _ = NewRequest("POST", "/account/apps", nil)

View File

@ -2,17 +2,71 @@ package databag
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestConnectContact(t *testing.T) {
// create A
app := AppData{
Name: "Appy",
Description: "A test app",
Url: "http://app.example.com",
};
var token string
// A profile update
// get account token
r, w, _ := NewRequest("POST", "/admin/accounts", nil)
SetBasicAuth(r, "admin:pass")
AddNodeAccount(w, r)
assert.NoError(t, ReadResponse(w, &token))
// set account profile
r, w, _ = NewRequest("GET", "/account/profile", nil)
SetBearerAuth(r, token);
SetCredentials(r, "connecta:pass")
AddAccount(w, r)
assert.NoError(t, ReadResponse(w, nil))
// acquire new token for attaching app
r, w, _ = NewRequest("POST", "/account/apps", nil)
SetBasicAuth(r, "attachapp:pass");
AddAccountApp(w, r);
assert.NoError(t, ReadResponse(w, &token))
// attach app with token
r, w, _ = NewRequest("PUT", "/account/apps", &app)
SetBearerAuth(r, token)
SetAccountApp(w, r)
var aToken string
assert.NoError(t, ReadResponse(w, &aToken))
// get account token
r, w, _ = NewRequest("POST", "/admin/accounts", nil)
SetBasicAuth(r, "admin:pass")
AddNodeAccount(w, r)
assert.NoError(t, ReadResponse(w, &token))
// set account profile
r, w, _ = NewRequest("GET", "/account/profile", nil)
SetBearerAuth(r, token);
SetCredentials(r, "connectb:pass")
AddAccount(w, r)
assert.NoError(t, ReadResponse(w, nil))
// acquire new token for attaching app
r, w, _ = NewRequest("POST", "/account/apps", nil)
SetBasicAuth(r, "attachapp:pass");
AddAccountApp(w, r);
assert.NoError(t, ReadResponse(w, &token))
// attach app with token
r, w, _ = NewRequest("PUT", "/account/apps", &app)
SetBearerAuth(r, token)
SetAccountApp(w, r)
var bToken string
assert.NoError(t, ReadResponse(w, &bToken))
// create B
// B profile update
// get B profile message