passing more options to DownloadSupport methods

13 views
Skip to first unread message

Samuel Rossinovic

unread,
Oct 8, 2017, 9:32:19 PM10/8/17
to Geb User Mailing List
Hi.


Would appreciate a suggestion how to pass the certificate's resource name & password as arguments to the closure. Can this be done?

Thanks!
Sam

Marcin Erdmann

unread,
Oct 9, 2017, 1:20:00 PM10/9/17
to Geb User Mailing List
Sam,

Can you please explain what you mean by "pass the certificate's resource name & password as arguments to the closure"? I had a look at the snippet you linked to and I don't quite get what you are trying to achieve and where you you want pass the data from.

Marcin

--
You received this message because you are subscribed to the Google Groups "Geb User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+unsubscribe@googlegroups.com.
To post to this group, send email to geb-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geb-user/c57e23bc-b523-4e6f-8d40-41a391a69307%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Samuel Rossinovic

unread,
Oct 12, 2017, 3:58:20 AM10/12/17
to Geb User Mailing List
Hey.
Sorry. Think brain wasn't 100% online when I posted this. Here's what I ended-up with:

class Utils {
   
static final def downloadBytesWithKeyStore = { url, keystore, pass ->
        downloadBytes url
, { HttpURLConnection connection ->
           
if (connection instanceof HttpsURLConnection) {
               
def helper = new SelfSignedCertificateHelper(getClass().getResource(keystore), pass)
                helper
.acceptCertificatesFor(connection as HttpsURLConnection)
           
}
       
}
   
}
}

class BaseSpec extends GebReportingSpec {
   
static final def DFL_KS_PASS = 'password', DFL_KS = "keystore.jks"

   
def downloadUrl(url,jks = DFL_KS, pass = DFL_KS_PASS) {
       
Utils.downloadBytesWithKeyStore.delegate = page
       
Utils.downloadBytesWithKeyStore url, jks, pass
   
}
}

class MySpec {
   
def "test foo"() {
       
//...
        downloadUrl
'files/foo/bar'
       
//...
   
}
}

Cheers,
Sam

On Tuesday, October 10, 2017 at 4:20:00 AM UTC+11, Marcin Erdmann wrote:
Sam,

Can you please explain what you mean by "pass the certificate's resource name & password as arguments to the closure"? I had a look at the snippet you linked to and I don't quite get what you are trying to achieve and where you you want pass the data from.

Marcin
On Mon, Oct 9, 2017 at 2:32 AM, Samuel Rossinovic <samuel.r...@gmail.com> wrote:
Hi.


Would appreciate a suggestion how to pass the certificate's resource name & password as arguments to the closure. Can this be done?

Thanks!
Sam

--
You received this message because you are subscribed to the Google Groups "Geb User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages