mirror of
https://github.com/balzack/databag.git
synced 2025-02-14 20:49:16 +00:00
preparing connect use case
This commit is contained in:
parent
4d2ccfb6e4
commit
060f826da4
@ -20,18 +20,14 @@ func TestAttachAccount(t *testing.T) {
|
|||||||
SetBasicAuth(r, "admin:pass")
|
SetBasicAuth(r, "admin:pass")
|
||||||
AddNodeAccount(w, r)
|
AddNodeAccount(w, r)
|
||||||
var account string
|
var account string
|
||||||
if ReadResponse(w, &account) != nil {
|
assert.NoError(t, ReadResponse(w, &account))
|
||||||
panic("failed to create token")
|
|
||||||
}
|
|
||||||
|
|
||||||
// set account profile
|
// set account profile
|
||||||
r, w, _ = NewRequest("GET", "/account/profile", nil)
|
r, w, _ = NewRequest("GET", "/account/profile", nil)
|
||||||
SetBearerAuth(r, account);
|
SetBearerAuth(r, account);
|
||||||
SetCredentials(r, "attachapp:pass")
|
SetCredentials(r, "attachapp:pass")
|
||||||
AddAccount(w, r)
|
AddAccount(w, r)
|
||||||
if ReadResponse(w, nil) != nil {
|
assert.NoError(t, ReadResponse(w, nil))
|
||||||
panic("failed to create account")
|
|
||||||
}
|
|
||||||
|
|
||||||
// acquire new token for attaching app
|
// acquire new token for attaching app
|
||||||
r, w, _ = NewRequest("POST", "/account/apps", nil)
|
r, w, _ = NewRequest("POST", "/account/apps", nil)
|
||||||
|
@ -2,17 +2,71 @@ package databag
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestConnectContact(t *testing.T) {
|
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
|
// get B profile message
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user