@@ -21,6 +21,7 @@ import spock.lang.IgnoreIf
21
21
import spock.lang.Requires
22
22
import spock.lang.Specification
23
23
import spock.lang.Timeout
24
+ import spock.lang.Unroll
24
25
25
26
@Timeout (30 )
26
27
@IgnoreIf ({System .getenv(' NXF_SMOKE' )})
@@ -35,7 +36,7 @@ class BitbucketRepositoryProviderTest extends Specification {
35
36
when :
36
37
def url = new BitbucketRepositoryProvider (' pditommaso/tutorial' ,config). getCloneUrl()
37
38
then :
38
- url == " https:// ${ config.user } @bitbucket.org/pditommaso/tutorial.git" . toString()
39
+ url ==~ / https:\/\/\w + @bitbucket.org\ / pditommaso\ / tutorial.git/
39
40
}
40
41
41
42
def testGetHomePage () {
@@ -50,11 +51,11 @@ class BitbucketRepositoryProviderTest extends Specification {
50
51
def config = new ProviderConfig (' bitbucket' ). setAuth(token)
51
52
52
53
when :
53
- def repo = new BitbucketRepositoryProvider (' pditommaso/tutorial ' , config)
54
+ def repo = new BitbucketRepositoryProvider (' pditommaso/secret ' , config)
54
55
def result = repo. readText(' main.nf' )
55
56
56
57
then :
57
- result. trim(). startsWith( ' #!/usr/bin/env nextflow ' )
58
+ result. trim() == " println 'Hello from Bitbucket' "
58
59
}
59
60
60
61
@Requires ( { System .getenv(' NXF_BITBUCKET_ACCESS_TOKEN' ) } )
@@ -110,17 +111,17 @@ class BitbucketRepositoryProviderTest extends Specification {
110
111
expect :
111
112
new BitbucketRepositoryProvider (' pditommaso/tutorial' , config)
112
113
.setRevision(' test-branch' )
113
- .getContentUrl(' main.nf' ) == ' https://bitbucket.org/api /2.0/repositories/pditommaso/tutorial/src/test-branch/main.nf'
114
+ .getContentUrl(' main.nf' ) == ' https://api. bitbucket.org/2.0/repositories/pditommaso/tutorial/src/test-branch/main.nf'
114
115
115
116
and :
116
117
new BitbucketRepositoryProvider (' pditommaso/tutorial' , config)
117
118
.setRevision(' feature/with-slash' )
118
- .getContentUrl(' main.nf' ) == ' https://bitbucket.org/api /2.0/repositories/pditommaso/tutorial/src/a6b825b22d46758cdeb496ae6cf26aef839ace52/main.nf'
119
+ .getContentUrl(' main.nf' ) == ' https://api. bitbucket.org/2.0/repositories/pditommaso/tutorial/src/a6b825b22d46758cdeb496ae6cf26aef839ace52/main.nf'
119
120
120
121
and :
121
122
new BitbucketRepositoryProvider (' pditommaso/tutorial' , config)
122
123
.setRevision(' test/tag/v2' )
123
- .getContentUrl(' main.nf' ) == ' https://bitbucket.org/api /2.0/repositories/pditommaso/tutorial/src/8f849beceb2ea479ef836809ca33d3daeeed25f9/main.nf'
124
+ .getContentUrl(' main.nf' ) == ' https://api. bitbucket.org/2.0/repositories/pditommaso/tutorial/src/8f849beceb2ea479ef836809ca33d3daeeed25f9/main.nf'
124
125
125
126
}
126
127
@@ -171,4 +172,35 @@ class BitbucketRepositoryProviderTest extends Specification {
171
172
! data. contains(' world' )
172
173
data. contains(' mundo' )
173
174
}
175
+
176
+ @Unroll
177
+ def ' should validate hasCredentials' () {
178
+ given :
179
+ def provider = new BitbucketRepositoryProvider (' pditommaso/tutorial' , CONFIG )
180
+
181
+ expect :
182
+ provider. hasCredentials() == EXPECTED
183
+
184
+ where :
185
+ EXPECTED | CONFIG
186
+ false | new ProviderConfig (' bitbucket' )
187
+ false | new ProviderConfig (' bitbucket' ). setUser(' foo' )
188
+ true | new ProviderConfig (' bitbucket' ). setUser(' foo' ). setPassword(' bar' )
189
+ true | new ProviderConfig (' bitbucket' ). setToken(' xyz' )
190
+ }
191
+
192
+ @Unroll
193
+ def ' should validate getAuth' () {
194
+ given :
195
+ def provider = new BitbucketRepositoryProvider (' pditommaso/tutorial' , CONFIG )
196
+
197
+ expect :
198
+ provider. getAuth() == EXPECTED as String []
199
+
200
+ where :
201
+ EXPECTED | CONFIG
202
+ null | new ProviderConfig (' bitbucket' )
203
+ [" Authorization" , " Bearer xyz" ] | new ProviderConfig (' bitbucket' ). setToken(' xyz' )
204
+ [" Authorization" , " Basic ${ "foo:bar".bytes.encodeBase64()} " ] | new ProviderConfig (' bitbucket' ). setUser(' foo' ). setPassword(' bar' )
205
+ }
174
206
}
0 commit comments