2017-05-03 08:02:29 +02:00
|
|
|
// Package with supporting functionality to run the microservice
|
2017-04-07 11:56:28 +02:00
|
|
|
package runtime
|
2017-04-05 19:03:44 +02:00
|
|
|
|
|
|
|
import (
|
2017-04-07 11:32:49 +02:00
|
|
|
"net/http"
|
2017-04-05 19:03:44 +02:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
2017-05-03 08:02:29 +02:00
|
|
|
// Function to test the permission handling
|
2017-04-05 19:03:44 +02:00
|
|
|
func TestAuth(t *testing.T) {
|
|
|
|
assert := assert.New(t)
|
|
|
|
|
2017-04-07 13:13:37 +02:00
|
|
|
PermissionURL = "http://localhost:8080/api-test/session/%s/%d/"
|
2017-04-07 11:32:49 +02:00
|
|
|
router := http.FileServer(http.Dir("../webroot"))
|
|
|
|
srv := &http.Server{
|
|
|
|
Addr: ":8080",
|
|
|
|
Handler: router,
|
|
|
|
}
|
|
|
|
go srv.ListenAndServe()
|
|
|
|
|
|
|
|
perm, err := HasPermission("testsessionkey", PermissionCreateGood)
|
2017-04-05 19:03:44 +02:00
|
|
|
assert.NoError(err)
|
|
|
|
assert.True(perm)
|
2017-04-05 20:23:29 +02:00
|
|
|
|
2017-04-07 11:32:49 +02:00
|
|
|
perm, err = HasPermission("testsessionkey", PermissionCreateGood)
|
2017-04-05 20:23:29 +02:00
|
|
|
assert.NoError(err)
|
|
|
|
assert.True(perm)
|
2017-04-07 11:32:49 +02:00
|
|
|
|
|
|
|
srv.Close()
|
2017-04-05 19:03:44 +02:00
|
|
|
}
|