databag/net/server/internal/ucAttachApp_test.go

39 lines
852 B
Go
Raw Normal View History

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))
// autorize app
r, w, _ = NewRequest("PUT", "/authorize", "aabbccdd")
SetBearerAuth(r, access);
Authorize(w, r);
var message DataMessage
assert.NoError(t, ReadResponse(w, &message))
2022-01-18 06:56:00 +00:00
// set profile
2022-01-17 07:00:08 +00:00
}