-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix parameter mismatch mistake in the AbstractGitUserDataFetcher class
- Loading branch information
Showing
4 changed files
with
42 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,4 +93,21 @@ public void shouldFetchGitUserData() throws Exception { | |
assertEquals(gitUserData.getScmUsername(), "Github User"); | ||
assertEquals(gitUserData.getScmUserEmail(), "[email protected]"); | ||
} | ||
|
||
@Test | ||
public void shouldFetchGitUserDataByUrl() throws Exception { | ||
// given | ||
PersonalAccessToken token = mock(PersonalAccessToken.class); | ||
when(token.getToken()).thenReturn(githubOauthToken); | ||
when(personalAccessTokenManager.get(any(Subject.class), eq("github"), eq(null), eq(null))) | ||
.thenReturn(Optional.empty()); | ||
when(personalAccessTokenManager.get( | ||
any(Subject.class), eq(null), eq(wireMockServer.baseUrl()), eq(null))) | ||
.thenReturn(Optional.of(token)); | ||
// when | ||
GitUserData gitUserData = githubGUDFetcher.fetchGitUserData(null); | ||
// then | ||
assertEquals(gitUserData.getScmUsername(), "Github User"); | ||
assertEquals(gitUserData.getScmUserEmail(), "[email protected]"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,6 @@ | |
import org.eclipse.che.api.factory.server.scm.PersonalAccessToken; | ||
import org.eclipse.che.api.factory.server.scm.PersonalAccessTokenManager; | ||
import org.eclipse.che.commons.subject.Subject; | ||
import org.eclipse.che.security.oauth.OAuthAPI; | ||
import org.mockito.Mock; | ||
import org.mockito.testng.MockitoTestNGListener; | ||
import org.testng.annotations.AfterMethod; | ||
|
@@ -44,7 +43,6 @@ | |
@Listeners(MockitoTestNGListener.class) | ||
public class GitlabUserDataFetcherTest { | ||
|
||
@Mock OAuthAPI oAuthTokenFetcher; | ||
@Mock PersonalAccessTokenManager personalAccessTokenManager; | ||
|
||
GitlabUserDataFetcher gitlabUserDataFetcher; | ||
|
@@ -90,6 +88,23 @@ public void shouldFetchGitUserData() throws Exception { | |
assertEquals(gitUserData.getScmUserEmail(), "[email protected]"); | ||
} | ||
|
||
@Test | ||
public void shouldFetchGitUserDataByUrl() throws Exception { | ||
// given | ||
PersonalAccessToken token = mock(PersonalAccessToken.class); | ||
when(token.getToken()).thenReturn("oauthtoken"); | ||
when(personalAccessTokenManager.get(any(Subject.class), eq("gitlab"), eq(null), eq(null))) | ||
.thenReturn(Optional.empty()); | ||
when(personalAccessTokenManager.get( | ||
any(Subject.class), eq(null), eq(wireMockServer.url("/")), eq(null))) | ||
.thenReturn(Optional.of(token)); | ||
// when | ||
GitUserData gitUserData = gitlabUserDataFetcher.fetchGitUserData(null); | ||
// then | ||
assertEquals(gitUserData.getScmUsername(), "John Smith"); | ||
assertEquals(gitUserData.getScmUserEmail(), "[email protected]"); | ||
} | ||
|
||
@Test | ||
public void shouldSetSAASUrlAsDefault() throws Exception { | ||
gitlabUserDataFetcher = | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters