2022-01-17 07:00:08 +00:00
|
|
|
package databag
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2022-01-18 06:56:00 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
2022-01-17 07:00:08 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestAttachAccount(t *testing.T) {
|
2022-01-18 06:56:00 +00:00
|
|
|
|
|
|
|
// acquire new token for attaching app
|
|
|
|
r, w, _ := NewRequest("POST", "/account/apps", nil)
|
|
|
|
SetBasicAuth(r, "user:pass");
|
|
|
|
AddAccountApp(w, r);
|
|
|
|
var token string
|
|
|
|
assert.NoError(t, ReadResponse(w, &token))
|
|
|
|
|
|
|
|
// attach app with token
|
|
|
|
app := AppData{
|
|
|
|
Name: "Appy",
|
|
|
|
Description: "A test app",
|
|
|
|
Url: "http://app.example.com",
|
|
|
|
};
|
|
|
|
r, w, _ = NewRequest("PUT", "/account/apps", &app)
|
|
|
|
SetBearerAuth(r, token)
|
|
|
|
SetAccountApp(w, r)
|
|
|
|
var access string
|
|
|
|
assert.NoError(t, ReadResponse(w, &access))
|
|
|
|
|
|
|
|
PrintMsg(access)
|
|
|
|
// autorize app
|
|
|
|
|
|
|
|
// set profile
|
2022-01-17 07:00:08 +00:00
|
|
|
}
|
|
|
|
|