Skip to content

Commit

Permalink
Merge pull request #6900 from DataDog/bbujon/fix-test-names
Browse files Browse the repository at this point in the history
Fix test names to be unique
  • Loading branch information
PerfectSlayer authored Apr 15, 2024
2 parents 25e3c44 + 1df3d98 commit 0b58fab
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class BufferInstrumentationTest extends AgentTestRunner {
injectSysConfig('dd.iast.enabled', 'true')
}

void 'test that toString() is instrumented'() {
void 'test that Buffer.#methodName is instrumented'() {
given:
final module = Mock(PropagationModule)
InstrumentationBridge.registerIastModule(module)
Expand All @@ -30,12 +30,12 @@ class BufferInstrumentationTest extends AgentTestRunner {
1 * module.taintIfTainted(_, buffer)

where:
_ | method
_ | { Buffer b -> b.toString() }
_ | { Buffer b -> b.toString('UTF-8') }
methodName | method
'toString()' | { Buffer b -> b.toString() }
'toString(String)' | { Buffer b -> b.toString('UTF-8') }
}

void 'test that append() is instrumented'() {
void 'test that Buffer.#methodName is instrumented'() {
given:
final module = Mock(PropagationModule)
InstrumentationBridge.registerIastModule(module)
Expand All @@ -49,9 +49,9 @@ class BufferInstrumentationTest extends AgentTestRunner {
1 * module.taintIfTainted(buffer, tainted)

where:
_ | method
_ | { Buffer b, Buffer taint -> b.appendBuffer(taint) }
_ | { Buffer b, Buffer taint -> b.appendBuffer(taint, 0, taint.length()) }
methodName | method
'appendBuffer(Buffer)' | { Buffer b, Buffer taint -> b.appendBuffer(taint) }
'appendBuffer(buffer, int, int)' | { Buffer b, Buffer taint -> b.appendBuffer(taint, 0, taint.length()) }
}

private Buffer taintedInstance(final byte origin) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class HeadersAdaptorInstrumentationTest extends AgentTestRunner {
iastCtx = Stub(IastContext)
}

void 'test that get() is instrumented'() {
void 'test that #name get() is instrumented'() {
given:
final module = Mock(PropagationModule)
InstrumentationBridge.registerIastModule(module)
Expand All @@ -42,12 +42,12 @@ class HeadersAdaptorInstrumentationTest extends AgentTestRunner {
1 * module.taintIfTainted(iastCtx, 'value', headers, SourceTypes.REQUEST_HEADER_VALUE, 'key')
where:
headers | _
httpAdaptor() | _
http2Adaptor() | _
headers | name
httpAdaptor() | 'HeadersAdaptor'
http2Adaptor() | 'Http2HeadersAdaptor'
}
void 'test that getAll() is instrumented'() {
void 'test that #name getAll() is instrumented'() {
given:
final module = Mock(PropagationModule)
InstrumentationBridge.registerIastModule(module)
Expand All @@ -69,12 +69,12 @@ class HeadersAdaptorInstrumentationTest extends AgentTestRunner {
1 * module.taint(iastCtx, 'value2', SourceTypes.REQUEST_HEADER_VALUE, 'key')
where:
headers | _
httpAdaptor() | _
http2Adaptor() | _
headers | name
httpAdaptor() | 'HeadersAdaptor'
http2Adaptor() | 'Http2HeadersAdaptor'
}
void 'test that names() is instrumented'() {
void 'test that #name names() is instrumented'() {
given:
final module = Mock(PropagationModule)
InstrumentationBridge.registerIastModule(module)
Expand All @@ -95,12 +95,12 @@ class HeadersAdaptorInstrumentationTest extends AgentTestRunner {
1 * module.taint(iastCtx, 'key', SourceTypes.REQUEST_HEADER_NAME, 'key')
where:
headers | _
httpAdaptor() | _
http2Adaptor() | _
headers | name
httpAdaptor() | 'HeadersAdaptor'
http2Adaptor() | 'Http2HeadersAdaptor'
}
void 'test that entries() is instrumented'() {
void 'test that #name entries() is instrumented'() {
given:
// latest versions of vertx 3.x define the entries in the MultiMap interface, so we will lose propagation
Assume.assumeTrue(hasMethod(headers.getClass(), 'entries'))
Expand Down Expand Up @@ -128,9 +128,9 @@ class HeadersAdaptorInstrumentationTest extends AgentTestRunner {
}
where:
headers | _
httpAdaptor() | _
http2Adaptor() | _
headers | name
httpAdaptor() | 'HeadersAdaptor'
http2Adaptor() | 'Http2HeadersAdaptor'
}
protected <E> E runUnderIastTrace(Closure<E> cl) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class BufferInstrumentationTest extends AgentTestRunner {
injectSysConfig('dd.iast.enabled', 'true')
}

void 'test that toString() is instrumented'() {
void 'test that Buffer.#methodName is instrumented'() {
given:
final module = Mock(PropagationModule)
InstrumentationBridge.registerIastModule(module)
Expand All @@ -30,12 +30,12 @@ class BufferInstrumentationTest extends AgentTestRunner {
1 * module.taintIfTainted(_, buffer)

where:
_ | method
_ | { Buffer b -> b.toString() }
_ | { Buffer b -> b.toString('UTF-8') }
methodName | method
'toString()' | { Buffer b -> b.toString() }
'toString(String)' | { Buffer b -> b.toString('UTF-8') }
}

void 'test that append() is instrumented'() {
void 'test that Buffer.#methodName is instrumented'() {
given:
final module = Mock(PropagationModule)
InstrumentationBridge.registerIastModule(module)
Expand All @@ -49,9 +49,9 @@ class BufferInstrumentationTest extends AgentTestRunner {
1 * module.taintIfTainted(buffer, tainted)

where:
_ | method
_ | { Buffer b, Buffer taint -> b.appendBuffer(taint) }
_ | { Buffer b, Buffer taint -> b.appendBuffer(taint, 0, taint.length()) }
methodName | method
'appendBuffer(Buffer)' | { Buffer b, Buffer taint -> b.appendBuffer(taint) }
'appendBuffer(buffer, int, int)' | { Buffer b, Buffer taint -> b.appendBuffer(taint, 0, taint.length()) }
}

private Buffer taintedInstance(final byte origin) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class MultiMapInstrumentationTest extends AgentTestRunner {
iastCtx = Stub(IastContext)
}

void 'test that get() is instrumented'() {
void 'test that #name get() is instrumented'() {
given:
final origin = SourceTypes.REQUEST_PARAMETER_VALUE
addAll([key: 'value'], instance)
Expand All @@ -56,9 +56,10 @@ class MultiMapInstrumentationTest extends AgentTestRunner {
where:
instance << multiMaps()
name = instance.getClass().simpleName
}
void 'test that getAll() is instrumented'() {
void 'test that #name getAll() is instrumented'() {
given:
final origin = SourceTypes.REQUEST_PARAMETER_VALUE
addAll([[key: 'value1'], [key: 'value2']], instance)
Expand All @@ -82,9 +83,10 @@ class MultiMapInstrumentationTest extends AgentTestRunner {
where:
instance << multiMaps()
name = instance.getClass().simpleName
}
void 'test that names() is instrumented'() {
void 'test that #name names() is instrumented'() {
given:
final origin = SourceTypes.REQUEST_PARAMETER_VALUE
addAll([[key: 'value1'], [key: 'value2']], instance)
Expand All @@ -107,11 +109,12 @@ class MultiMapInstrumentationTest extends AgentTestRunner {
where:
instance << multiMaps()
name = instance.getClass().simpleName
}
// some implementations do not override the entries() method so we will lose propagation in those cases
@IgnoreIf({ !MultiMapInstrumentationTest.hasMethod(data['instance'].class, 'entries')})
void 'test that entries() is instrumented'() {
void 'test that #name entries() is instrumented'() {
given:
final origin = SourceTypes.REQUEST_PARAMETER_VALUE
addAll([[key: 'value1'], [key: 'value2']], instance)
Expand All @@ -136,6 +139,7 @@ class MultiMapInstrumentationTest extends AgentTestRunner {
where:
instance << multiMaps()
name = instance.getClass().simpleName
}
protected <E> E runUnderIastTrace(Closure<E> cl) {
Expand Down

0 comments on commit 0b58fab

Please sign in to comment.