-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue 3725 Bitbucket Cloud - Support App passwords authentication (#3726
- Loading branch information
Showing
4 changed files
with
73 additions
and
10 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
api/src/main/java/com/epam/pipeline/entity/git/AuthType.java
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright 2024 EPAM Systems, Inc. (https://www.epam.com/) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.epam.pipeline.entity.git; | ||
|
||
public enum AuthType { | ||
TOKEN, BASIC; | ||
} |
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
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 |
---|---|---|
|
@@ -17,31 +17,50 @@ | |
package com.epam.pipeline.manager.git; | ||
|
||
import com.epam.pipeline.AbstractSpringTest; | ||
import com.epam.pipeline.entity.git.AuthType; | ||
import com.epam.pipeline.entity.git.GitCommitEntry; | ||
import com.epam.pipeline.entity.git.GitProject; | ||
import com.epam.pipeline.entity.git.GitRepositoryEntry; | ||
import com.epam.pipeline.entity.git.GitTagEntry; | ||
import com.epam.pipeline.entity.pipeline.Pipeline; | ||
import com.epam.pipeline.entity.pipeline.Revision; | ||
import com.epam.pipeline.entity.preference.Preference; | ||
import com.epam.pipeline.exception.git.GitClientException; | ||
import com.epam.pipeline.manager.git.bitbucketcloud.BitbucketCloudService; | ||
import com.epam.pipeline.manager.preference.PreferenceManager; | ||
import com.epam.pipeline.manager.preference.SystemPreferences; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Ignore; | ||
import org.junit.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Value; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class BitbucketCloudServiceTest extends AbstractSpringTest { | ||
|
||
private static final String BRANCH = "test"; | ||
private static final String TAG = "test_tag10"; | ||
private static final String TAG = "test_tag1"; | ||
private static final String MESSAGE = "message"; | ||
private static final String COMMIT_ID = "d468da2"; | ||
private static final String COMMIT_ID = "c4cbce0"; | ||
private static final String FILE_PATH = "/test2/test_file.txt"; | ||
private static final String FOLDER_PATH = "test2"; | ||
private static final String CONTENT = "content123"; | ||
|
||
/* | ||
Authentication type should be set up in System Preferences(bitbucket.cloud.auth.type). | ||
If Authentication type is BASIC: | ||
repositoryPath should contain user name (like https://[email protected]/workspace/repository.git) | ||
token should contain app password | ||
Clone url looks like https://user_name:[email protected]/workspace/repository.git | ||
If Authentication type is TOKEN: | ||
repositoryPath should look like https://bitbucket.org/workspace/repository.git | ||
token should contain secure token | ||
Clone url looks like https://x-token-auth:[email protected]/workspace/repository.git | ||
*/ | ||
@Value("${bitbucket.cloud.repository.path}") | ||
private String repositoryPath; | ||
@Value("${bitbucket.cloud.token}") | ||
|
@@ -50,6 +69,16 @@ public class BitbucketCloudServiceTest extends AbstractSpringTest { | |
@Autowired | ||
private BitbucketCloudService service; | ||
|
||
@Autowired | ||
private PreferenceManager preferenceManager; | ||
|
||
@Before | ||
public void setup() { | ||
final Preference preference = SystemPreferences.BITBUCKET_CLOUD_AUTH_TYPE.toPreference(); | ||
preference.setValue(AuthType.TOKEN.name()); | ||
preferenceManager.update(Collections.singletonList(preference)); | ||
} | ||
|
||
@Ignore | ||
@Test | ||
public void testGetRepository() throws GitClientException { | ||
|