Skip to content

Commit

Permalink
reusing SFTestEffects in SFAuthTest
Browse files Browse the repository at this point in the history
  • Loading branch information
frj committed Aug 29, 2019
1 parent a4ad737 commit d50c5f1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class HandlerTest extends FlatSpec with Matchers {
FakeFetchString.fetchString
).map { operation =>
operation
.steps(potentialIssueDateRequests("Guardian Weekly xxx", "2019-01-01", "2019-02-01"))
.steps(potentialIssueDateRequest("Guardian Weekly xxx", "2019-01-01", "2019-02-01"))
}
) {
case ContinueProcessing(response) =>
Expand All @@ -49,7 +49,7 @@ class HandlerTest extends FlatSpec with Matchers {
}
}

private def potentialIssueDateRequests(productPrefix: String, startDate: String, endDate: String) = {
private def potentialIssueDateRequest(productPrefix: String, startDate: String, endDate: String) = {
ApiGatewayRequest(
Some("GET"),
Some(Map("startDate" -> startDate, "endDate" -> endDate)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ object SFTestEffects {
val authSuccess = (
POSTRequest(
"/services/oauth2/token",
"""client_id=clientsfclient&client_secret=clientsecretsfsecret&username=usernamesf&password=passSFpasswordtokentokenSFtoken&
|grant_type=password""".stripMargin
"""client_id=clientsfclient&client_secret=clientsecretsfsecret&username=usernamesf&password=passSFpasswordtokentokenSFtoken&grant_type=password""".stripMargin
),
HTTPResponse(200, authSuccessResponseBody)
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.gu.salesforce.auth

import com.gu.effects.TestingRawEffects
import com.gu.effects.{SFTestEffects, TestingRawEffects}
import com.gu.effects.TestingRawEffects.{HTTPResponse, POSTRequest}
import com.gu.salesforce.SalesforceAuthenticate
import com.gu.salesforce.SalesforceAuthenticate.{SFAuthConfig, SalesforceAuth}
Expand All @@ -21,31 +21,9 @@ class SalesforceAuthenticateTest extends FlatSpec with Matchers {
)).value
val expected = ClientSuccess(SalesforceAuth("tokentoken", "https://instance.url"))
auth should be(expected)

}

}

object SalesforceAuthenticateData {

def postResponses: Map[POSTRequest, HTTPResponse] = {

val accountQueryResponse: String =
s"""
|{
| "access_token": "tokentoken",
| "instance_url": "https://instance.url",
| "id": "https://id.sf.com/id/idididididid/ididididid",
| "token_type": "Bearer",
| "issued_at": "101010101010",
| "signature": "bW9uc3RlcnMhCg=="
|}
""".stripMargin

Map(
POSTRequest("/services/oauth2/token", """client_id=clientsfclient&client_secret=clientsecretsfsecret&username=usernamesf&password=passSFpasswordtokentokenSFtoken&grant_type=password""")
-> HTTPResponse(200, accountQueryResponse)
)
}

def postResponses: Map[POSTRequest, HTTPResponse] = Map(SFTestEffects.authSuccess)
}

0 comments on commit d50c5f1

Please sign in to comment.