1 import unittest
, os
, setup_path
5 class SubversionAuthTestCase(unittest
.TestCase
):
6 """Test cases for the Subversion auth."""
9 baton
= core
.svn_auth_open([])
10 self
.assert_(baton
is not None)
12 def test_set_parameter(self
):
13 baton
= core
.svn_auth_open([])
14 core
.svn_auth_set_parameter(baton
, "name", "somedata")
16 def test_invalid_cred_kind(self
):
17 baton
= core
.svn_auth_open([])
18 self
.assertRaises(core
.SubversionException
,
19 lambda: core
.svn_auth_first_credentials(
20 "unknown", "somerealm", baton
))
22 def test_credentials_get_username(self
):
23 def myfunc(realm
, maysave
, pool
):
24 self
.assertEquals("somerealm", realm
)
25 username_cred
= core
.svn_auth_cred_username_t()
26 username_cred
.username
= "bar"
27 username_cred
.may_save
= False
29 baton
= core
.svn_auth_open([core
.svn_auth_get_username_prompt_provider(myfunc
, 1)])
30 creds
= core
.svn_auth_first_credentials(
31 core
.SVN_AUTH_CRED_USERNAME
, "somerealm", baton
)
32 self
.assert_(creds
is not None)
34 def test_credentials_get_simple(self
):
35 def myfunc(realm
, username
, may_save
, pool
):
36 self
.assertEquals("somerealm", realm
)
37 simple_cred
= core
.svn_auth_cred_simple_t()
38 simple_cred
.username
= "mijnnaam"
39 simple_cred
.password
= "geheim"
40 simple_cred
.may_save
= False
42 baton
= core
.svn_auth_open([core
.svn_auth_get_simple_prompt_provider(myfunc
, 1)])
43 creds
= core
.svn_auth_first_credentials(
44 core
.SVN_AUTH_CRED_SIMPLE
, "somerealm", baton
)
45 self
.assert_(creds
is not None)
47 def test_credentials_get_ssl_client_cert(self
):
48 def myfunc(realm
, may_save
, pool
):
49 self
.assertEquals("somerealm", realm
)
50 ssl_cred
= core
.svn_auth_cred_ssl_client_cert_t()
51 ssl_cred
.cert_file
= "my-certs-file"
52 ssl_cred
.may_save
= False
54 baton
= core
.svn_auth_open([core
.svn_auth_get_ssl_client_cert_prompt_provider(myfunc
, 1)])
55 creds
= core
.svn_auth_first_credentials(
56 core
.SVN_AUTH_CRED_SSL_CLIENT_CERT
, "somerealm", baton
)
57 self
.assert_(creds
is not None)
59 def test_credentials_get_ssl_client_cert_pw(self
):
60 def myfunc(realm
, may_save
, pool
):
61 self
.assertEquals("somerealm", realm
)
62 ssl_cred_pw
= core
.svn_auth_cred_ssl_client_cert_pw_t()
63 ssl_cred_pw
.password
= "supergeheim"
64 ssl_cred_pw
.may_save
= False
66 baton
= core
.svn_auth_open([core
.svn_auth_get_ssl_client_cert_pw_prompt_provider(myfunc
, 1)])
67 creds
= core
.svn_auth_first_credentials(
68 core
.SVN_AUTH_CRED_SSL_CLIENT_CERT_PW
, "somerealm", baton
)
69 self
.assert_(creds
is not None)
72 return unittest
.makeSuite(SubversionAuthTestCase
, 'test')
74 if __name__
== '__main__':
75 runner
= unittest
.TextTestRunner()