Skip to content

Commit

Permalink
Change numeric fields to be used as Numbers instead of Strings
Browse files Browse the repository at this point in the history
  • Loading branch information
en-milie committed May 11, 2022
1 parent 6b055ad commit 4a2e033
Show file tree
Hide file tree
Showing 141 changed files with 278 additions and 307 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.endava.cats.fuzzer.fields;

import com.endava.cats.args.FilesArguments;
import com.endava.cats.annotations.FieldFuzzer;
import com.endava.cats.args.FilesArguments;
import com.endava.cats.fuzzer.fields.base.BaseBoundaryFieldFuzzer;
import com.endava.cats.generator.simple.StringGenerator;
import com.endava.cats.io.ServiceCaller;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.endava.cats.fuzzer.fields;

import com.endava.cats.args.FilesArguments;
import com.endava.cats.annotations.FieldFuzzer;
import com.endava.cats.args.FilesArguments;
import com.endava.cats.fuzzer.fields.base.BaseBoundaryFieldFuzzer;
import com.endava.cats.generator.simple.NumberGenerator;
import com.endava.cats.io.ServiceCaller;
Expand Down Expand Up @@ -29,7 +29,7 @@ public List<Class<? extends Schema>> getSchemasThatTheFuzzerWillApplyTo() {
}

@Override
public String getBoundaryValue(Schema schema) {
public Number getBoundaryValue(Schema schema) {
return NumberGenerator.generateLeftBoundaryDecimalValue(schema);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.endava.cats.fuzzer.fields;

import com.endava.cats.args.FilesArguments;
import com.endava.cats.annotations.FieldFuzzer;
import com.endava.cats.args.FilesArguments;
import com.endava.cats.fuzzer.fields.base.BaseBoundaryFieldFuzzer;
import com.endava.cats.generator.simple.NumberGenerator;
import com.endava.cats.io.ServiceCaller;
Expand Down Expand Up @@ -29,7 +29,7 @@ public List<Class<? extends Schema>> getSchemasThatTheFuzzerWillApplyTo() {
}

@Override
public String getBoundaryValue(Schema schema) {
public Number getBoundaryValue(Schema schema) {
return NumberGenerator.generateRightBoundaryDecimalValue(schema);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.endava.cats.fuzzer.fields;

import com.endava.cats.args.FilesArguments;
import com.endava.cats.annotations.FieldFuzzer;
import com.endava.cats.args.FilesArguments;
import com.endava.cats.fuzzer.fields.base.BaseBoundaryFieldFuzzer;
import com.endava.cats.generator.simple.NumberGenerator;
import com.endava.cats.io.ServiceCaller;
Expand Down Expand Up @@ -35,7 +35,7 @@ public List<Class<? extends Schema>> getSchemasThatTheFuzzerWillApplyTo() {
}

@Override
public String getBoundaryValue(Schema schema) {
public Number getBoundaryValue(Schema schema) {
return NumberGenerator.generateDecimalValue(schema);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.endava.cats.fuzzer.fields;

import com.endava.cats.args.FilesArguments;
import com.endava.cats.annotations.FieldFuzzer;
import com.endava.cats.args.FilesArguments;
import com.endava.cats.fuzzer.fields.base.BaseBoundaryFieldFuzzer;
import com.endava.cats.generator.simple.NumberGenerator;
import com.endava.cats.io.ServiceCaller;
Expand Down Expand Up @@ -34,7 +34,7 @@ public List<Class<? extends Schema>> getSchemasThatTheFuzzerWillApplyTo() {
}

@Override
public String getBoundaryValue(Schema schema) {
public Object getBoundaryValue(Schema schema) {
return NumberGenerator.getExtremeNegativeDecimalValue(schema);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.endava.cats.fuzzer.fields;

import com.endava.cats.args.FilesArguments;
import com.endava.cats.annotations.FieldFuzzer;
import com.endava.cats.args.FilesArguments;
import com.endava.cats.fuzzer.fields.base.BaseBoundaryFieldFuzzer;
import com.endava.cats.generator.simple.NumberGenerator;
import com.endava.cats.io.ServiceCaller;
Expand Down Expand Up @@ -34,7 +34,7 @@ public List<Class<? extends Schema>> getSchemasThatTheFuzzerWillApplyTo() {
}

@Override
public String getBoundaryValue(Schema schema) {
public Number getBoundaryValue(Schema schema) {
return NumberGenerator.getExtremeNegativeIntegerValue(schema);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.endava.cats.fuzzer.fields;

import com.endava.cats.args.FilesArguments;
import com.endava.cats.annotations.FieldFuzzer;
import com.endava.cats.args.FilesArguments;
import com.endava.cats.fuzzer.fields.base.BaseBoundaryFieldFuzzer;
import com.endava.cats.generator.simple.NumberGenerator;
import com.endava.cats.io.ServiceCaller;
Expand Down Expand Up @@ -35,7 +35,7 @@ public List<Class<? extends Schema>> getSchemasThatTheFuzzerWillApplyTo() {
}

@Override
public String getBoundaryValue(Schema schema) {
public Number getBoundaryValue(Schema schema) {
return NumberGenerator.getExtremePositiveDecimalValue(schema);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.endava.cats.fuzzer.fields;

import com.endava.cats.args.FilesArguments;
import com.endava.cats.annotations.FieldFuzzer;
import com.endava.cats.args.FilesArguments;
import com.endava.cats.fuzzer.fields.base.BaseBoundaryFieldFuzzer;
import com.endava.cats.generator.simple.NumberGenerator;
import com.endava.cats.io.ServiceCaller;
Expand Down Expand Up @@ -34,7 +34,7 @@ public List<Class<? extends Schema>> getSchemasThatTheFuzzerWillApplyTo() {
}

@Override
public String getBoundaryValue(Schema schema) {
public Number getBoundaryValue(Schema schema) {
return NumberGenerator.getExtremePositiveIntegerValue(schema);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.endava.cats.fuzzer.fields;

import com.endava.cats.args.FilesArguments;
import com.endava.cats.annotations.FieldFuzzer;
import com.endava.cats.args.FilesArguments;
import com.endava.cats.fuzzer.fields.base.BaseBoundaryFieldFuzzer;
import com.endava.cats.generator.simple.NumberGenerator;
import com.endava.cats.io.ServiceCaller;
Expand Down Expand Up @@ -29,7 +29,7 @@ public List<Class<? extends Schema>> getSchemasThatTheFuzzerWillApplyTo() {
}

@Override
public String getBoundaryValue(Schema schema) {
public Number getBoundaryValue(Schema schema) {
return NumberGenerator.generateLeftBoundaryIntegerValue(schema);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.endava.cats.fuzzer.fields;

import com.endava.cats.args.FilesArguments;
import com.endava.cats.annotations.FieldFuzzer;
import com.endava.cats.args.FilesArguments;
import com.endava.cats.fuzzer.fields.base.BaseBoundaryFieldFuzzer;
import com.endava.cats.generator.simple.NumberGenerator;
import com.endava.cats.io.ServiceCaller;
Expand Down Expand Up @@ -29,7 +29,7 @@ public List<Class<? extends Schema>> getSchemasThatTheFuzzerWillApplyTo() {
}

@Override
public String getBoundaryValue(Schema schema) {
public Number getBoundaryValue(Schema schema) {
return NumberGenerator.generateRightBoundaryIntegerValue(schema);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.endava.cats.fuzzer.fields;

import com.endava.cats.args.FilesArguments;
import com.endava.cats.annotations.FieldFuzzer;
import com.endava.cats.args.FilesArguments;
import com.endava.cats.fuzzer.fields.base.BaseBoundaryFieldFuzzer;
import com.endava.cats.generator.simple.StringGenerator;
import com.endava.cats.io.ServiceCaller;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.endava.cats.fuzzer.fields;

import com.endava.cats.args.FilesArguments;
import com.endava.cats.annotations.FieldFuzzer;
import com.endava.cats.args.FilesArguments;
import com.endava.cats.fuzzer.fields.base.ExactValuesInFieldsFuzzer;
import com.endava.cats.io.ServiceCaller;
import com.endava.cats.report.TestCaseListener;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.endava.cats.fuzzer.fields;

import com.endava.cats.args.FilesArguments;
import com.endava.cats.annotations.FieldFuzzer;
import com.endava.cats.args.FilesArguments;
import com.endava.cats.fuzzer.fields.base.ExactValuesInFieldsFuzzer;
import com.endava.cats.io.ServiceCaller;
import com.endava.cats.report.TestCaseListener;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.endava.cats.fuzzer.fields;

import com.endava.cats.args.FilesArguments;
import com.endava.cats.annotations.FieldFuzzer;
import com.endava.cats.args.FilesArguments;
import com.endava.cats.fuzzer.fields.base.ExactValuesInFieldsFuzzer;
import com.endava.cats.io.ServiceCaller;
import com.endava.cats.report.TestCaseListener;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.endava.cats.fuzzer.fields;

import com.endava.cats.args.FilesArguments;
import com.endava.cats.annotations.FieldFuzzer;
import com.endava.cats.args.FilesArguments;
import com.endava.cats.fuzzer.fields.base.ExactValuesInFieldsFuzzer;
import com.endava.cats.io.ServiceCaller;
import com.endava.cats.report.TestCaseListener;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import com.endava.cats.io.ServiceData;
import com.endava.cats.model.CatsResponse;
import com.endava.cats.model.FuzzingData;
import com.endava.cats.report.TestCaseListener;
import com.endava.cats.model.util.JsonUtils;
import com.endava.cats.report.TestCaseListener;
import io.github.ludovicianul.prettylogger.PrettyLogger;
import io.github.ludovicianul.prettylogger.PrettyLoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.endava.cats.fuzzer.fields;

import com.endava.cats.args.FilesArguments;
import com.endava.cats.annotations.FieldFuzzer;
import com.endava.cats.args.FilesArguments;
import com.endava.cats.fuzzer.fields.base.BaseBoundaryFieldFuzzer;
import com.endava.cats.generator.simple.StringGenerator;
import com.endava.cats.io.ServiceCaller;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.endava.cats.fuzzer.fields;

import com.endava.cats.args.FilesArguments;
import com.endava.cats.annotations.FieldFuzzer;
import com.endava.cats.args.FilesArguments;
import com.endava.cats.fuzzer.fields.base.BaseBoundaryFieldFuzzer;
import com.endava.cats.generator.simple.StringGenerator;
import com.endava.cats.io.ServiceCaller;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.endava.cats.fuzzer.fields;

import com.endava.cats.args.FilesArguments;
import com.endava.cats.annotations.FieldFuzzer;
import com.endava.cats.args.FilesArguments;
import com.endava.cats.fuzzer.fields.base.BaseBoundaryFieldFuzzer;
import com.endava.cats.generator.format.FormatGenerator;
import com.endava.cats.io.ServiceCaller;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.endava.cats.fuzzer.fields;

import com.endava.cats.args.FilesArguments;
import com.endava.cats.annotations.FieldFuzzer;
import com.endava.cats.args.FilesArguments;
import com.endava.cats.fuzzer.fields.base.BaseBoundaryFieldFuzzer;
import com.endava.cats.generator.format.FormatGenerator;
import com.endava.cats.io.ServiceCaller;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.endava.cats.fuzzer.fields;

import com.endava.cats.args.FilesArguments;
import com.endava.cats.annotations.FieldFuzzer;
import com.endava.cats.args.FilesArguments;
import com.endava.cats.fuzzer.fields.base.BaseBoundaryFieldFuzzer;
import com.endava.cats.generator.simple.StringGenerator;
import com.endava.cats.io.ServiceCaller;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package com.endava.cats.fuzzer.fields;

import com.endava.cats.annotations.FieldFuzzer;
import com.endava.cats.args.FilesArguments;
import com.endava.cats.args.ProcessingArguments;
import com.endava.cats.annotations.FieldFuzzer;
import com.endava.cats.fuzzer.fields.base.ExpectOnly4XXBaseFieldsFuzzer;
import com.endava.cats.io.ServiceCaller;
import com.endava.cats.model.FuzzingData;
import com.endava.cats.model.FuzzingStrategy;
import com.endava.cats.model.util.PayloadUtils;
import com.endava.cats.report.TestCaseListener;
import com.endava.cats.util.CatsUtil;
import com.endava.cats.model.util.PayloadUtils;

import javax.inject.Singleton;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.endava.cats.fuzzer.fields;

import com.endava.cats.annotations.FieldFuzzer;
import com.endava.cats.args.FilesArguments;
import com.endava.cats.args.ProcessingArguments;
import com.endava.cats.annotations.FieldFuzzer;
import com.endava.cats.fuzzer.fields.base.ExpectOnly4XXBaseFieldsFuzzer;
import com.endava.cats.generator.simple.StringGenerator;
import com.endava.cats.io.ServiceCaller;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private boolean isRequestSchemaMatchingFuzzerType(Schema schema) {
* @param schema used to extract boundary information
* @return a value to be used for fuzzing
*/
public abstract String getBoundaryValue(Schema schema);
public abstract Object getBoundaryValue(Schema schema);

/**
* Override this to provide information about whether the current field has boundaries defined or not. For example a String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ protected void process(FuzzingData data, String fuzzedField, FuzzingStrategy fuz
if (this.isFuzzingPossible(data, fuzzedField, fuzzingStrategy)) {
logger.debug("Fuzzing possible...");
FuzzingResult fuzzingResult = catsUtil.replaceField(data.getPayload(), fuzzedField, fuzzingStrategy);
boolean isFuzzedValueMatchingPattern = this.isFuzzedValueMatchingPattern(fuzzingResult.getFuzzedValue(), data, fuzzedField);
boolean isFuzzedValueMatchingPattern = this.isFuzzedValueMatchingPattern(String.valueOf(fuzzingResult.getFuzzedValue()), data, fuzzedField);

ServiceData serviceData = ServiceData.builder().relativePath(data.getPath())
.headers(data.getHeaders()).payload(fuzzingResult.getJson()).httpMethod(data.getMethod())
Expand All @@ -92,7 +92,7 @@ protected void process(FuzzingData data, String fuzzedField, FuzzingStrategy fuz
} else {
logger.debug("Fuzzing not possible!");
FuzzingStrategy strategy = this.createSkipStrategy(fuzzingStrategy);
testCaseListener.skipTest(logger, strategy.process(""));
testCaseListener.skipTest(logger, (String) strategy.process(""));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package com.endava.cats.fuzzer.fields.leading;

import com.endava.cats.args.FilesArguments;
import com.endava.cats.annotations.ControlCharFuzzer;
import com.endava.cats.annotations.FieldFuzzer;
import com.endava.cats.annotations.TrimAndValidate;
import com.endava.cats.args.FilesArguments;
import com.endava.cats.fuzzer.fields.base.InvisibleCharsBaseTrimValidateFuzzer;
import com.endava.cats.io.ServiceCaller;
import com.endava.cats.model.FuzzingStrategy;
import com.endava.cats.model.util.PayloadUtils;
import com.endava.cats.report.TestCaseListener;
import com.endava.cats.util.CatsUtil;
import com.endava.cats.model.util.PayloadUtils;

import javax.inject.Singleton;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.endava.cats.fuzzer.fields.leading;

import com.endava.cats.args.FilesArguments;
import com.endava.cats.annotations.ControlCharFuzzer;
import com.endava.cats.annotations.FieldFuzzer;
import com.endava.cats.annotations.ValidateAndTrim;
import com.endava.cats.args.FilesArguments;
import com.endava.cats.http.ResponseCodeFamily;
import com.endava.cats.io.ServiceCaller;
import com.endava.cats.report.TestCaseListener;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package com.endava.cats.fuzzer.fields.leading;

import com.endava.cats.args.FilesArguments;
import com.endava.cats.annotations.EmojiFuzzer;
import com.endava.cats.annotations.FieldFuzzer;
import com.endava.cats.annotations.TrimAndValidate;
import com.endava.cats.args.FilesArguments;
import com.endava.cats.fuzzer.fields.base.InvisibleCharsBaseTrimValidateFuzzer;
import com.endava.cats.io.ServiceCaller;
import com.endava.cats.model.FuzzingStrategy;
import com.endava.cats.model.util.PayloadUtils;
import com.endava.cats.report.TestCaseListener;
import com.endava.cats.util.CatsUtil;
import com.endava.cats.model.util.PayloadUtils;

import javax.inject.Singleton;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.endava.cats.fuzzer.fields.leading;

import com.endava.cats.args.FilesArguments;
import com.endava.cats.annotations.EmojiFuzzer;
import com.endava.cats.annotations.FieldFuzzer;
import com.endava.cats.annotations.ValidateAndTrim;
import com.endava.cats.args.FilesArguments;
import com.endava.cats.http.ResponseCodeFamily;
import com.endava.cats.io.ServiceCaller;
import com.endava.cats.report.TestCaseListener;
Expand Down
Loading

0 comments on commit 4a2e033

Please sign in to comment.