some work on auth/sessions

This commit is contained in:
simon987
2019-02-01 21:21:14 -05:00
parent d3188c512d
commit 9e09246a29
24 changed files with 265 additions and 66 deletions

View File

@@ -5,9 +5,9 @@ import (
"crypto"
"crypto/hmac"
"encoding/hex"
"github.com/simon987/task_tracker/api"
"github.com/simon987/task_tracker/config"
"net/http"
"src/task_tracker/api"
"src/task_tracker/config"
"testing"
)

View File

@@ -2,8 +2,8 @@ package test
import (
"encoding/json"
"github.com/simon987/task_tracker/api"
"io/ioutil"
"src/task_tracker/api"
"testing"
)

View File

@@ -4,9 +4,9 @@ import (
"encoding/json"
"fmt"
"github.com/Sirupsen/logrus"
"github.com/simon987/task_tracker/api"
"github.com/simon987/task_tracker/storage"
"io/ioutil"
"src/task_tracker/api"
"src/task_tracker/storage"
"testing"
"time"
)

View File

@@ -3,9 +3,9 @@ package test
import (
"encoding/json"
"fmt"
"github.com/simon987/task_tracker/api"
"io/ioutil"
"net/http"
"src/task_tracker/api"
"testing"
)

View File

@@ -1,9 +1,9 @@
package test
import (
"src/task_tracker/api"
"src/task_tracker/config"
"src/task_tracker/storage"
"github.com/simon987/task_tracker/api"
"github.com/simon987/task_tracker/config"
"github.com/simon987/task_tracker/storage"
"strconv"
"testing"
)
@@ -50,23 +50,3 @@ func BenchmarkCreateTask(b *testing.B) {
_ = db.SaveTask(&storage.Task{}, project, 0)
}
}
func TestTest(t *testing.T) {
config.SetupConfig()
db := storage.Database{}
project, _ := db.SaveProject(&storage.Project{
Priority: 1,
Id: 1,
Version: "bmcreatetask",
Public: true,
Motd: "bmcreatetask",
Name: "BenchmarkCreateTask",
GitRepo: "benchmark_test",
})
for i := 0; i < 1000000; i++ {
_ = db.SaveTask(&storage.Task{}, project, 0)
}
}

View File

@@ -3,9 +3,9 @@ package test
import (
"encoding/json"
"fmt"
"github.com/simon987/task_tracker/api"
"github.com/simon987/task_tracker/storage"
"io/ioutil"
"src/task_tracker/api"
"src/task_tracker/storage"
"testing"
)

View File

@@ -3,10 +3,10 @@ package test
import (
"encoding/json"
"fmt"
"github.com/simon987/task_tracker/api"
"github.com/simon987/task_tracker/storage"
"io/ioutil"
"net/http"
"src/task_tracker/api"
"src/task_tracker/storage"
"testing"
)

View File

@@ -7,11 +7,11 @@ import (
"encoding/hex"
"encoding/json"
"fmt"
"github.com/simon987/task_tracker/config"
"github.com/simon987/task_tracker/storage"
"io"
"io/ioutil"
"net/http"
"src/task_tracker/config"
"src/task_tracker/storage"
"strconv"
)

View File

@@ -3,8 +3,8 @@ server:
database:
conn_str: "user=task_tracker dbname=task_tracker_test sslmode=disable"
# log_levels: ["debug", "error"]
log_levels: ["debug", "error", "trace", "info", "warning"]
log_levels: ["debug", "error"]
# log_levels: ["debug", "error", "trace", "info", "warning"]
git:
webhook_secret: "very_secret_secret"
@@ -12,4 +12,8 @@ git:
webhook_sig_header: "X-Hub-Signature"
log:
level: "trace"
level: "trace"
session:
cookie_name: "tt"
expiration: "25m"

View File

@@ -1,8 +1,8 @@
package test
import (
"src/task_tracker/api"
"src/task_tracker/config"
"github.com/simon987/task_tracker/api"
"github.com/simon987/task_tracker/config"
"testing"
"time"
)

View File

@@ -1,5 +1,5 @@
DROP TABLE IF EXISTS worker_identity, worker, project, task, log_entry,
worker_has_access_to_project;
worker_has_access_to_project, manager, manager_has_role_on_project;
DROP TYPE IF EXISTS status;
DROP TYPE IF EXISTS log_level;
@@ -63,3 +63,17 @@ CREATE TABLE log_entry
timestamp INTEGER
);
CREATE TABLE manager
(
id SERIAL PRIMARY KEY,
username TEXT,
password TEXT,
website_admin BOOLEAN
);
CREATE TABLE manager_has_role_on_project
(
manager INTEGER REFERENCES manager (id),
role SMALLINT,
project INTEGER REFERENCES project (id)
);