Commit 80bc613d authored by Greg Messner's avatar Greg Messner
Browse files

Removed deprecated login methods and SessionApi (#503)

parent 45040e3d
......@@ -80,7 +80,7 @@ There have been reports of problems resolving some dependencies when using Ivy o
GitLab4J-API is quite simple to use, all you need is the URL to your GitLab server and the Personal Access Token from your GitLab Account Settings page. Once you have that info it is as simple as:
```java
// Create a GitLabApi instance to communicate with your GitLab server
GitLabApi gitLabApi = new GitLabApi("http://your.gitlab.server.com", "YOUR_ACCESS_TOKEN");
GitLabApi gitLabApi = new GitLabApi("http://your.gitlab.server.com", "YOUR_PERSONAL_ACCESS_TOKEN");
// Get the list of projects your account has access to
List<Project> projects = gitLabApi.getProjectApi().getProjects();
......@@ -89,12 +89,12 @@ List<Project> projects = gitLabApi.getProjectApi().getProjects();
You can also login to your GitLab server with username, and password:
```java
// Log in to the GitLab server using a username and password
GitLabApi gitLabApi = GitLabApi.login("http://your.gitlab.server.com", "your-username", "your-password");
GitLabApi gitLabApi = GitLabApi.oauth2Login("http://your.gitlab.server.com", "username", "password");
```
As of GitLab4J-API 4.6.6, all API requests support performing the API call as if you were another user, provided you are authenticated as an administrator:
```java
// Create a GitLabApi instance to communicate with your GitLab server (must be an administrator)
GitLabApi gitLabApi = new GitLabApi("http://your.gitlab.server.com", "YOUR_ACCESS_TOKEN");
GitLabApi gitLabApi = new GitLabApi("http://your.gitlab.server.com", "YOUR_PERSONAL_ACCESS_TOKEN");
// sudo as as a different user, in this case the user named "johndoe", all future calls will be done as "johndoe"
gitLabApi.sudo("johndoe")
......@@ -110,16 +110,16 @@ As of GitLab4J-API 4.8.2 support has been added for connecting to the GitLab ser
// Log in to the GitLab server using a proxy server (with basic auth on proxy)
Map<String, Object> proxyConfig = ProxyClientConfig.createProxyClientConfig(
"http://your-proxy-server", "proxy-username", "proxy-password");
GitLabApi gitLabApi = new GitLabApi("http://your.gitlab.com", "YOUR_ACCESS_TOKEN", null, proxyConfig);
GitLabApi gitLabApi = new GitLabApi("http://your.gitlab.com", "YOUR_PERSONAL_ACCESS_TOKEN", null, proxyConfig);
// Log in to the GitLab server using a proxy server (no auth on proxy)
Map<String, Object> proxyConfig = ProxyClientConfig.createProxyClientConfig("http://your-proxy-server");
GitLabApi gitLabApi = new GitLabApi("http://your.gitlab.com", "YOUR_ACCESS_TOKEN", null, proxyConfig);
GitLabApi gitLabApi = new GitLabApi("http://your.gitlab.com", "YOUR_PERSONAL_ACCESS_TOKEN", null, proxyConfig);
// Log in to the GitLab server using an NTLM (Windows DC) proxy
Map<String, Object> ntlmProxyConfig = ProxyClientConfig.createNtlmProxyClientConfig(
"http://your-proxy-server", "windows-username", "windows-password", "windows-workstation", "windows-domain");
GitLabApi gitLabApi = new GitLabApi("http://your.gitlab.com", "YOUR_ACCESS_TOKEN", null, ntlmProxyConfig);
GitLabApi gitLabApi = new GitLabApi("http://your.gitlab.com", "YOUR_PERSONAL_ACCESS_TOKEN", null, ntlmProxyConfig);
```
See the Javadoc on the GitLabApi class for a complete list of methods accepting the proxy configuration (clientConfiguration parameter)
......@@ -129,7 +129,7 @@ As of GitLab4J-API 4.2.0 support has been added for GitLab API V4. If your appli
you can still use GitLab4J-API by creating your GitLabApi instance as follows:
```java
// Create a GitLabApi instance to communicate with your GitLab server using GitLab API V3
GitLabApi gitLabApi = new GitLabApi(ApiVersion.V3, "http://your.gitlab.server.com", "YOUR_ACCESS_TOKEN");
GitLabApi gitLabApi = new GitLabApi(ApiVersion.V3, "http://your.gitlab.server.com", "YOUR_PRIVATE_TOKEN");
```
**NOTICE**:
......@@ -140,7 +140,7 @@ As of GitLab 11.0 support for the GitLab API v3 has been removed from the GitLab
As of GitLab4J-API 4.8.39 support has been added to log the requests to and the responses from the
GitLab API. Enable logging using one of the following methods on the GitLabApi instance:
```java
GitLabApi gitLabApi = new GitLabApi("http://your.gitlab.server.com", "YOUR_PRIVATE_TOKEN");
GitLabApi gitLabApi = new GitLabApi("http://your.gitlab.server.com", "YOUR_PERSONAL_ACCESS_TOKEN");
// Log using the shared logger and default level of FINE
gitLabApi.enableRequestResponseLogging();
......
......@@ -13,7 +13,6 @@ import javax.ws.rs.core.Response;
import org.gitlab4j.api.Constants.TokenType;
import org.gitlab4j.api.models.OauthTokenResponse;
import org.gitlab4j.api.models.Session;
import org.gitlab4j.api.models.User;
import org.gitlab4j.api.models.Version;
import org.gitlab4j.api.utils.MaskingLoggingFilter;
......@@ -49,7 +48,6 @@ public class GitLabApi {
private String gitLabServerUrl;
private Map<String, Object> clientConfigProperties;
private int defaultPerPage = DEFAULT_PER_PAGE;
private Session session;
private ApplicationsApi applicationsApi;
private ApplicationSettingsApi applicationSettingsApi;
......@@ -87,7 +85,6 @@ public class GitLabApi {
private RunnersApi runnersApi;
private SearchApi searchApi;
private ServicesApi servicesApi;
private SessionApi sessionApi;
private SnippetsApi snippetsApi;
private SystemHooksApi systemHooksApi;
private TagsApi tagsApi;
......@@ -105,25 +102,26 @@ public class GitLabApi {
}
/**
* Create a new GitLabApi instance that is logically a duplicate of this instance, with the exception off sudo state.
* Constructs a GitLabApi instance set up to interact with the GitLab server
* using GitLab API version 4. This is the primary way to authenticate with
* the GitLab REST API.
*
* @return a new GitLabApi instance that is logically a duplicate of this instance, with the exception off sudo state.
* @param hostUrl the URL of the GitLab server
* @param personalAccessToken the private token to use for access to the API
*/
public final GitLabApi duplicate() {
Integer sudoUserId = this.getSudoAsId();
GitLabApi gitLabApi = new GitLabApi(apiVersion, gitLabServerUrl,
getTokenType(), getAuthToken(), getSecretToken(), clientConfigProperties);
if (sudoUserId != null) {
gitLabApi.apiClient.setSudoAsId(sudoUserId);
}
if (getIgnoreCertificateErrors()) {
gitLabApi.setIgnoreCertificateErrors(true);
}
public GitLabApi(String hostUrl, String personalAccessToken) {
this(ApiVersion.V4, hostUrl, personalAccessToken, null);
}
gitLabApi.defaultPerPage = this.defaultPerPage;
return (gitLabApi);
/**
* Constructs a GitLabApi instance set up to interact with the GitLab server using GitLab API version 4.
*
* @param hostUrl the URL of the GitLab server
* @param personalAccessToken the private token to use for access to the API
* @param secretToken use this token to validate received payloads
*/
public GitLabApi(String hostUrl, String personalAccessToken, String secretToken) {
this(ApiVersion.V4, hostUrl, TokenType.PRIVATE, personalAccessToken, secretToken);
}
/**
......@@ -302,121 +300,26 @@ public class GitLabApi {
}
/**
* <p>Logs into GitLab using provided {@code username} and {@code password}, and creates a new {@code GitLabApi} instance
* using returned private token and the specified GitLab API version.</p>
*
* <strong>NOTE</strong>: For GitLab servers 10.2 and above this will utilize OAUTH2 for login. For GitLab servers prior to
* 10.2, the Session API login is utilized.
* Constructs a GitLabApi instance set up to interact with the GitLab server using the specified GitLab API version.
*
* @param apiVersion the ApiVersion specifying which version of the API to use
* @param url GitLab URL
* @param username user name for which private token should be obtained
* @param password password for a given {@code username}
* @return new {@code GitLabApi} instance configured for a user-specific token
* @throws GitLabApiException GitLabApiException if any exception occurs during execution
* @deprecated As of release 4.8.7, will be removed in 4.9.0
*/
@Deprecated
public static GitLabApi login(ApiVersion apiVersion, String url, String username, String password) throws GitLabApiException {
return (GitLabApi.login(apiVersion, url, username, password, false));
}
/**
* <p>Logs into GitLab using provided {@code username} and {@code password}, and creates a new {@code GitLabApi} instance
* using returned private token using GitLab API version 4.</p>
*
* <strong>NOTE</strong>: For GitLab servers 10.2 and above this will utilize OAUTH2 for login. For GitLab servers prior to
* 10.2, the Session API login is utilized.
*
* @param url GitLab URL
* @param username user name for which private token should be obtained
* @param password password for a given {@code username}
* @return new {@code GitLabApi} instance configured for a user-specific token
* @throws GitLabApiException GitLabApiException if any exception occurs during execution
* @deprecated As of release 4.8.7, will be removed in 4.9.0
* @param hostUrl the URL of the GitLab server
* @param personalAccessToken the private token to use for access to the API
*/
@Deprecated
public static GitLabApi login(String url, String username, String password) throws GitLabApiException {
return (GitLabApi.login(ApiVersion.V4, url, username, password, false));
public GitLabApi(ApiVersion apiVersion, String hostUrl, String personalAccessToken) {
this(apiVersion, hostUrl, personalAccessToken, null);
}
/**
* <p>Logs into GitLab using provided {@code username} and {@code password}, and creates a new {@code GitLabApi} instance
* using returned private token and the specified GitLab API version.</p>
*
* <strong>NOTE</strong>: For GitLab servers 10.2 and above this will utilize OAUTH2 for login. For GitLab servers prior to
* 10.2, the Session API login is utilized.
* Constructs a GitLabApi instance set up to interact with the GitLab server using the specified GitLab API version.
*
* @param apiVersion the ApiVersion specifying which version of the API to use
* @param url GitLab URL
* @param username user name for which private token should be obtained
* @param password password for a given {@code username}
* @param ignoreCertificateErrors if true will set up the Jersey system ignore SSL certificate errors
* @return new {@code GitLabApi} instance configured for a user-specific token
* @throws GitLabApiException GitLabApiException if any exception occurs during execution
* @deprecated As of release 4.8.7, will be removed in 4.9.0
*/
@Deprecated
public static GitLabApi login(ApiVersion apiVersion, String url, String username, String password, boolean ignoreCertificateErrors) throws GitLabApiException {
GitLabApi gitLabApi = new GitLabApi(apiVersion, url, (String)null);
if (ignoreCertificateErrors) {
gitLabApi.setIgnoreCertificateErrors(true);
}
try {
SessionApi sessionApi = gitLabApi.getSessionApi();
Session session = sessionApi.login(username, null, password);
gitLabApi = new GitLabApi(apiVersion, url, session);
if (ignoreCertificateErrors) {
gitLabApi.setIgnoreCertificateErrors(true);
}
} catch (GitLabApiException gle) {
if (gle.getHttpStatus() != Response.Status.NOT_FOUND.getStatusCode()) {
throw (gle);
} else {
gitLabApi = GitLabApi.oauth2Login(apiVersion, url, username, password, null, null, ignoreCertificateErrors);
}
}
return (gitLabApi);
}
/**
* <p>Logs into GitLab using provided {@code username} and {@code password}, and creates a new {@code GitLabApi} instance
* using returned private token using GitLab API version 4.</p>
*
* <strong>NOTE</strong>: For GitLab servers 10.2 and above this will utilize OAUTH2 for login. For GitLab servers prior to
* 10.2, the Session API login is utilized.
*
* @param url GitLab URL
* @param username user name for which private token should be obtained
* @param password password for a given {@code username}
* @param ignoreCertificateErrors if true will set up the Jersey system ignore SSL certificate errors
* @return new {@code GitLabApi} instance configured for a user-specific token
* @throws GitLabApiException GitLabApiException if any exception occurs during execution
* @deprecated As of release 4.8.7, will be removed in 4.9.0
*/
@Deprecated
public static GitLabApi login(String url, String username, String password, boolean ignoreCertificateErrors) throws GitLabApiException {
return (GitLabApi.login(ApiVersion.V4, url, username, password, ignoreCertificateErrors));
}
/**
* <p>If this instance was created with {@link #login(String, String, String)} this method will
* return the Session instance returned by the GitLab API on login, otherwise returns null.</p>
*
* <strong>NOTE</strong>: For GitLab servers 10.2 and above this method will always return null.
*
* @return the Session instance
* @deprecated This method will be removed in Release 4.9.0
* @param hostUrl the URL of the GitLab server
* @param personalAccessToken the private token to use for access to the API
* @param secretToken use this token to validate received payloads
*/
@Deprecated
public Session getSession() {
return session;
public GitLabApi(ApiVersion apiVersion, String hostUrl, String personalAccessToken, String secretToken) {
this(apiVersion, hostUrl, personalAccessToken, secretToken, null);
}
/**
......@@ -431,17 +334,6 @@ public class GitLabApi {
this(apiVersion, hostUrl, tokenType, authToken, null);
}
/**
* Constructs a GitLabApi instance set up to interact with the GitLab server using the specified GitLab API version.
*
* @param apiVersion the ApiVersion specifying which version of the API to use
* @param hostUrl the URL of the GitLab server
* @param privateToken to private token to use for access to the API
*/
public GitLabApi(ApiVersion apiVersion, String hostUrl, String privateToken) {
this(apiVersion, hostUrl, privateToken, null);
}
/**
* Constructs a GitLabApi instance set up to interact with the GitLab server using GitLab API version 4.
*
......@@ -453,38 +345,6 @@ public class GitLabApi {
this(ApiVersion.V4, hostUrl, tokenType, authToken, null);
}
/**
* Constructs a GitLabApi instance set up to interact with the GitLab server using GitLab API version 4.
*
* @param hostUrl the URL of the GitLab server
* @param privateToken to private token to use for access to the API
*/
public GitLabApi(String hostUrl, String privateToken) {
this(ApiVersion.V4, hostUrl, privateToken, null);
}
/**
* Constructs a GitLabApi instance set up to interact with the GitLab server using the specified GitLab API version.
*
* @param apiVersion the ApiVersion specifying which version of the API to use
* @param hostUrl the URL of the GitLab server
* @param session the Session instance obtained by logining into the GitLab server
*/
public GitLabApi(ApiVersion apiVersion, String hostUrl, Session session) {
this(apiVersion, hostUrl, TokenType.PRIVATE, session.getPrivateToken(), null);
this.session = session;
}
/**
* Constructs a GitLabApi instance set up to interact with the GitLab server using GitLab API version 4.
*
* @param hostUrl the URL of the GitLab server
* @param session the Session instance obtained by logining into the GitLab server
*/
public GitLabApi(String hostUrl, Session session) {
this(ApiVersion.V4, hostUrl, session);
}
/**
* Constructs a GitLabApi instance set up to interact with the GitLab server using the specified GitLab API version.
*
......@@ -498,18 +358,6 @@ public class GitLabApi {
this(apiVersion, hostUrl, tokenType, authToken, secretToken, null);
}
/**
* Constructs a GitLabApi instance set up to interact with the GitLab server using the specified GitLab API version.
*
* @param apiVersion the ApiVersion specifying which version of the API to use
* @param hostUrl the URL of the GitLab server
* @param privateToken to private token to use for access to the API
* @param secretToken use this token to validate received payloads
*/
public GitLabApi(ApiVersion apiVersion, String hostUrl, String privateToken, String secretToken) {
this(apiVersion, hostUrl, privateToken, secretToken, null);
}
/**
* Constructs a GitLabApi instance set up to interact with the GitLab server using GitLab API version 4.
*
......@@ -522,28 +370,17 @@ public class GitLabApi {
this(ApiVersion.V4, hostUrl, tokenType, authToken, secretToken);
}
/**
* Constructs a GitLabApi instance set up to interact with the GitLab server using GitLab API version 4.
*
* @param hostUrl the URL of the GitLab server
* @param privateToken to private token to use for access to the API
* @param secretToken use this token to validate received payloads
*/
public GitLabApi(String hostUrl, String privateToken, String secretToken) {
this(ApiVersion.V4, hostUrl, TokenType.PRIVATE, privateToken, secretToken);
}
/**
* Constructs a GitLabApi instance set up to interact with the GitLab server specified by GitLab API version.
*
* @param apiVersion the ApiVersion specifying which version of the API to use
* @param hostUrl the URL of the GitLab server
* @param privateToken to private token to use for access to the API
* @param personalAccessToken to private token to use for access to the API
* @param secretToken use this token to validate received payloads
* @param clientConfigProperties Map instance with additional properties for the Jersey client connection
*/
public GitLabApi(ApiVersion apiVersion, String hostUrl, String privateToken, String secretToken, Map<String, Object> clientConfigProperties) {
this(apiVersion, hostUrl, TokenType.PRIVATE, privateToken, secretToken, clientConfigProperties);
public GitLabApi(ApiVersion apiVersion, String hostUrl, String personalAccessToken, String secretToken, Map<String, Object> clientConfigProperties) {
this(apiVersion, hostUrl, TokenType.PRIVATE, personalAccessToken, secretToken, clientConfigProperties);
}
/**
......@@ -563,12 +400,12 @@ public class GitLabApi {
* Constructs a GitLabApi instance set up to interact with the GitLab server using GitLab API version 4.
*
* @param hostUrl the URL of the GitLab server
* @param privateToken to private token to use for access to the API
* @param personalAccessToken the private token to use for access to the API
* @param secretToken use this token to validate received payloads
* @param clientConfigProperties Map instance with additional properties for the Jersey client connection
*/
public GitLabApi(String hostUrl, String privateToken, String secretToken, Map<String, Object> clientConfigProperties) {
this(ApiVersion.V4, hostUrl, TokenType.PRIVATE, privateToken, secretToken, clientConfigProperties);
public GitLabApi(String hostUrl, String personalAccessToken, String secretToken, Map<String, Object> clientConfigProperties) {
this(ApiVersion.V4, hostUrl, TokenType.PRIVATE, personalAccessToken, secretToken, clientConfigProperties);
}
/**
......@@ -588,6 +425,28 @@ public class GitLabApi {
apiClient = new GitLabApiClient(apiVersion, hostUrl, tokenType, authToken, secretToken, clientConfigProperties);
}
/**
* Create a new GitLabApi instance that is logically a duplicate of this instance, with the exception of sudo state.
*
* @return a new GitLabApi instance that is logically a duplicate of this instance, with the exception of sudo state.
*/
public final GitLabApi duplicate() {
Integer sudoUserId = this.getSudoAsId();
GitLabApi gitLabApi = new GitLabApi(apiVersion, gitLabServerUrl,
getTokenType(), getAuthToken(), getSecretToken(), clientConfigProperties);
if (sudoUserId != null) {
gitLabApi.apiClient.setSudoAsId(sudoUserId);
}
if (getIgnoreCertificateErrors()) {
gitLabApi.setIgnoreCertificateErrors(true);
}
gitLabApi.defaultPerPage = this.defaultPerPage;
return (gitLabApi);
}
/**
* Enable the logging of the requests to and the responses from the GitLab server API
* using the GitLab4J shared Logger instance and Level.FINE as the level.
......@@ -1583,25 +1442,6 @@ public class GitLabApi {
return (servicesApi);
}
/**
* Gets the SessionApi instance owned by this GitLabApi instance. The SessionApi is used
* to perform a login to the GitLab API.
*
* @return the SessionApi instance owned by this GitLabApi instance
*/
public SessionApi getSessionApi() {
if (sessionApi == null) {
synchronized (this) {
if (sessionApi == null) {
sessionApi = new SessionApi(this);
}
}
}
return (sessionApi);
}
/**
* Gets the SystemHooksApi instance owned by this GitLabApi instance. All methods
* require administrator authorization.
......
package org.gitlab4j.api;
import javax.ws.rs.core.Form;
import javax.ws.rs.core.Response;
import org.gitlab4j.api.models.Session;
/**
* This class implements the client side API for the GitLab login call.
*/
public class SessionApi extends AbstractApi {
public SessionApi(GitLabApi gitLabApi) {
super(gitLabApi);
}
/**
* Login to get private token. This functionality is not available on GitLab servers 10.2 and above.
*
* <pre><code>GitLab Endpoint: POST /session</code></pre>
*
* @param username the username to login
* @param email the email address to login
* @param password the password of the user
* @return a Session instance with info on the logged in user
* @throws GitLabApiException if any exception occurs
*/
public Session login(String username, String email, String password) throws GitLabApiException {
if ((username == null || username.trim().length() == 0) && (email == null || email.trim().length() == 0)) {
throw new IllegalArgumentException("both username and email cannot be empty or null");
}
Form formData = new Form();
addFormParam(formData, "email", email, false);
addFormParam(formData, "password", password, true);
addFormParam(formData, "login", username, false);
Response response = post(Response.Status.CREATED, formData, "session");
return (response.readEntity(Session.class));
}
}
package org.gitlab4j.api.models;
import java.util.Date;
import java.util.List;
import org.gitlab4j.api.utils.JacksonJson;
public class Session {
private String avatarUrl;
private String bio;
private Boolean blocked;
private Boolean canCreateGroup;
private Boolean canCreateProject;
private Integer colorSchemeId;
private Date createdAt;
private Date currentSignInAt;
private Boolean darkScheme;
private String email;
private Integer id;
private List<Identity> identities;
private Boolean isAdmin;
private String linkedin;
private String name;
private String privateToken;
private Integer projectsLimit;
private String state;
private String skype;
private Integer themeId;
private String twitter;
private Boolean twoFactorEnabled;
private String username;
private String websiteUrl;
public String getAvatarUrl() {
return avatarUrl;
}
public void setAvatarUrl(String avatarUrl) {
this.avatarUrl = avatarUrl;
}
public String getBio() {
return bio;
}
public void setBio(String bio) {
this.bio = bio;
}
public Boolean getBlocked() {
return blocked;
}
public void setBlocked(Boolean blocked) {
this.blocked = blocked;
}
public Boolean getCanCreateGroup() {
return canCreateGroup;
}
public void setCanCreateGroup(Boolean canCreateGroup) {
this.canCreateGroup = canCreateGroup;
}
public Boolean getCanCreateProject() {
return canCreateProject;
}
public void setCanCreateProject(Boolean canCreateProject) {
this.canCreateProject = canCreateProject;
}
public Integer getColorSchemeId() {
return colorSchemeId;
}
public void setColorSchemeId(Integer colorSchemeId) {
this.colorSchemeId = colorSchemeId;
}
public Date getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
public Date getCurrentSignInAt() {
return currentSignInAt;
}
public void setCurrentSignInAt(Date currentSignInAt) {
this.currentSignInAt = currentSignInAt;
}
public Boolean getDarkScheme() {
return darkScheme;
}
public void setDarkScheme(Boolean darkScheme) {
this.darkScheme = darkScheme;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public List<Identity> getIdentities() {
return identities;
}
public void setIdentities(List<Identity> identities) {
this.identities = identities;
}
public Boolean getIsAdmin() {
return isAdmin;
}
public void setIsAdmin(Boolean isAdmin) {
this.isAdmin = isAdmin;
}
public String getLinkedin() {
return linkedin;
}
public void setLinkedin(String linkedin) {
this.linkedin = linkedin;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPrivateToken() {
return privateToken;
}
public void setPrivateToken(String privateToken) {
this.privateToken = privateToken;
}
public Integer getProjectsLimit() {
return projectsLimit;
}
public void setProjectsLimit(Integer projectsLimit) {
this.projectsLimit = projectsLimit;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getSkype() {
return skype;
}
public void setSkype(String skype) {
this.skype = skype;
}
public Integer getThemeId() {
return themeId;
}
public void setThemeId(Integer themeId) {
this.themeId = themeId;
}
public String getTwitter() {
return twitter;
}
public void setTwitter(String twitter) {
this.twitter = twitter;
}
public Boolean getTwoFactorEnabled() {
return twoFactorEnabled;
}
public void setTwoFactorEnabled(Boolean twoFactorEnabled) {
this.twoFactorEnabled = twoFactorEnabled;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getWebsiteUrl() {
return websiteUrl;
}
public void setWebsiteUrl(String websiteUrl) {
this.websiteUrl = websiteUrl;
}
@Override
public String toString() {
return (JacksonJson.toJsonString(this));
}
}
......@@ -160,7 +160,6 @@ public class TestCommitsApi extends AbstractIntegrationTest {
List<CommitRef> commitRefs = gitLabApi.getCommitsApi().getCommitRefs(testProject.getId(), commits.get(0).getId());
assertNotNull(commitRefs);
assertTrue(commitRefs.size() > 0);
}
@Test
......
......@@ -95,7 +95,6 @@ import org.gitlab4j.api.models.RepositoryFile;
import org.gitlab4j.api.models.Runner;
import org.gitlab4j.api.models.RunnerDetail;
import org.gitlab4j.api.models.SearchBlob;
import org.gitlab4j.api.models.Session;
import org.gitlab4j.api.models.Snippet;
import org.gitlab4j.api.models.SshKey;
import org.gitlab4j.api.models.SystemHook;
......@@ -562,12 +561,6 @@ public class TestGitLabApiBeans {
assertTrue(compareJson(snippet, "snippet.json"));
}
@Test
public void testSession() throws Exception {
Session session = unmarshalResource(Session.class, "session.json");
assertTrue(compareJson(session, "session.json"));
}
@Test
public void testSlackService() throws Exception {
SlackService slackNotifications = unmarshalResource(SlackService.class, "slack-notifications.json");
......
package org.gitlab4j.api;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assume.assumeFalse;
import static org.junit.Assume.assumeTrue;
import org.gitlab4j.api.GitLabApi.ApiVersion;
import org.gitlab4j.api.models.Version;
import org.gitlab4j.api.utils.SecretString;
import org.junit.Before;
......@@ -32,7 +30,6 @@ public class TestGitLabLogin implements PropertyConstants {
private static final String TEST_PRIVATE_TOKEN = HelperUtils.getProperty(PRIVATE_TOKEN_KEY);
private static String problems = "";
private static boolean hasSession;
public TestGitLabLogin() {
super();
......@@ -59,21 +56,6 @@ public class TestGitLabLogin implements PropertyConstants {
problems += "TEST_PRIVATE_TOKEN cannot be empty\n";
}
if (problems.isEmpty()) {
try {
GitLabApi gitLabApi = new GitLabApi(ApiVersion.V4, TEST_HOST_URL, TEST_PRIVATE_TOKEN);
Version version = gitLabApi.getVersion();
String[] parts = version.getVersion().split(".", -1);
if (parts.length == 3) {
if (Integer.parseInt(parts[0]) < 10 ||
(Integer.parseInt(parts[0]) == 10 && Integer.parseInt(parts[1]) < 2)) {
hasSession = true;
}
}
} catch (Exception e) {
}
}
if (!problems.isEmpty()) {
System.err.print(problems);
}
......@@ -84,16 +66,6 @@ public class TestGitLabLogin implements PropertyConstants {
assumeTrue(problems != null && problems.isEmpty());
}
@Test
public void testSessionFallover() throws GitLabApiException {
assumeFalse(hasSession);
@SuppressWarnings("deprecation")
GitLabApi gitLabApi = GitLabApi.login(ApiVersion.V4, TEST_HOST_URL, TEST_LOGIN_USERNAME, TEST_LOGIN_PASSWORD);
assertNotNull(gitLabApi);
Version version = gitLabApi.getVersion();
assertNotNull(version);
}
@Test
public void testOauth2LoginWithStringPassword() throws GitLabApiException {
GitLabApi gitLabApi = GitLabApi.oauth2Login(TEST_HOST_URL, TEST_LOGIN_USERNAME, TEST_LOGIN_PASSWORD, null, null, true);
......
{
"name": "John Smith",
"username": "john_smith",
"id": 32,
"state": "active",
"created_at": "2015-01-29T21:07:19.440Z",
"is_admin": true,
"skype": "",
"linkedin": "",
"twitter": "",
"website_url": "",
"email": "john@example.com",
"theme_id": 1,
"color_scheme_id": 1,
"projects_limit": 10,
"current_sign_in_at": "2015-07-07T07:10:58.392Z",
"identities": [],
"can_create_group": true,
"can_create_project": true,
"two_factor_enabled": false,
"private_token": "9koXpg98eAheJpvBs5tK"
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment