3636
3737import static org .assertj .core .api .Assertions .assertThat ;
3838import static org .assertj .core .api .Assertions .assertThatThrownBy ;
39+ import static org .junit .jupiter .api .Assertions .assertDoesNotThrow ;
3940
4041@ WithJenkins
4142class BitbucketSCMFileTest {
@@ -53,11 +54,29 @@ static void init(JenkinsRule rule) {
5354 void verify_content_throws_FileNotFoundException_when_file_does_not_exists () {
5455 BitbucketApi client = BitbucketIntegrationClientFactory .getApiMockClient ("https://acme.bitbucket.com" );
5556
56- BitbucketSCMFile parent = new BitbucketSCMFile (client , "master" , "hash " );
57+ BitbucketSCMFile parent = new BitbucketSCMFile (client , "master" , "51af66dad14c38d7c69874c57a65f77f688e3f33 " );
5758 BitbucketSCMFile file = new BitbucketSCMFile (parent , "pipeline_config.groovy" , Type .REGULAR_FILE , "046d9a3c1532acf4cf08fe93235c00e4d673c1d2" );
5859 assertThatThrownBy (file ::content ).isInstanceOf (FileNotFoundException .class );
5960 }
6061
62+ @ Issue ("JENKINS-75208" )
63+ @ Test
64+ void test_SCMFile_does_not_contains_illegal_chars_in_the_name () throws Exception {
65+ BitbucketApi client = BitbucketIntegrationClientFactory .getApiMockClient ("https://acme.bitbucket.com" );
66+
67+ BitbucketSCMFile parent = new BitbucketSCMFile (client , "feature/pipeline" , null );
68+ BitbucketSCMFile file = new BitbucketSCMFile (parent , "Jenkinsfile" , null , "2c130d767a38ac4ef511797f221315f35a2aea55" );
69+ SCMFile scmFile = assertDoesNotThrow (() -> client .getFile (file ));
70+
71+ assertThat (scmFile .isFile ()).isTrue ();
72+ assertThat (scmFile .getName ()).isEqualTo ("Jenkinsfile" );
73+ assertThat (scmFile ).isInstanceOfSatisfying (BitbucketSCMFile .class ,
74+ f -> {
75+ assertThat (f .getRef ()).isEqualTo ("feature/pipeline" );
76+ assertThat (f .getHash ()).isEqualTo ("2c130d767a38ac4ef511797f221315f35a2aea55" );
77+ });
78+ }
79+
6180 @ Issue ("JENKINS-75157" )
6281 @ Test
6382 void test_SCMBinder_behavior_when_discover_the_Jenkinsfile_for_a_given_branch_on_cloud () throws Exception {
0 commit comments