1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
#! /usr/bin/env python
# -*- coding: UTF-8 -*-
# Python unit tests for Lasso library
#
# Copyright (C) 2004 Entr'ouvert
# http://lasso.entrouvert.org
#
# Authors: Emmanuel Raviart <eraviart@entrouvert.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import unittest
import sys
sys.path.insert(0, '..')
sys.path.insert(0, '../.libs')
import lasso
from IdentityProvider import IdentityProvider
from ServiceProvider import ServiceProvider
from websimulator import *
class LoginTestCase(unittest.TestCase):
def generateIdpSite(self, internet):
site = IdentityProvider(self, internet, "https://identity-provider/")
site.providerId = "https://identity-provider/metadata"
server = lasso.Server.new(
"../../examples/data/idp-metadata.xml",
"../../examples/data/idp-public-key.pem",
"../../examples/data/idp-private-key.pem",
"../../examples/data/idp-crt.pem",
lasso.signatureMethodRsaSha1)
server.add_provider(
"../../examples/data/sp-metadata.xml",
"../../examples/data/sp-public-key.pem",
"../../examples/data/ca-crt.pem")
site.serverDump = server.dump()
self.failUnless(site.serverDump)
server.destroy()
site.addWebUser('Chantereau')
site.addWebUser('Clapies')
site.addWebUser('Febvre')
site.addWebUser('Nowicki')
return site
def generateSpSite(self, internet):
site = ServiceProvider(self, internet, "https://service-provider/")
site.providerId = "https://service-provider/metadata"
server = lasso.Server.new(
"../../examples/data/sp-metadata.xml",
"../../examples/data/sp-public-key.pem",
"../../examples/data/sp-private-key.pem",
"../../examples/data/sp-crt.pem",
lasso.signatureMethodRsaSha1)
server.add_provider(
"../../examples/data/idp-metadata.xml",
"../../examples/data/idp-public-key.pem",
"../../examples/data/ca-crt.pem")
site.serverDump = server.dump()
self.failUnless(site.serverDump)
server.destroy()
site.addWebUser('Nicolas')
site.addWebUser('Romain')
site.addWebUser('Valery')
return site
## def setUp(self):
## pass
## def tearDown(self):
## pass
def test01_generateServers(self):
"""Service provider initiated login using HTTP redirect ans service provider initiated
logout using SOAP."""
internet = Internet()
idpSite = self.generateIdpSite(internet)
spSite = self.generateSpSite(internet)
spSite.idpSite = idpSite
principal = Principal(internet, "Romain Chantereau")
principal.keyring[idpSite.url] = "Chantereau"
principal.keyring[spSite.url] = "Romain"
httpResponse = spSite.doHttpRequest(HttpRequest(principal, "GET", "/loginUsingRedirect"))
self.failUnlessEqual(httpResponse.statusCode, 200)
httpResponse = spSite.doHttpRequest(HttpRequest(principal, "GET", "/logoutUsingSoap"))
self.failUnlessEqual(httpResponse.statusCode, 200)
## def test06(self):
## """Service provider LECP login."""
## # LECP has asked service provider for login.
## spServer = self.getServer()
## # FIXME: Why doesn't lasso.Lecp.new have spServer as argument?
## # spLecp = lasso.Lecp.new(spServer)
## spLecp = lasso.Lecp.new()
## spLecp.init_authn_request_envelope(sp, )
## lasso_lecp_init_authn_request_envelope(sp_lecp, spserver, authnRequest);
## lasso_lecp_build_authn_request_envelope_msg(sp_lecp);
## msg = g_strdup(sp_lecp->msg_body);
## lasso_lecp_destroy(sp_lecp);
suite1 = unittest.makeSuite(LoginTestCase, 'test')
allTests = unittest.TestSuite((suite1,))
if __name__ == '__main__':
sys.exit(not unittest.TextTestRunner(verbosity=2).run(allTests).wasSuccessful())
|