@@ -13,7 +13,7 @@ import play.api.libs.oauth.RequestToken
13
13
import play .api .libs .oauth .ConsumerKey
14
14
import play .shaded .oauth .oauth .signpost .exception .OAuthException
15
15
16
- class OAuth1ClientSpec extends Specification with Mockito {
16
+ class OAuth1ClientSpec ( implicit ee : ExecutionEnv ) extends Specification with Mockito {
17
17
val fakeServiceInfo = new ServiceInfo (" requestTokenUrl" , " accessTokenUrl" , " authorizationUrl" , ConsumerKey (" consumerKey" , " consumerSecret" ))
18
18
19
19
" The default OAuth1Client" should {
@@ -27,67 +27,62 @@ class OAuth1ClientSpec extends Specification with Mockito {
27
27
actualRedirectUrl === expectedRedirectUrl
28
28
}
29
29
" 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)
35
34
36
- val actualRequestToken = client.retrieveRequestToken(callbackUrl)
35
+ val actualRequestToken = client.retrieveRequestToken(callbackUrl)
37
36
38
- actualRequestToken must beEqualTo(expectedRequestToken).await
37
+ actualRequestToken must beEqualTo(expectedRequestToken).await
39
38
}
40
39
" 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)
46
44
47
- val actualRequestToken = client.retrieveRequestToken(callbackUrl)
45
+ val actualRequestToken = client.retrieveRequestToken(callbackUrl)
48
46
49
- actualRequestToken must throwAn(expectedException).await
47
+ actualRequestToken must throwAn(expectedException).await
50
48
}
51
49
" 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" )
57
54
58
- client.client.retrieveAccessToken(requestToken, verifier) returns Right (accessToken)
55
+ client.client.retrieveAccessToken(requestToken, verifier) returns Right (accessToken)
59
56
60
- val actualOAuth1Info = client.retrieveOAuth1Info(requestToken, verifier)
57
+ val actualOAuth1Info = client.retrieveOAuth1Info(requestToken, verifier)
61
58
62
- actualOAuth1Info must beEqualTo(OAuth1Info (accessToken.token, accessToken.secret)).await
59
+ actualOAuth1Info must beEqualTo(OAuth1Info (accessToken.token, accessToken.secret)).await
63
60
}
64
61
" 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" ) {}
70
66
71
- client.client.retrieveAccessToken(requestToken, verifier) returns Left (expectedException)
67
+ client.client.retrieveAccessToken(requestToken, verifier) returns Left (expectedException)
72
68
73
- val actualOAuth1Info = client.retrieveOAuth1Info(requestToken, verifier)
69
+ val actualOAuth1Info = client.retrieveOAuth1Info(requestToken, verifier)
74
70
75
- actualOAuth1Info must throwAn(expectedException).await
71
+ actualOAuth1Info must throwAn(expectedException).await
76
72
}
77
73
" 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" )
84
79
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
87
82
88
- val actualJsonProfile = client.retrieveProfile(profileApiUrl, oauth1info)
83
+ val actualJsonProfile = client.retrieveProfile(profileApiUrl, oauth1info)
89
84
90
- actualJsonProfile must beEqualTo(expectedJsonProfile).await
85
+ actualJsonProfile must beEqualTo(expectedJsonProfile).await
91
86
}
92
87
}
93
88
0 commit comments