Skip to content

Commit 3d82dcf

Browse files
Adds auto header
1 parent 5564c3e commit 3d82dcf

11 files changed

Lines changed: 390 additions & 92 deletions

src/test/scala/github4s/integration/GHAuthSpec.scala

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
/*
2+
* Copyright (c) 2016 47 Degrees, LLC. <http://www.47deg.com>
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
5+
* this software and associated documentation files (the "Software"), to deal in
6+
* the Software without restriction, including without limitation the rights to
7+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8+
* the Software, and to permit persons to whom the Software is furnished to do so,
9+
* subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in all
12+
* copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20+
*/
21+
122
package github4s.integration
223

324
import cats.Id
@@ -11,12 +32,20 @@ import org.scalatest._
1132
class GHAuthSpec extends FlatSpec with Matchers with TestUtils {
1233

1334
"Auth >> NewAuth" should "return error on Left when invalid credential is provided" in {
14-
val response = Github().auth.newAuth(validUsername, invalidPassword, validScopes, validNote, validClientId, invalidClientSecret).exec[Id]
35+
val response = Github().auth
36+
.newAuth(validUsername,
37+
invalidPassword,
38+
validScopes,
39+
validNote,
40+
validClientId,
41+
invalidClientSecret)
42+
.exec[Id]
1543
response should be('left)
1644
}
1745

1846
"Auth >> AuthorizeUrl" should "return the expected URL for valid username" in {
19-
val response = Github().auth.authorizeUrl(validClientId, validRedirectUri, validScopes).exec[Id]
47+
val response =
48+
Github().auth.authorizeUrl(validClientId, validRedirectUri, validScopes).exec[Id]
2049
response should be('right)
2150

2251
response.toOption map { r
@@ -27,7 +56,9 @@ class GHAuthSpec extends FlatSpec with Matchers with TestUtils {
2756
}
2857

2958
"Auth >> GetAccessToken" should "return error on Left for invalid code value" in {
30-
val response = Github().auth.getAccessToken(validClientId, invalidClientSecret, "", validRedirectUri, "").exec[Id]
59+
val response = Github().auth
60+
.getAccessToken(validClientId, invalidClientSecret, "", validRedirectUri, "")
61+
.exec[Id]
3162
response should be('left)
3263
}
3364

src/test/scala/github4s/integration/GHGistsSpec.scala

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
/*
2+
* Copyright (c) 2016 47 Degrees, LLC. <http://www.47deg.com>
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
5+
* this software and associated documentation files (the "Software"), to deal in
6+
* the Software without restriction, including without limitation the rights to
7+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8+
* the Software, and to permit persons to whom the Software is furnished to do so,
9+
* subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in all
12+
* copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20+
*/
21+
122
package github4s.integration
223

324
import cats.Id
@@ -10,8 +31,7 @@ import org.scalatest._
1031

1132
class GHGistsSpec extends FlatSpec with Matchers with TestUtils {
1233
"Gists >> Post" should "return the provided gist" in {
13-
val response = Github(accessToken)
14-
.gists
34+
val response = Github(accessToken).gists
1535
.newGist(validGistDescription, validGistPublic, validGistFiles)
1636
.exec[Id]
1737
response should be('right)

src/test/scala/github4s/integration/GHReposSpec.scala

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
/*
2+
* Copyright (c) 2016 47 Degrees, LLC. <http://www.47deg.com>
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
5+
* this software and associated documentation files (the "Software"), to deal in
6+
* the Software without restriction, including without limitation the rights to
7+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8+
* the Software, and to permit persons to whom the Software is furnished to do so,
9+
* subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in all
12+
* copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20+
*/
21+
122
package github4s.integration
223

324
import cats.Id
@@ -7,7 +28,7 @@ import github4s.GithubResponses._
728
import github4s.implicits._
829
import github4s.Github
930
import github4s.utils.TestUtils
10-
import org.scalatest.{ Matchers, FlatSpec }
31+
import org.scalatest.{Matchers, FlatSpec}
1132

1233
class GHReposSpec extends FlatSpec with Matchers with TestUtils {
1334

@@ -42,7 +63,8 @@ class GHReposSpec extends FlatSpec with Matchers with TestUtils {
4263
}
4364

4465
"Repos >> ListContributors" should "return the expected list of contributors for valid data" in {
45-
val response = Github(accessToken).repos.listContributors(validRepoOwner, validRepoName).exec[Id]
66+
val response =
67+
Github(accessToken).repos.listContributors(validRepoOwner, validRepoName).exec[Id]
4668
response should be('right)
4769

4870
response.toOption map { r
@@ -53,7 +75,8 @@ class GHReposSpec extends FlatSpec with Matchers with TestUtils {
5375
}
5476

5577
it should "return error for invalid repo name" in {
56-
val response = Github(accessToken).repos.listContributors(invalidRepoName, validRepoName).exec[Id]
78+
val response =
79+
Github(accessToken).repos.listContributors(invalidRepoName, validRepoName).exec[Id]
5780
response should be('left)
5881
}
5982

src/test/scala/github4s/integration/GHUsersSpec.scala

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
/*
2+
* Copyright (c) 2016 47 Degrees, LLC. <http://www.47deg.com>
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
5+
* this software and associated documentation files (the "Software"), to deal in
6+
* the Software without restriction, including without limitation the rights to
7+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8+
* the Software, and to permit persons to whom the Software is furnished to do so,
9+
* subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in all
12+
* copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20+
*/
21+
122
package github4s.integration
223

324
import cats.Id

src/test/scala/github4s/unit/ApiSpec.scala

Lines changed: 47 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,40 @@
1+
/*
2+
* Copyright (c) 2016 47 Degrees, LLC. <http://www.47deg.com>
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
5+
* this software and associated documentation files (the "Software"), to deal in
6+
* the Software without restriction, including without limitation the rights to
7+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8+
* the Software, and to permit persons to whom the Software is furnished to do so,
9+
* subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in all
12+
* copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20+
*/
21+
122
package github4s.unit
223

3-
import github4s.api.{ Auth, Gists, Repos, Users }
24+
import github4s.api.{Auth, Gists, Repos, Users}
425
import github4s.free.domain.Pagination
5-
import github4s.utils.{ DummyGithubUrls, MockGithubApiServer, TestUtils }
26+
import github4s.utils.{DummyGithubUrls, MockGithubApiServer, TestUtils}
627
import org.scalatest._
728
import cats.implicits._
829

930
class ApiSpec
10-
extends FlatSpec
11-
with Matchers
12-
with TestUtils
13-
with MockGithubApiServer
14-
with DummyGithubUrls {
31+
extends FlatSpec
32+
with Matchers
33+
with TestUtils
34+
with MockGithubApiServer
35+
with DummyGithubUrls {
1536

16-
val auth = new Auth
37+
val auth = new Auth
1738
val repos = new Repos
1839
val users = new Users
1940
val gists = new Gists
@@ -29,7 +50,8 @@ class ApiSpec
2950
}
3051

3152
it should "return error on Left when invalid credential is provided" in {
32-
val response = auth.newAuth(validUsername, invalidPassword, validScopes, validNote, validClientId, "")
53+
val response =
54+
auth.newAuth(validUsername, invalidPassword, validScopes, validNote, validClientId, "")
3355
response should be('left)
3456
}
3557

@@ -79,9 +101,9 @@ class ApiSpec
79101
"Repos >> ListCommits" should "return the expected list of commits for valid data" in {
80102
val response = repos.listCommits(
81103
accessToken = accessToken,
82-
owner = validRepoOwner,
83-
repo = validRepoName,
84-
pagination = Option(Pagination(validPage, validPerPage))
104+
owner = validRepoOwner,
105+
repo = validRepoName,
106+
pagination = Option(Pagination(validPage, validPerPage))
85107
)
86108
response should be('right)
87109

@@ -94,9 +116,9 @@ class ApiSpec
94116
it should "return an empty list of commits for invalid page parameter" in {
95117
val response = repos.listCommits(
96118
accessToken = accessToken,
97-
owner = validRepoOwner,
98-
repo = validRepoName,
99-
pagination = Option(Pagination(invalidPage, validPerPage))
119+
owner = validRepoOwner,
120+
repo = validRepoName,
121+
pagination = Option(Pagination(invalidPage, validPerPage))
100122
)
101123

102124
response should be('right)
@@ -116,8 +138,8 @@ class ApiSpec
116138
"Repos >> ListContributors" should "return the expected list of contributors for valid data" in {
117139
val response = repos.listContributors(
118140
accessToken = accessToken,
119-
owner = validRepoOwner,
120-
repo = validRepoName
141+
owner = validRepoOwner,
142+
repo = validRepoName
121143
)
122144

123145
response should be('right)
@@ -132,9 +154,9 @@ class ApiSpec
132154
it should "return the expected list of contributors for valid data, including a valid anon parameter" in {
133155
val response = repos.listContributors(
134156
accessToken = accessToken,
135-
owner = validRepoOwner,
136-
repo = validRepoName,
137-
anon = Option(validAnonParameter)
157+
owner = validRepoOwner,
158+
repo = validRepoName,
159+
anon = Option(validAnonParameter)
138160
)
139161

140162
response should be('right)
@@ -148,9 +170,9 @@ class ApiSpec
148170
it should "return an empty list of contributors for invalid anon parameter" in {
149171
val response = repos.listContributors(
150172
accessToken = accessToken,
151-
owner = validRepoOwner,
152-
repo = validRepoName,
153-
anon = Some(invalidAnonParameter)
173+
owner = validRepoOwner,
174+
repo = validRepoName,
175+
anon = Some(invalidAnonParameter)
154176
)
155177

156178
response should be('right)
@@ -222,7 +244,8 @@ class ApiSpec
222244
}
223245

224246
"Gists >> PostGist" should "return the provided gist for a valid request" in {
225-
val response = gists.newGist(validGistDescription, validGistPublic, validGistFiles, accessToken)
247+
val response =
248+
gists.newGist(validGistDescription, validGistPublic, validGistFiles, accessToken)
226249
response should be('right)
227250

228251
response.toOption map { r

src/test/scala/github4s/unit/DecodersSpec.scala

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,34 @@
1+
/*
2+
* Copyright (c) 2016 47 Degrees, LLC. <http://www.47deg.com>
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
5+
* this software and associated documentation files (the "Software"), to deal in
6+
* the Software without restriction, including without limitation the rights to
7+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8+
* the Software, and to permit persons to whom the Software is furnished to do so,
9+
* subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in all
12+
* copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20+
*/
21+
122
package github4s.unit
223

3-
import github4s.free.domain.{ Commit, Repository }
24+
import github4s.free.domain.{Commit, Repository}
425
import github4s.utils.FakeResponses
526
import github4s.Decoders._
627
import org.scalatest._
728
import io.circe.parser._
829
import cats.implicits._
930

10-
class DecodersSpec
11-
extends FlatSpec
12-
with Matchers
13-
with FakeResponses {
31+
class DecodersSpec extends FlatSpec with Matchers with FakeResponses {
1432

1533
"Commit decoder" should "return a list of commits when the JSON is valid" in {
1634
decode[List[Commit]](listCommitsValidResponse) should be('right)
Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,33 @@
1+
/*
2+
* Copyright (c) 2016 47 Degrees, LLC. <http://www.47deg.com>
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
5+
* this software and associated documentation files (the "Software"), to deal in
6+
* the Software without restriction, including without limitation the rights to
7+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8+
* the Software, and to permit persons to whom the Software is furnished to do so,
9+
* subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in all
12+
* copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20+
*/
21+
122
package github4s.utils
223

324
import github4s.GithubApiUrls
425

526
trait DummyGithubUrls {
627

728
implicit val dummyUrls: GithubApiUrls = GithubApiUrls(
8-
baseUrl = "http://127.0.0.1:9999/",
9-
authorizeUrl = "http://127.0.0.1:9999/authorize?client_id=%s&redirect_uri=%s&scope=%s&state=%s",
29+
baseUrl = "http://127.0.0.1:9999/",
30+
authorizeUrl = "http://127.0.0.1:9999/authorize?client_id=%s&redirect_uri=%s&scope=%s&state=%s",
1031
accessTokenUrl = "http://127.0.0.1:9999/login/oauth/access_token"
1132
)
1233
}

0 commit comments

Comments
 (0)