starting webric while test:ui call; adapted login test
[opensuse:yast-web-client.git] / webclient / test / dummy-host / host.rb
1 # host.rb
2   require 'rubygems'
3   require 'active_support'
4   require 'sinatra'
5
6   post '/login.xml' do
7     req = Hash.from_xml request.env["rack.input"].read
8     login = Hash.new
9     if req["hash"]["login"] == "webyast_guest"
10       login["login"] = "revoked"
11     else
12       login["login"] = "granted"
13       login["auth_token"] = {"expires"=>"Tue Aug 18 07:08:22 UTC 2009", "value"=>"3e3910533595dd5657c54c32f27fc6068df96873"}
14     end
15     login.to_xml
16   end
17
18   post '/logout.xml' do
19     logout = Hash.new
20     logout["logout"] = "Goodbye!"
21     logout.to_xml
22   end
23
24   get '/resources.xml' do
25     resources = [{"interface" => "org.opensuse.yast.modules.yapi.time",
26                  "singular" => true,
27                  "href" => "time"},
28                 {"interface" => "org.opensuse.yast.modules.yapi.users",
29                  "singular" => true,
30                  "href" => "users"},
31                 {"interface" => "org.opensuse.yast.modules.yapi.language",
32                  "singular" => true,
33                  "href" => "language"},
34                 {"interface" => "org.opensuse.yast.system.services",
35                  "singular" => true,
36                  "href" => "services"},
37                 {"interface" => "org.opensuse.yast.system.patches",
38                  "singular" => true,
39                  "href" => "patches"},
40                 {"interface" => "org.opensuse.yast.system.security",
41                  "singular" => true,
42                  "href" => "security"},
43                 {"interface" => "org.opensuse.yast.system.networks",
44                  "singular" => true,
45                  "href" => "networks"},
46                 {"interface" => "org.opensuse.yast.system.sambashares",
47                  "singular" => true,
48                  "href" => "sambashares"},
49                 {"interface" => "org.opensuse.yast.system.system",
50                  "singular" => true,
51                  "href" => "system"},
52                 {"interface" => "org.opensuse.yast.system.status",
53                  "singular" => true,
54                  "href" => "status"},
55                 {"interface" => "org.opensuse.yast.commandline",
56                  "singular" => true,
57                  "href" => "yast/commandline"}]
58     resources.to_xml(:root => "resources")
59   end 
60
61   get '/permissions.xml' do
62     permissions = [   {"name" => "org.opensuse.yast.webservice.read-permissions", "grant" => true},
63                       {"name" => "org.opensuse.yast.webservice.write-permissions", "grant" => true},
64                       {"name" =>"org.opensuse.yast.modules.yapi.language.setcurrentlanguage", "grant" => true},
65                       {"name" =>"org.opensuse.yast.system.network.read", "grant" => true},
66                       {"name" =>"org.opensuse.yast.language.read-firstlanguage", "grant" => true},
67                       {"name" =>"org.opensuse.yast.scr.error", "grant" => false},
68                       {"name" =>"org.opensuse.yast.services.execute-commands-gpm", "grant" => true},
69                       {"name" =>"org.opensuse.yast.scr.registeragent", "grant" => false},
70                       {"name" =>"org.opensuse.yast.language.read", "grant" => true},
71                       {"name" =>"org.opensuse.yast.systemtime.write-timezone", "grant" => true},
72                       {"name" =>"org.opensuse.yast.services.read-config-ntp-manualserver", "grant" => true},
73                       {"name" =>"org.opensuse.yast.system.services.execute", "grant" => true},
74                       {"name" =>"org.opensuse.yast.system.users.write", "grant" => true},
75                       {"name" =>"org.opensuse.yast.services.write-config", "grant" => true},
76                       {"name" =>"org.opensuse.yast.system.users.delete", "grant" => true},
77                       {"name" =>"org.opensuse.yast.system.patches.read", "grant" => true},
78                       {"name" =>"org.opensuse.yast.system.time.read", "grant" => true},
79                       {"name" =>"org.opensuse.yast.language.read-secondlanguages", "grant" => true},
80                       {"name" =>"org.opensuse.yast.services.read", "grant" => true},
81                       {"name" =>"org.opensuse.yast.system.users.read", "grant" => true},
82                       {"name" =>"org.opensuse.yast.system.patches.install", "grant" => true},
83                       {"name" =>"org.opensuse.yast.permissions.write", "grant" => true},
84                       {"name" =>"org.opensuse.yast.language.write", "grant" => true},
85                       {"name" =>"org.opensuse.yast.modules.yapi.users.useradd", "grant" => true},
86                       {"name" =>"org.opensuse.yast.scr.unregisteragent", "grant" => false},
87                       {"name" =>"org.opensuse.yast.services.read-config-ntp-enabled", "grant" => true},
88                       {"name" =>"org.opensuse.yast.scr.execute", "grant" => false},
89                       {"name" =>"org.opensuse.yast.modules.yapi.language.setutf8", "grant" => true},
90                       {"name" =>"org.opensuse.yast.scr.unregisterallagents", "grant" => false},
91                       {"name" =>"org.opensuse.yast.services.write-config-ntp", "grant" => true},
92                       {"name" =>"org.opensuse.yast.module-manager.import", "grant" => true},
93                       {"name" =>"org.opensuse.yast.modules.yapi.time.write", "grant" => true},
94                       {"name" =>"org.opensuse.yast.services.execute-commands", "grant" => true},
95                       {"name" =>"org.opensuse.yast.scr.dir", "grant" => false},
96                       {"name" =>"org.opensuse.yast.modules.yapi.language.getlanguages", "grant" => true},
97                       {"name" =>"org.opensuse.yast.systemtime.write", "grant" => true},
98                       {"name" =>"org.opensuse.yast.system.status.writelimits", "grant" => true},
99                       {"name" =>"org.opensuse.yast.system.time.write", "grant" => true},
100                       {"name" =>"org.opensuse.yast.language.read-available", "grant" => true},
101                       {"name" =>"org.opensuse.yast.services.execute-commands-random", "grant" => true},
102                       {"name" =>"org.opensuse.yast.modules.yapi.users.usersget", "grant" => true},
103                       {"name" =>"org.opensuse.yast.system.security.write", "grant" => true},
104                       {"name" =>"org.opensuse.yast.permissions.read", "grant" => true},
105                       {"name" =>"org.opensuse.yast.system.services.read", "grant" => true},
106                       {"name" =>"org.opensuse.yast.services.execute", "grant" => true},
107                       {"name" =>"org.opensuse.yast.services.execute-commands-ntp", "grant" => true},
108                       {"name" =>"org.opensuse.yast.services.execute-commands-smbfs", "grant" => true},
109                       {"name" =>"org.opensuse.yast.services.write-config-ntp-enabled", "grant" => true},
110                       {"name" =>"org.opensuse.yast.scr.read", "grant" => false},
111                       {"name" =>"org.opensuse.yast.modules.yapi.language.getcurrentlanguage", "grant" => true},
112                       {"name" =>"org.opensuse.yast.systemtime.read", "grant" => true},
113                       {"name" =>"org.opensuse.yast.modules.yapi.time.read", "grant" => true},
114                       {"name" =>"org.opensuse.yast.scr.write", "grant" => false},
115                       {"name" =>"org.opensuse.yast.patch.install", "grant" => true},
116                       {"name" =>"org.opensuse.yast.modules.yapi.language.isutf8", "grant" => true},
117                       {"name" =>"org.opensuse.yast.system.services.write", "grant" => true},
118                       {"name" =>"org.opensuse.yast.services.write-config-ntp-manualserver", "grant" => true},
119                       {"name" =>"org.opensuse.yast.system.language.read", "grant" => true},
120                       {"name" =>"org.opensuse.yast.services.write", "grant" => true},
121                       {"name" =>"org.opensuse.yast.scr.registernewagents", "grant" => false},
122                       {"name" =>"org.opensuse.yast.language.write-secondlanguages", "grant" => true},
123                       {"name" =>"org.opensuse.yast.modules.yapi.language.write", "grant" => true},
124                       {"name" =>"org.opensuse.yast.system.status.read", "grant" => true},
125                       {"name" =>"org.opensuse.yast.system.users.new", "grant" => true},
126                       {"name" =>"org.opensuse.yast.services.execute-commands-sshd", "grant" => true},
127                       {"name" =>"org.opensuse.yast.systemtime.read-validtimezones", "grant" => true},
128                       {"name" =>"org.opensuse.yast.systemtime.read-isutc", "grant" => true},
129                       {"name" =>"org.opensuse.yast.scr.unmountagent", "grant" => false},
130                       {"name" =>"org.opensuse.yast.language.write-firstlanguage", "grant" => true},
131                       {"name" =>"org.opensuse.yast.module-manager.lock", "grant" => true},
132                       {"name" =>"org.opensuse.yast.modules.yapi.users.userdelete", "grant" => true},
133                       {"name" =>"org.opensuse.yast.services.read-config-ntp-userandomserverw", "grant" => true},
134                       {"name" =>"org.opensuse.yast.modules.yapi.language.setrootlang", "grant" => true},
135                       {"name" =>"org.opensuse.yast.modules.yapi.language.read", "grant" => true},
136                       {"name" =>"org.opensuse.yast.system.network.writelimits", "grant" => true},
137                       {"name" =>"org.opensuse.yast.systemtime.write-isutc", "grant" => true},
138                       {"name" =>"org.opensuse.yast.systemtime.write-currenttime", "grant" => true},
139                       {"name" =>"org.opensuse.yast.modules.yapi.users.userget", "grant" => true},
140                       {"name" =>"org.opensuse.yast.patch.read", "grant" => true},
141                       {"name" =>"org.opensuse.yast.services.execute-commands-cups", "grant" => true},
142                       {"name" =>"org.opensuse.yast.system.security.read", "grant" => true},
143                       {"name" =>"org.opensuse.yast.systemtime.read-currenttime", "grant" => true},
144                       {"name" =>"org.opensuse.yast.system.language.write", "grant" => true},
145                       {"name" =>"org.opensuse.yast.modules.yapi.language.getrootlang", "grant" => true},
146                       {"name" =>"org.opensuse.yast.systemtime.read-timezone", "grant" => true},
147                       {"name" =>"org.opensuse.yast.services.execute-commands-cron", "grant" => true},
148                       {"name" =>"org.opensuse.yast.services.read-config-ntp", "grant" => true},
149                       {"name" =>"org.opensuse.yast.services.write-config-ntp-userandomserverw", "grant" => true},
150                       {"name" =>"org.opensuse.yast.services.read-config", "grant" => true},
151                       {"name" =>"org.opensuse.yast.modules.yapi.users.usermodify", "grant" => true}]
152     permissions.to_xml(:root => "permissions")
153   end 
154
155   put '/permissions/:id.xml' do
156     permission = {"name" => "org.opensuse.yast.webservice.return-permissions", "grant" => true}
157     permission.to_xml(:root => "permission")
158   end