Skip to content

Commit 6a0380a

Browse files
committed
Release: 0.42.5
Fix request level auth Signed-off-by: Gopal S Akshintala <[email protected]>
1 parent 26913bf commit 6a0380a

File tree

8 files changed

+35
-27
lines changed

8 files changed

+35
-27
lines changed

README.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ endif::[]
1818
:pmtemplates: src/integrationTest/resources/pm-templates
1919
:imagesdir: docs/images
2020
:prewrap!:
21-
:revoman-version: 0.42.4
21+
:revoman-version: 0.42.5
2222

2323
'''
2424

buildSrc/src/main/kotlin/Config.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
* ************************************************************************************************
77
*/
88
const val GROUP_ID = "com.salesforce.revoman"
9-
const val VERSION = "0.42.4"
9+
const val VERSION = "0.42.5"
1010
const val ARTIFACT_ID = "revoman"
1111
const val STAGING_PROFILE_ID = "1ea0a23e61ba7d"

src/main/kotlin/com/salesforce/revoman/ReVoman.kt

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,15 @@ import org.http4k.core.Request
4343
import org.http4k.format.ConfigurableMoshi
4444

4545
object ReVoman {
46+
4647
@JvmStatic
47-
@OptIn(ExperimentalStdlibApi::class)
48-
fun revUp(vararg kicks: Kick): List<Rundown> =
48+
@JvmOverloads
49+
fun revUp(
50+
dynamicEnvironment: Map<String, String> = mapOf<String, String>(),
51+
vararg kicks: Kick
52+
): List<Rundown> =
4953
kicks
50-
.fold(mapOf<String, String>() to listOf<Rundown>()) { (accumulatedMutableEnv, rundowns), kick
51-
->
54+
.fold(dynamicEnvironment to listOf<Rundown>()) { (accumulatedMutableEnv, rundowns), kick ->
5255
val rundown =
5356
revUp(
5457
kick.overrideDynamicEnvironments(
@@ -67,10 +70,16 @@ object ReVoman {
6770
val pmStepsDeepFlattened =
6871
kick
6972
.templatePaths()
73+
.asSequence()
7074
.mapNotNull { pmTemplateAdapter.fromJson(bufferFileInResources(it)) }
7175
.flatMap { (pmSteps, authFromRoot) ->
72-
deepFlattenItems(pmSteps.map { it.copy(auth = it.auth ?: authFromRoot) })
76+
deepFlattenItems(
77+
pmSteps.map { item ->
78+
item.copy(request = item.request.copy(auth = item.request.auth ?: authFromRoot))
79+
}
80+
)
7381
}
82+
.toList()
7483
logger.info {
7584
val templateCount = kick.templatePaths().size
7685
"Total Steps from ${if (templateCount > 1) "$templateCount Collections" else "the Collection"} provided: ${pmStepsDeepFlattened.size}"
@@ -140,7 +149,7 @@ object ReVoman {
140149
pm.rundown = pm.rundown.copy(stepReports = pm.rundown.stepReports + sr)
141150
val item = regexReplacer.replaceVariablesInPmItem(itemWithRegex, pm)
142151
val httpRequest = item.request.toHttpRequest()
143-
fireHttpRequest(step, item.auth, httpRequest, kick.insecureHttp())
152+
fireHttpRequest(step, item.request.auth, httpRequest, kick.insecureHttp())
144153
.mapLeft { sr.copy(requestInfo = Left(it).toVavr()) }
145154
.map {
146155
sr.copy(

src/main/kotlin/com/salesforce/revoman/internal/exe/ExeUtils.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,16 @@ internal fun deepFlattenItems(
4343
if (stepIndexFromParent.isBlank()) "${itemIndex + 1}"
4444
else "$stepIndexFromParent.${itemIndex + 1}"
4545
item.item
46-
?.map { childItem -> childItem.copy(auth = childItem.auth ?: item.auth) }
46+
?.map { childItem ->
47+
childItem.copy(
48+
request = childItem.request.copy(auth = childItem.request.auth ?: item.request.auth)
49+
)
50+
}
4751
?.let {
4852
val currentFolder = Folder(item.name, parentFolder)
4953
parentFolder?.subFolders?.add(currentFolder)
5054
deepFlattenItems(it, currentFolder, stepIndex)
51-
} ?: listOf(Step(stepIndex, item.name, item.copy(auth = item.auth), parentFolder))
55+
} ?: listOf(Step(stepIndex, item, parentFolder))
5256
}
5357
.toList()
5458

@@ -121,7 +125,7 @@ internal fun shouldHaltExecution(
121125
}
122126
}
123127
}
124-
?.not() ?: true
128+
?.not() != false
125129
}
126130
}
127131

src/main/kotlin/com/salesforce/revoman/internal/postman/RegexReplacer.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,17 @@ class RegexReplacer(
5757
}
5858

5959
internal fun replaceVariablesInPmItem(item: Item, pm: PostmanSDK): Item =
60-
item.copy(
61-
request = replaceVariablesInRequestRecursively(item.request, pm),
62-
auth =
63-
item.auth?.copy(
64-
bearer = listOfNotNull(replaceVariablesInBearer(item.auth.bearer.firstOrNull(), pm))
65-
)
66-
)
60+
item.copy(request = replaceVariablesInRequestRecursively(item.request, pm))
6761

6862
private fun replaceVariablesInBearer(bearer: Bearer?, pm: PostmanSDK): Bearer? =
6963
bearer?.copy(value = replaceVariablesRecursively(bearer.value, pm)!!)
7064

7165
internal fun replaceVariablesInRequestRecursively(request: Request, pm: PostmanSDK): Request =
7266
request.copy(
67+
auth =
68+
request.auth?.copy(
69+
bearer = listOfNotNull(replaceVariablesInBearer(request.auth.bearer.firstOrNull(), pm))
70+
),
7371
header =
7472
request.header.map { header ->
7573
header.copy(

src/main/kotlin/com/salesforce/revoman/internal/postman/template/Template.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ data class Item(
2525
val name: String = "",
2626
val item: List<Item>? = null,
2727
val request: Request = Request(),
28-
val auth: Auth? = null,
2928
val event: List<Event>? = null
3029
) {
3130
@JvmField val httpMethod = request.method
@@ -44,6 +43,7 @@ data class Event(val listen: String, val script: Script) {
4443

4544
@JsonClass(generateAdapter = true)
4645
data class Request(
46+
@JvmField val auth: Auth? = null,
4747
@JvmField val method: String = "",
4848
@JvmField val header: List<Header> = emptyList(),
4949
@JvmField val url: Url = Url(),

src/main/kotlin/com/salesforce/revoman/output/report/Step.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ import java.util.Collections.indexOfSubList
1414

1515
data class Step(
1616
@JvmField val index: String,
17-
@JvmField val name: String,
1817
@JvmField val rawPMStep: Item,
1918
@JvmField val parentFolder: Folder? = null,
2019
) {
20+
@JvmField val name: String = rawPMStep.name
2121
@JvmField var preHookCount: Int = 0
2222
@JvmField var postHookCount: Int = 0
2323
@JvmField

src/test/kotlin/com/salesforce/revoman/output/report/StepReportTest.kt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ class StepReportTest {
2929
Request(method = POST.toString(), url = Url("https://overfullstack.github.io/"))
3030
val requestInfo = TxnInfo(String::class.java, "fakeRequest", rawRequest.toHttpRequest())
3131
val stepReportSuccess =
32-
StepReport(
33-
Step("1.3.7", "HttpStatusSuccessful", Item(request = rawRequest)),
34-
Right(requestInfo)
35-
)
32+
StepReport(Step("1.3.7", Item(request = rawRequest)), Right(requestInfo))
3633
println(stepReportSuccess)
3734
stepReportSuccess.isHttpStatusSuccessful shouldBe true
3835
}
@@ -44,7 +41,7 @@ class StepReportTest {
4441
val requestInfo = TxnInfo(String::class.java, "fakeRequest", rawRequest.toHttpRequest())
4542
val stepReportHttpFailure =
4643
StepReport(
47-
Step("1.3.7", "HttpRequestFailure", Item(request = rawRequest)),
44+
Step("1.3.7", Item(request = rawRequest)),
4845
Left(HttpRequestFailure(RuntimeException("fakeRTE"), requestInfo))
4946
)
5047
println(stepReportHttpFailure)
@@ -60,7 +57,7 @@ class StepReportTest {
6057
TxnInfo(String::class.java, "fakeBadResponse", Response(BAD_REQUEST).body("fakeBadResponse"))
6158
val stepReportBadRequest =
6259
StepReport(
63-
Step("", "BadResponse", Item(request = rawRequest)),
60+
Step("", Item(request = rawRequest)),
6461
Right(requestInfo),
6562
null,
6663
Right(badResponseInfo)
@@ -77,7 +74,7 @@ class StepReportTest {
7774
val responseInfo: TxnInfo<Response> = TxnInfo(String::class.java, "fakeResponse", Response(OK))
7875
val stepReportPostHookFailure =
7976
StepReport(
80-
Step("", "PostHookFailure", Item(request = rawRequest)),
77+
Step("", Item(request = rawRequest)),
8178
Right(requestInfo),
8279
null,
8380
Right(responseInfo),

0 commit comments

Comments
 (0)