-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add different auth support per cloud agent in e2e (#558)
- Loading branch information
abalias
authored
Jun 20, 2023
1 parent
c3a5d8e
commit 1c3c55a
Showing
18 changed files
with
177 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package interactions | ||
|
||
import common.Environments | ||
import net.serenitybdd.screenplay.Actor | ||
import net.serenitybdd.screenplay.Tasks | ||
import net.serenitybdd.screenplay.rest.abilities.CallAnApi | ||
import net.serenitybdd.screenplay.rest.interactions.RestInteraction | ||
import net.thucydides.core.annotations.Step | ||
|
||
|
||
/** | ||
* This class is a copy of the class Delete from serenity rest interactions | ||
* to add a custom authentication header to the request on-the-fly. | ||
*/ | ||
open class Delete(private val resource: String) : RestInteraction() { | ||
@Step("{0} executes a DELETE on the resource #resource") | ||
override fun <T : Actor?> performAs(actor: T) { | ||
val spec = rest() | ||
if (Environments.AGENT_AUTH_REQUIRED) { | ||
spec.header(Environments.AGENT_AUTH_HEADER, actor!!.recall("AUTH_KEY")) | ||
} | ||
spec.delete(CallAnApi.`as`(actor).resolve(resource)) | ||
} | ||
|
||
companion object { | ||
fun from(resource: String?): Delete { | ||
return Tasks.instrumented(Delete::class.java, resource) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package interactions | ||
|
||
import common.Environments | ||
import net.serenitybdd.screenplay.Actor | ||
import net.serenitybdd.screenplay.Tasks | ||
import net.serenitybdd.screenplay.rest.abilities.CallAnApi | ||
import net.serenitybdd.screenplay.rest.interactions.RestInteraction | ||
import net.thucydides.core.annotations.Step | ||
|
||
/** | ||
* This class is a copy of the class Get from serenity rest interactions | ||
* to add a custom authentication header to the request on-the-fly. | ||
*/ | ||
open class Get(private val resource: String) : RestInteraction() { | ||
@Step("{0} executes a GET on the resource #resource") | ||
override fun <T : Actor?> performAs(actor: T) { | ||
val spec = rest() | ||
if (Environments.AGENT_AUTH_REQUIRED) { | ||
spec.header(Environments.AGENT_AUTH_HEADER, actor!!.recall("AUTH_KEY")) | ||
} | ||
spec.get(CallAnApi.`as`(actor).resolve(resource)) | ||
} | ||
|
||
companion object { | ||
fun resource(resource: String?): Get { | ||
return Tasks.instrumented(Get::class.java, resource) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package interactions | ||
|
||
import common.Environments | ||
import net.serenitybdd.screenplay.Actor | ||
import net.serenitybdd.screenplay.Tasks | ||
import net.serenitybdd.screenplay.rest.abilities.CallAnApi | ||
import net.serenitybdd.screenplay.rest.interactions.RestInteraction | ||
import net.thucydides.core.annotations.Step | ||
|
||
/** | ||
* This class is a copy of the class Patch from serenity rest interactions | ||
* to add a custom authentication header to the request on-the-fly. | ||
*/ | ||
open class Patch(private val resource: String) : RestInteraction() { | ||
@Step("{0} executes a PATCH on the resource #resource") | ||
override fun <T : Actor?> performAs(actor: T) { | ||
val spec = rest() | ||
if (Environments.AGENT_AUTH_REQUIRED) { | ||
spec.header(Environments.AGENT_AUTH_HEADER, actor!!.recall("AUTH_KEY")) | ||
} | ||
spec.patch(CallAnApi.`as`(actor).resolve(resource)) | ||
} | ||
|
||
companion object { | ||
fun to(resource: String?): Patch { | ||
return Tasks.instrumented(Patch::class.java, resource) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package interactions | ||
|
||
import common.Environments | ||
import net.serenitybdd.screenplay.Actor | ||
import net.serenitybdd.screenplay.Tasks | ||
import net.serenitybdd.screenplay.rest.abilities.CallAnApi | ||
import net.serenitybdd.screenplay.rest.interactions.RestInteraction | ||
import net.thucydides.core.annotations.Step | ||
|
||
/** | ||
* This class is a copy of the class Post from serenity rest interactions | ||
* to add a custom authentication header to the request on-the-fly. | ||
*/ | ||
open class Post(private val resource: String) : RestInteraction() { | ||
@Step("{0} executes a POST on the resource #resource") | ||
override fun <T : Actor?> performAs(actor: T) { | ||
val spec = rest() | ||
if (Environments.AGENT_AUTH_REQUIRED) { | ||
spec.header(Environments.AGENT_AUTH_HEADER, actor!!.recall("AUTH_KEY")) | ||
} | ||
spec.post(CallAnApi.`as`(actor).resolve(resource)) | ||
} | ||
|
||
companion object { | ||
fun to(resource: String?): Post { | ||
return Tasks.instrumented(Post::class.java, resource) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package interactions | ||
|
||
import common.Environments | ||
import net.serenitybdd.screenplay.Actor | ||
import net.serenitybdd.screenplay.Tasks | ||
import net.serenitybdd.screenplay.rest.abilities.CallAnApi | ||
import net.serenitybdd.screenplay.rest.interactions.RestInteraction | ||
import net.thucydides.core.annotations.Step | ||
|
||
|
||
/** | ||
* This class is a copy of the class Put from serenity rest interactions | ||
* to add a custom authentication header to the request on-the-fly. | ||
*/ | ||
open class Put(private val resource: String) : RestInteraction() { | ||
@Step("{0} executes a PUT on the resource #resource") | ||
override fun <T : Actor?> performAs(actor: T) { | ||
val spec = rest() | ||
if (Environments.AGENT_AUTH_REQUIRED) { | ||
spec.header(Environments.AGENT_AUTH_HEADER, actor!!.recall("AUTH_KEY")) | ||
} | ||
spec.put(CallAnApi.`as`(actor).resolve(resource)) | ||
} | ||
|
||
companion object { | ||
fun to(resource: String?): Put { | ||
return Tasks.instrumented(Put::class.java, resource) | ||
} | ||
} | ||
} |