Skip to content

Commit 5da549d

Browse files
committed
update sbt, fix tests
1 parent 82cb203 commit 5da549d

File tree

7 files changed

+61
-72
lines changed

7 files changed

+61
-72
lines changed

module-code/project/build.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.1.1
1+
sbt.version=1.2.8

module-code/test/securesocial/core/OAuth1ClientSpec.scala

+36-41
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import play.api.libs.oauth.RequestToken
1313
import play.api.libs.oauth.ConsumerKey
1414
import play.shaded.oauth.oauth.signpost.exception.OAuthException
1515

16-
class OAuth1ClientSpec extends Specification with Mockito {
16+
class OAuth1ClientSpec(implicit ee: ExecutionEnv) extends Specification with Mockito {
1717
val fakeServiceInfo = new ServiceInfo("requestTokenUrl", "accessTokenUrl", "authorizationUrl", ConsumerKey("consumerKey", "consumerSecret"))
1818

1919
"The default OAuth1Client" should {
@@ -27,67 +27,62 @@ class OAuth1ClientSpec extends Specification with Mockito {
2727
actualRedirectUrl === expectedRedirectUrl
2828
}
2929
"retrieve the requestToken when the endpoint is correct" in {
30-
implicit ee: ExecutionEnv =>
31-
val client = aDefaultClient()
32-
val callbackUrl: String = "callbackUrl"
33-
val expectedRequestToken = RequestToken("token", "secret")
34-
client.client.retrieveRequestToken(callbackUrl) returns Right(expectedRequestToken)
30+
val client = aDefaultClient()
31+
val callbackUrl: String = "callbackUrl"
32+
val expectedRequestToken = RequestToken("token", "secret")
33+
client.client.retrieveRequestToken(callbackUrl) returns Right(expectedRequestToken)
3534

36-
val actualRequestToken = client.retrieveRequestToken(callbackUrl)
35+
val actualRequestToken = client.retrieveRequestToken(callbackUrl)
3736

38-
actualRequestToken must beEqualTo(expectedRequestToken).await
37+
actualRequestToken must beEqualTo(expectedRequestToken).await
3938
}
4039
"fail to retrieve the requestToken with an OAuthException when the endpoint is incorrect" in {
41-
implicit ee: ExecutionEnv =>
42-
val client = aDefaultClient()
43-
val callbackUrl: String = "incorrectCallbackUrl"
44-
val expectedException = new OAuthException("invalid endpoint") {}
45-
client.client.retrieveRequestToken(callbackUrl) returns Left(expectedException)
40+
val client = aDefaultClient()
41+
val callbackUrl: String = "incorrectCallbackUrl"
42+
val expectedException = new OAuthException("invalid endpoint") {}
43+
client.client.retrieveRequestToken(callbackUrl) returns Left(expectedException)
4644

47-
val actualRequestToken = client.retrieveRequestToken(callbackUrl)
45+
val actualRequestToken = client.retrieveRequestToken(callbackUrl)
4846

49-
actualRequestToken must throwAn(expectedException).await
47+
actualRequestToken must throwAn(expectedException).await
5048
}
5149
"retrieve the OAuth1Info given a valid request token and a verifier" in {
52-
implicit ee: ExecutionEnv =>
53-
val client = aDefaultClient()
54-
val verifier: String = "verifier"
55-
val requestToken = RequestToken("requestToken", "requestSecret")
56-
val accessToken: RequestToken = RequestToken("accessToken", "accessSecret")
50+
val client = aDefaultClient()
51+
val verifier: String = "verifier"
52+
val requestToken = RequestToken("requestToken", "requestSecret")
53+
val accessToken: RequestToken = RequestToken("accessToken", "accessSecret")
5754

58-
client.client.retrieveAccessToken(requestToken, verifier) returns Right(accessToken)
55+
client.client.retrieveAccessToken(requestToken, verifier) returns Right(accessToken)
5956

60-
val actualOAuth1Info = client.retrieveOAuth1Info(requestToken, verifier)
57+
val actualOAuth1Info = client.retrieveOAuth1Info(requestToken, verifier)
6158

62-
actualOAuth1Info must beEqualTo(OAuth1Info(accessToken.token, accessToken.secret)).await
59+
actualOAuth1Info must beEqualTo(OAuth1Info(accessToken.token, accessToken.secret)).await
6360
}
6461
"fail to retrieve the OAuth1Info given an invalid request token and a verifier" in {
65-
implicit ee: ExecutionEnv =>
66-
val client = aDefaultClient()
67-
val verifier: String = "verifier"
68-
val requestToken = RequestToken("invalidRequestToken", "requestSecret")
69-
val expectedException = new OAuthException("invalid endpoint") {}
62+
val client = aDefaultClient()
63+
val verifier: String = "verifier"
64+
val requestToken = RequestToken("invalidRequestToken", "requestSecret")
65+
val expectedException = new OAuthException("invalid endpoint") {}
7066

71-
client.client.retrieveAccessToken(requestToken, verifier) returns Left(expectedException)
67+
client.client.retrieveAccessToken(requestToken, verifier) returns Left(expectedException)
7268

73-
val actualOAuth1Info = client.retrieveOAuth1Info(requestToken, verifier)
69+
val actualOAuth1Info = client.retrieveOAuth1Info(requestToken, verifier)
7470

75-
actualOAuth1Info must throwAn(expectedException).await
71+
actualOAuth1Info must throwAn(expectedException).await
7672
}
7773
"retrieve the json profile given the profile api url and the OAuth1Info" in {
78-
implicit ee: ExecutionEnv =>
79-
val httpService: MockHttpService = new MockHttpService()
80-
val client = aDefaultClient(httpService)
81-
val profileApiUrl: String = "profileApiUrl"
82-
val oauth1info = OAuth1Info("accessToken", "accessSecret")
83-
val expectedJsonProfile = Json.obj("id" -> "success")
74+
val httpService: MockHttpService = new MockHttpService()
75+
val client = aDefaultClient(httpService)
76+
val profileApiUrl: String = "profileApiUrl"
77+
val oauth1info = OAuth1Info("accessToken", "accessSecret")
78+
val expectedJsonProfile = Json.obj("id" -> "success")
8479

85-
httpService.request.sign(any[OAuthCalculator]) returns httpService.request //make sure the request is signed
86-
httpService.response.json returns expectedJsonProfile
80+
httpService.request.sign(any[OAuthCalculator]) returns httpService.request //make sure the request is signed
81+
httpService.response.json returns expectedJsonProfile
8782

88-
val actualJsonProfile = client.retrieveProfile(profileApiUrl, oauth1info)
83+
val actualJsonProfile = client.retrieveProfile(profileApiUrl, oauth1info)
8984

90-
actualJsonProfile must beEqualTo(expectedJsonProfile).await
85+
actualJsonProfile must beEqualTo(expectedJsonProfile).await
9186
}
9287
}
9388

module-code/test/securesocial/core/OAuth2ClientSpec.scala

+20-23
Original file line numberDiff line numberDiff line change
@@ -11,44 +11,41 @@ import securesocial.core.services.HttpService
1111
import scala.concurrent.ExecutionContext.Implicits.global
1212
import scala.concurrent.Future
1313

14-
class OAuth2ClientSpec extends Specification with Mockito {
14+
class OAuth2ClientSpec(implicit ee: ExecutionEnv) extends Specification with Mockito {
1515
"The default OAuth2Client" should {
1616
import MockHttpService._
1717
"exchange a signin code for a token" in {
18-
implicit ee: ExecutionEnv =>
19-
val httpService: MockHttpService = new MockHttpService()
20-
val client = aDefaultClient(httpService)
21-
val (code, callbackUrl) = ("code", "callbackUrl")
22-
val expectedJson: JsObject = Json.obj("expected" -> "object")
23-
val expectedToken = OAuth2Info("accessToken")
18+
val httpService: MockHttpService = new MockHttpService()
19+
val client = aDefaultClient(httpService)
20+
val (code, callbackUrl) = ("code", "callbackUrl")
21+
val expectedJson: JsObject = Json.obj("expected" -> "object")
22+
val expectedToken = OAuth2Info("accessToken")
2423

25-
httpService.request.post(any[Params])(any[ParamsWriter]) returns Future.successful(httpService.response)
26-
httpService.response.json returns expectedJson
24+
httpService.request.post(any[Params])(any[ParamsWriter]) returns Future.successful(httpService.response)
25+
httpService.response.json returns expectedJson
2726

28-
val builder: WSResponse => OAuth2Info = (response: WSResponse) => if (response.json == expectedJson) expectedToken else throw new RuntimeException(s"Expected ${response.json} to be $expectedJson")
29-
val token: Future[OAuth2Info] = client.exchangeCodeForToken(code, callbackUrl, builder)
27+
val builder: WSResponse => OAuth2Info = (response: WSResponse) => if (response.json == expectedJson) expectedToken else throw new RuntimeException(s"Expected ${response.json} to be $expectedJson")
28+
val token: Future[OAuth2Info] = client.exchangeCodeForToken(code, callbackUrl, builder)
3029

31-
token must beEqualTo(expectedToken).await
30+
token must beEqualTo(expectedToken).await
3231
}
3332
"retrieve the profile given an access token" in {
34-
implicit ee: ExecutionEnv =>
35-
val httpService: MockHttpService = new MockHttpService()
36-
val client = aDefaultClient(httpService)
37-
val profileUrl = "profileUrl"
38-
val expectedJson: JsObject = Json.obj("expected" -> "object")
39-
httpService.response.json returns expectedJson
33+
val httpService: MockHttpService = new MockHttpService()
34+
val client = aDefaultClient(httpService)
35+
val profileUrl = "profileUrl"
36+
val expectedJson: JsObject = Json.obj("expected" -> "object")
37+
httpService.response.json returns expectedJson
4038

41-
val actualProfile = client.retrieveProfile(profileUrl)
39+
val actualProfile = client.retrieveProfile(profileUrl)
4240

43-
actualProfile must beEqualTo(expectedJson).await
41+
actualProfile must beEqualTo(expectedJson).await
4442
}
4543

4644
}
4745
private def aDefaultClient(httpService: HttpService = new MockHttpService()) = {
48-
new OAuth2Client.Default(httpService, fakeOAuth2Settings) {
46+
new OAuth2Client.Default(httpService, fakeOAuth2Settings)(global) {
4947
}
5048
}
5149
val fakeOAuth2Settings = new OAuth2Settings(
52-
"authorizationUrl", "accessTokenUrl", "clientId", "clientSecret", Some("scope"), Map.empty, Map.empty
53-
)
50+
"authorizationUrl", "accessTokenUrl", "clientId", "clientSecret", Some("scope"), Map.empty, Map.empty)
5451
}

module-code/test/securesocial/core/providers/GoogleProviderSpec.scala

+1-2
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ class GoogleProviderSpec extends PlaySpecification with Mockito {
128128
Some(email),
129129
Some(avatarUrl),
130130
AuthenticationMethod.OAuth2,
131-
oAuth2Info = Some(oAuth2Info)
132-
)
131+
oAuth2Info = Some(oAuth2Info))
133132
profile must_== expectedProfile
134133
}
135134
}

module-code/test/securesocial/core/providers/UsernamePasswordProviderSpec.scala

+1-2
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ class UsernamePasswordProviderSpec extends PlaySpecification with Mockito {
8686
authMethod = upp.authMethod,
8787
oAuth1Info = None,
8888
oAuth2Info = None,
89-
passwordInfo = Some(PasswordInfo("bcrypt", user.hash))
90-
)
89+
passwordInfo = Some(PasswordInfo("bcrypt", user.hash)))
9190
}
9291

9392
case class User(email: String, password: String) {

project/build.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.1.1
1+
sbt.version=1.2.8

samples/scala/demo/test/NaiveIdentityProvider.scala

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ class NaiveIdentityProvider extends IdentityProvider {
1616
Some("Foo Bar"),
1717
1818
None,
19-
authMethod
20-
)))
19+
authMethod)))
2120
}
2221
}

0 commit comments

Comments
 (0)