<commit_before>package main

import (
	"crypto/tls"
	"fmt"
	"io"
	"net/http"
	"os"
	"os/signal"
	"regexp"
	"strings"
	"syscall"
	"testing"
	"time"

	runner "github.com/adt-automation/goRunner/golib"
)

var port string

func TestXxx(*testing.T) {
	done := make(chan bool)
	sigs := make(chan os.Signal, 1)

	signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM, syscall.SIGKILL)

	go func() {
		<-sigs
		done <- true
	}()

	go http.ListenAndServe(":9009", nil)
	http.HandleFunc("/main", Landing)
	http.HandleFunc("/GetSession", ReturnSession)
	http.HandleFunc("/reqapi/check/token", HandleToken)
	http.HandleFunc("/reqapi/test/account/pass", HandleTicket)
	http.HandleFunc("/reqapi/test/account/pass/", HandleTicket2)

	runner.Delimeter = ","
	baseUrl := "http://localhost:9009"
	baseUrlFilter := regexp.MustCompile(baseUrl)
	configuration := runner.NewConfiguration2("test_public.ini")
	results := make(map[int]*runner.Result)
	transportConfig := &tls.Config{InsecureSkipVerify: true} //allow wrong ssl certs
	tr := &http.Transport{TLSClientConfig: transportConfig}
	tr.ResponseHeaderTimeout = time.Second * time.Duration(30) //timeout in seconds
	var stopTime time.Time                                     // client loops will work to the end of trafficChannel unless we explicitly init a stopTime
	result := &runner.Result{}
	results[0] = result
	msDelay := 0
	grep1, grep2 := "", ""
	id := "123"
	clientId := 0
	var cookieMap = make(map[string]*http.Cookie)
	var sessionVars = make(map[string]string)
	overallStartTime := time.Now()
	runner.DoReq(0, id, configuration, result, clientId, baseUrl, baseUrlFilter, msDelay, tr, cookieMap, sessionVars, grep1, grep2, stopTime, 0.0) //val,resp, err
	message, exitCode := runner.GetResults(results, time.Now())

	runner.PrintResults(message, overallStartTime)

	//	<-done //close websrver

	os.Exit(int(exitCode))

}

func ReturnSession(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("SESSIONVAR", "C1NC0d3M6Y0")
	w.WriteHeader(200)
	w.Write([]byte("TokenValue:=<EMAIL>"))
	io.WriteString(w, "Return SessionVariable, TokenValue=TOKEN, UserID in header")
}

func Landing(w http.ResponseWriter, r *http.Request) {<commit_msg>add header row to output csv<commit_after>package main

import (
	"crypto/tls"
	"fmt"
	"io"
	"net/http"
	"os"
	"os/signal"
	"regexp"
	"strings"
	"syscall"
	"testing"
	"time"

	runner "github.com/adt-automation/goRunner/golib"
)

var port string

func TestXxx(*testing.T) {
	done := make(chan bool)
	sigs := make(chan os.Signal, 1)

	signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM, syscall.SIGKILL)

	go func() {
		<-sigs
		done <- true
	}()

	go http.ListenAndServe(":9009", nil)
	http.HandleFunc("/main", Landing)
	http.HandleFunc("/GetSession", ReturnSession)
	http.HandleFunc("/reqapi/check/token", HandleToken)
	http.HandleFunc("/reqapi/test/account/pass", HandleTicket)
	http.HandleFunc("/reqapi/test/account/pass/", HandleTicket2)

	runner.Delimeter = ","
	baseUrl := "http://localhost:9009"
	baseUrlFilter := regexp.MustCompile(baseUrl)
	configuration := runner.NewConfiguration2("test_public.ini")
	results := make(map[int]*runner.Result)
	transportConfig := &tls.Config{InsecureSkipVerify: true} //allow wrong ssl certs
	tr := &http.Transport{TLSClientConfig: transportConfig}
	tr.ResponseHeaderTimeout = time.Second * time.Duration(30) //timeout in seconds
	var stopTime time.Time                                     // client loops will work to the end of trafficChannel unless we explicitly init a stopTime
	result := &runner.Result{}
	results[0] = result
	msDelay := 0
	grep1, grep2 := "", ""
	id := "123"
	clientId := 0
	var cookieMap = make(map[string]*http.Cookie)
	var sessionVars = make(map[string]string)
	overallStartTime := time.Now()
	d := runner.Delimeter
	fmt.Printf("startTime%vcommand%vnextCommand%vstep%vrequestType%vsessionKey%vsession%vgrep1%vgrep2%vid%vshortUrl%vstatusCode%vsessionVarsOk%vclientId%vbyteSize%vserver%vduration%vserverDuration\n", d, d, d, d, d, d, d, d, d, d, d, d, d, d, d, d, d)
	runner.DoReq(0, id, configuration, result, clientId, baseUrl, baseUrlFilter, msDelay, tr, cookieMap, sessionVars, grep1, grep2, stopTime, 0.0) //val,resp, err
	message, exitCode := runner.GetResults(results, time.Now())

	runner.PrintResults(message, overallStartTime)

	//	<-done //close websrver

	os.Exit(int(exitCode))

}

func ReturnSession(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("SESSIONVAR", "C1NC0d3M6Y0")
	w.WriteHeader(200)
	w.Write([]byte("TokenValue:=<EMAIL>.<EMAIL>.<EMAIL>"))
	io.WriteString(w, "Return SessionVariable, TokenValue=TOKEN, UserID in header")
}

func Landing(w http.ResponseWriter, r *http.Request) {
{'fraction_non_alphanumeric': 0.15003219575016097, 'fraction_numerical': 0.01502468340845675, 'mean_word_length': 4.869017632241814, 'pattern_counts': {'":': 2, '<': 13, '<?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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5902310', 'n_tokens_mistral': 1714, 'n_tokens_neox': 1640, 'n_words': 347}