如何在CAS登录后通过重定向对Grails 3应用程序进行功能测试?
问题 我有一个使用CAS(中央认证服务)登录的应用程序。在配置(如何在CAS登录后通过重定向对Grails 3应用程序进行功能测试?,grails,intellij-idea,cas,functional-testing,geb,Grails,Intellij Idea,Cas,Functional Testing,Geb,问题 我有一个使用CAS(中央认证服务)登录的应用程序。在配置(application.yml)中,CAS的配置如下: grails: plugin: springsecurity: # ...other configurations omitted ... cas: serverUrlPrefix: "https://<some endpoint for the actual CAS>" serviceU
application.yml
)中,CAS的配置如下:
grails:
plugin:
springsecurity:
# ...other configurations omitted ...
cas:
serverUrlPrefix: "https://<some endpoint for the actual CAS>"
serviceUrl: https://localhost:8443/myapp/login/cas
# ...other configurations omitted ...
堆栈跟踪:
java.lang.RuntimeException: org.apache.http.conn.HttpHostConnectException: Connect to localhost:8443 [localhost/127.0.0.1] failed: Connection refused (Connection refused)
at com.gargoylesoftware.htmlunit.WebClient.download(WebClient.java:2067)
at com.gargoylesoftware.htmlunit.html.HtmlForm.submit(HtmlForm.java:138)
at com.gargoylesoftware.htmlunit.html.HtmlButton.doClickStateUpdate(HtmlButton.java:97)
at com.gargoylesoftware.htmlunit.html.DomElement.click(DomElement.java:786)
at com.gargoylesoftware.htmlunit.html.DomElement.click(DomElement.java:733)
at org.openqa.selenium.htmlunit.HtmlUnitMouse.click(HtmlUnitMouse.java:74)
at org.openqa.selenium.htmlunit.HtmlUnitWebElement.click(HtmlUnitWebElement.java:151)
at geb.navigator.NonEmptyNavigator.click(NonEmptyNavigator.groovy:437)
at geb.content.TemplateDerivedPageContent.click(TemplateDerivedPageContent.groovy:115)
at myapp.LoginPage.login(LoginPage.groovy:22)
at geb.Browser.methodMissing(Browser.groovy:207)
at geb.spock.GebSpec.methodMissing(GebSpec.groovy:56)
at myapp.MyAppControllerFunctionalSpec.test something(MyAppControllerFunctionalSpec.groovy:39)
Caused by: org.apache.http.conn.HttpHostConnectException: Connect to localhost:8443 [localhost/127.0.0.1] failed: Connection refused (Connection refused)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:158)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71)
at com.gargoylesoftware.htmlunit.HttpWebConnection.getResponse(HttpWebConnection.java:179)
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1321)
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1379)
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponse(WebClient.java:1238)
at com.gargoylesoftware.htmlunit.WebClient.download(WebClient.java:2063)
... 12 more
Caused by: java.net.ConnectException: Connection refused (Connection refused)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:337)
at com.gargoylesoftware.htmlunit.httpclient.HtmlUnitSSLConnectionSocketFactory.connectSocket(HtmlUnitSSLConnectionSocketFactory.java:189)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:141)
... 25 more
问题
什么是正确的方法使我的功能测试能够通过CAS登录
其他信息
- Grails:3.2.7
- Groovy:2.4.12
- IntelliJ:2017.1.5
我尝试过使用环境变量设置端口号,但没有效果。请参阅:我当前的解决方案,以使用Intellij IDEA的CAS登录运行功能测试:
src/integration test/groovy/
目录下grails test-app foo.MyAppControllerFunctionalSpec --integration