Skip to content

Commit

Permalink
fix: Insecure option is not applied when use -i option
Browse files Browse the repository at this point in the history
  • Loading branch information
chonla committed Jul 28, 2024
1 parent 5920bed commit f839d19
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
16 changes: 9 additions & 7 deletions internal/executable/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ import (
)

type ParserOptions struct {
Configurator *config.Config
FileReader reader.Reader
RequestParser httphelper.RequestParser
Logger logger.Logger
ClockWrapper clock.ClockWrapper
Configurator *config.Config
FileReader reader.Reader
RequestParser httphelper.RequestParser
Logger logger.Logger
ClockWrapper clock.ClockWrapper
InsecureRequest bool
}

type Parser interface {
Expand Down Expand Up @@ -163,8 +164,9 @@ func (p *ExecutableParser) FromMarkdownLines(mdLines []line.Line) (*Executable,
}

options := &ExecutableOptions{
RequestParser: p.options.RequestParser,
Logger: p.options.Logger,
RequestParser: p.options.RequestParser,
Logger: p.options.Logger,
InsecureRequest: p.options.InsecureRequest,
}
ex := New(title, reqRaw, options)
for _, cap := range captures {
Expand Down
8 changes: 5 additions & 3 deletions internal/testcase/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type ParserOptions struct {
ExecutableParser executable.Parser
Logger logger.Logger
ClockWrapper clock.ClockWrapper
InsecureRequest bool
}

type Parser struct {
Expand Down Expand Up @@ -252,9 +253,10 @@ func (p *Parser) FromMarkdownLines(mdLines []line.Line) (*Testcase, error) {
p.options.Logger.PrintDetailedDebugMessage("==========")

options := &TestcaseOptions{
RequestParser: p.options.RequestParser,
Logger: p.options.Logger,
ClockWrapper: p.options.ClockWrapper,
RequestParser: p.options.RequestParser,
Logger: p.options.Logger,
ClockWrapper: p.options.ClockWrapper,
InsecureRequest: p.options.InsecureRequest,
}
tc := NewTestcase(title, line.Line(strings.Join(description, "\n")).Trim().Value(), reqRaw, options)
for _, cap := range captures {
Expand Down
14 changes: 8 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,12 @@ func main() {
clockWrapper := clock.New()

exOptions := &executable.ParserOptions{
Configurator: config,
FileReader: reader,
RequestParser: reqParser,
Logger: log,
ClockWrapper: clockWrapper,
Configurator: config,
FileReader: reader,
RequestParser: reqParser,
Logger: log,
ClockWrapper: clockWrapper,
InsecureRequest: insecure,
}
exParser := executable.NewParser(exOptions)

Expand All @@ -104,6 +105,7 @@ func main() {
Logger: log,
ExecutableParser: exParser,
ClockWrapper: clockWrapper,
InsecureRequest: insecure,
}

options := &testcase.TestsuiteOptions{
Expand All @@ -130,7 +132,7 @@ func main() {
func usage() {
fmt.Fprintf(flag.CommandLine.Output(), `Usage of cotton:
cotton [-d] [-c] [-p] [-b <basedir>] [-r <reporttype>] <testpath|testdir>
cotton [-d] [-c] [-p] [-i] [-b <basedir>] [-r <reporttype>] <testpath|testdir>
cotton -v
cotton --help
Expand Down

0 comments on commit f839d19

Please sign in to comment.