<commit_before>package ticket_test

import (
	"github.com/calmh/mole/ticket"
	"testing"
)

func TestGrantVerify(t *testing.T) {
	tic := ticket.Grant("jb", "10.2.3.4", 1234567890)

	user, err := ticket.Verify(tic, "10.2.3.4", 1234567890)
	if user != "jb" {
		t.Errorf("unexpected user %q", user)
	}
	if err != nil {
		t.Errorf("unexpected err %s", err)
	}

	user, err = ticket.Verify(tic, "10.2.3.5", 1234567890)
	if user != "" {
		t.Errorf("unexpected user %q", user)
	}
	if err == nil {
		t.Errorf("unexpected nil err")
	}

	user, err = ticket.Verify(tic, "10.2.3.4", 1234567891)
	if user != "" {
		t.Errorf("unexpected user %q", user)
	}
	if err == nil {
		t.Errorf("unexpected nil err")
	}

	fail := "A" + tic[:len(tic)-1]
	user, err = ticket.Verify(fail, "10.2.3.4", 1234567890)
	if user != "" {
		t.Errorf("unexpected user %q", user)
	}
	if err == nil {
		t.Errorf("unexpected nil err")
	}

	ticket.Init()

	user, err = ticket.Verify(tic, "10.2.3.4", 1234567890)
	if user != "" {
		t.Errorf("unexpected user %q", user)
	}
	if err == nil {
		t.Errorf("unexpected nil err")
	}
}<commit_msg>Split up tests a bit<commit_after>package ticket_test

import (
	"github.com/calmh/mole/ticket"
	"testing"
)

func TestGrantVerifyOK(t *testing.T) {
	tic := ticket.Grant("jb", "10.2.3.4", 1234567890)

	user, err := ticket.Verify(tic, "10.2.3.4", 1234567890)
	if user != "jb" {
		t.Errorf("unexpected user %q", user)
	}
	if err != nil {
		t.Errorf("unexpected err %s", err)
	}
}

func TestGrantVerifyIncorrectIP(t *testing.T) {
	tic := ticket.Grant("jb", "10.2.3.4", 1234567890)

	user, err := ticket.Verify(tic, "10.2.3.5", 1234567890)
	if user != "" {
		t.Errorf("unexpected user %q", user)
	}
	if err == nil {
		t.Errorf("unexpected nil err")
	}
}

func TestGrantVerifyExpired(t *testing.T) {
	tic := ticket.Grant("jb", "10.2.3.4", 1234567890)

	user, err := ticket.Verify(tic, "10.2.3.4", 1234567891)
	if user != "" {
		t.Errorf("unexpected user %q", user)
	}
	if err == nil {
		t.Errorf("unexpected nil err")
	}
}

func TestGrantVerifyModified(t *testing.T) {
	tic := ticket.Grant("jb", "10.2.3.4", 1234567890)

	fail := "A" + tic[:len(tic)-1]
	user, err := ticket.Verify(fail, "10.2.3.4", 1234567890)
	if user != "" {
		t.Errorf("unexpected user %q", user)
	}
	if err == nil {
		t.Errorf("unexpected nil err")
	}
}

func TestGrantVerifyReinitialized(t *testing.T) {
	tic := ticket.Grant("jb", "10.2.3.4", 1234567890)

	ticket.Init()

	user, err := ticket.Verify(tic, "10.2.3.4", 1234567890)
	if user != "" {
		t.Errorf("unexpected user %q", user)
	}
	if err == nil {
		t.Errorf("unexpected nil err")
	}
}
{'fraction_non_alphanumeric': 0.2013835511145273, 'fraction_numerical': 0.0930053804765565, 'mean_word_length': 3.5908289241622575, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 16, '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': '2720411', 'n_tokens_mistral': 1298, 'n_tokens_neox': 1111, 'n_words': 238}