|
3 | 3 | import com.github.tomakehurst.wiremock.core.WireMockConfiguration; |
4 | 4 | import org.apache.commons.io.IOUtils; |
5 | 5 | import org.junit.After; |
6 | | -import org.junit.Assert; |
7 | 6 | import org.junit.Before; |
8 | 7 | import org.junit.Rule; |
9 | 8 | import org.kohsuke.github.junit.GitHubWireMockRule; |
|
13 | 12 | import java.io.IOException; |
14 | 13 | import java.util.*; |
15 | 14 |
|
| 15 | +import static org.hamcrest.MatcherAssert.assertThat; |
| 16 | +import static org.hamcrest.Matchers.is; |
16 | 17 | import static org.junit.Assume.assumeFalse; |
17 | 18 | import static org.junit.Assume.assumeTrue; |
18 | 19 |
|
19 | 20 | /** |
20 | 21 | * @author Liam Newman |
21 | 22 | */ |
22 | | -public abstract class AbstractGitHubWireMockTest extends Assert { |
| 23 | +public abstract class AbstractGitHubWireMockTest { |
23 | 24 |
|
24 | 25 | private final GitHubBuilder githubBuilder = createGitHubBuilder(); |
25 | 26 |
|
@@ -126,6 +127,13 @@ protected void requireProxy(String reason) { |
126 | 127 | mockGitHub.isUseProxy()); |
127 | 128 | } |
128 | 129 |
|
| 130 | + protected void verifyAuthenticated() { |
| 131 | + assertThat( |
| 132 | + "GitHub connection believes it is anonymous. Make sure you set GITHUB_OAUTH or both GITHUB_USER and GITHUB_PASSWORD environment variables", |
| 133 | + gitHub.isAnonymous(), |
| 134 | + is(false)); |
| 135 | + } |
| 136 | + |
129 | 137 | protected GHUser getUser() { |
130 | 138 | return getUser(gitHub); |
131 | 139 | } |
@@ -163,6 +171,10 @@ protected GHRepository getTempRepository() throws IOException { |
163 | 171 | protected GHRepository getTempRepository(String name) throws IOException { |
164 | 172 | String fullName = GITHUB_API_TEST_ORG + '/' + name; |
165 | 173 | if (mockGitHub.isUseProxy()) { |
| 174 | + |
| 175 | + // Needs to check if you are authenticated before doing this cleanup and repo creation |
| 176 | + verifyAuthenticated(); |
| 177 | + |
166 | 178 | cleanupRepository(fullName); |
167 | 179 |
|
168 | 180 | GHRepository repository = gitHubBeforeAfter.getOrganization(GITHUB_API_TEST_ORG) |
|
0 commit comments