<commit_before>/**
 * @file auth.go
 * @author <NAME> jollheef<AT>riseup.net
 * @license GNU AGPLv3
 * @date September, 2016
 * @brief test auth
 */

package scoreboard

import (
	"net/http"
	"net/http/httptest"
	"testing"

	"github.com/jollheef/henhouse/db"
)

func TestGenSession(*testing.T) {
	s, err := genSession()
	if err != nil {
		panic(err)
	}

	if len(s) != 512 {
		panic("Session length mismatch")
	}
}

func TestSessionTeamID(*testing.T) {

	database, err := db.InitDatabase(dbPath)
	if err != nil {
		panic(err)
	}

	defer database.Close()

	err = addTestData(database, 20, 5, 5, "testFlag")
	if err != nil {
		panic(err)
	}

	w := httptest.NewRecorder()

	realTeamID := 1

	err = setSessionTeamID(database, w, realTeamID)
	if err != nil {
		panic(err)
	}

	resp := http.Response{Header: w.Header()}
	cookies := resp.Cookies()
	if len(cookies) == 0 {
		panic(err)
	}

	req := &http.Request{Header: http.Header{
		"Cookie": w.HeaderMap["Set-Cookie"]}}

	// set cookie to request
<commit_msg>Remove unneded comment<commit_after>/**
 * @file auth.go
 * @author <NAME> jollheef<AT>riseup.net
 * @license GNU AGPLv3
 * @date September, 2016
 * @brief test auth
 */

package scoreboard

import (
	"net/http"
	"net/http/httptest"
	"testing"

	"github.com/jollheef/henhouse/db"
)

func TestGenSession(*testing.T) {
	s, err := genSession()
	if err != nil {
		panic(err)
	}

	if len(s) != 512 {
		panic("Session length mismatch")
	}
}

func TestSessionTeamID(*testing.T) {

	database, err := db.InitDatabase(dbPath)
	if err != nil {
		panic(err)
	}

	defer database.Close()

	err = addTestData(database, 20, 5, 5, "testFlag")
	if err != nil {
		panic(err)
	}

	w := httptest.NewRecorder()

	realTeamID := 1

	err = setSessionTeamID(database, w, realTeamID)
	if err != nil {
		panic(err)
	}

	resp := http.Response{Header: w.Header()}
	cookies := resp.Cookies()
	if len(cookies) == 0 {
		panic(err)
	}

	req := &http.Request{Header: http.Header{
		"Cookie": w.HeaderMap["Set-Cookie"]}}

{'fraction_non_alphanumeric': 0.16498993963782696, 'fraction_numerical': 0.014084507042253521, 'mean_word_length': 3.713270142180095, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3272164', 'n_tokens_mistral': 841, 'n_tokens_neox': 777, 'n_words': 174}