1
1
package au.org.ala.merit
2
2
3
3
import org.apache.http.HttpStatus
4
+ import org.h2.engine.User
4
5
import org.springframework.mock.web.MockMultipartFile
5
6
import spock.lang.Specification
6
7
import grails.testing.web.controllers.ControllerUnitTest
7
8
8
9
class DownloadControllerSpec extends Specification implements ControllerUnitTest<DownloadController > {
9
10
10
11
WebService webService = Mock (WebService )
12
+ UserService userService = Mock (UserService )
11
13
def setup () {
14
+ controller. userService = userService
12
15
controller. webService = webService
13
16
}
14
17
@@ -20,6 +23,7 @@ class DownloadControllerSpec extends Specification implements ControllerUnitTest
20
23
def resp = controller. get()
21
24
22
25
then :
26
+ 1 * userService. userIsSiteAdmin() >> true
23
27
1 * webService. proxyGetRequest(_, {it. endsWith(' download/uuid1234' )}, true , true , _) >> [status :HttpStatus . SC_OK ]
24
28
25
29
and : " We return null to inform grails to not attempt to process a view as we are proxying a response from ecodata"
@@ -32,6 +36,7 @@ class DownloadControllerSpec extends Specification implements ControllerUnitTest
32
36
controller. get()
33
37
34
38
then :
39
+ 1 * userService. userIsSiteAdmin() >> true
35
40
response. status == HttpStatus . SC_BAD_REQUEST
36
41
}
37
42
@@ -45,6 +50,7 @@ class DownloadControllerSpec extends Specification implements ControllerUnitTest
45
50
controller. get()
46
51
47
52
then :
53
+ 1 * userService. userIsSiteAdmin() >> true
48
54
1 * webService. proxyGetRequest(_, {it. contains(' download/file' )}, true , true , _) >> {
49
55
resp, url, userId, apiKey, timeout ->
50
56
formatPassedToEcodata = url. endsWith(format)
0 commit comments