~mvo/ubuntu-sso-client/strawman-lp711413

« back to all changes in this revision

Viewing changes to ubuntu/sso/tests/test_key_acls.py

  • Committer: natalia.bidart at canonical
  • Date: 2010-06-09 18:23:27 UTC
  • mfrom: (533.1.4 rename)
  • Revision ID: natalia.bidart@canonical.com-20100609182327-kmd0rjjb1f0eojhu
Renaming modules and Dbus service to make them more generic.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# test_key_acls - tests for ubuntuone.oauthdesktop.key_acls
 
1
# test_key_acls - tests for ubuntu.sso.key_acls
2
2
#
3
3
# Author: Stuart Langridge <stuart.langridge@canonical.com>
4
4
#
20
20
import os, StringIO
21
21
import xdg.BaseDirectory
22
22
from mocker import MockerTestCase, IN, ANY
23
 
from ubuntuone.oauthdesktop.key_acls import (
 
23
from ubuntu.sso.key_acls import (
24
24
  get_privileged_config_folder, get_acl_preregistrations, set_all_key_acls,
25
25
  set_single_acl)
26
26
 
35
35
        osp.exists(ETC_FOLDER)
36
36
        self.mocker.result(True)
37
37
        self.mocker.replay()
38
 
        
 
38
 
39
39
        self.assertEqual(ETC_FOLDER,
40
40
          get_privileged_config_folder(use_source_tree_folder=False))
41
41
 
43
43
        """Is the /etc/xdg folder found even if the $HOME folder is present?"""
44
44
        
45
45
        ETC_FOLDER = "/etc/xdg/ubuntuone"
46
 
        HOME_FOLDER = os.path.join(xdg.BaseDirectory.xdg_config_home, 
 
46
        HOME_FOLDER = os.path.join(xdg.BaseDirectory.xdg_config_home,
47
47
          "ubuntuone")
48
48
        osp = self.mocker.replace("os.path")
49
49
        osp.exists(ETC_FOLDER)
51
51
        osp.exists(HOME_FOLDER)
52
52
        self.mocker.result(True)
53
53
        self.mocker.replay()
54
 
        
 
54
 
55
55
        self.assertEqual(ETC_FOLDER,
56
56
          get_privileged_config_folder(use_source_tree_folder=False))
57
57
 
69
69
        listdir(ETC_FILES_FOLDER)
70
70
        self.mocker.result(FILE_LIST)
71
71
        self.mocker.replay()
72
 
        
 
72
 
73
73
        our_list = sorted(
74
74
          [os.path.join(ETC_FILES_FOLDER, x) for x in FILE_LIST])
75
75
        their_list = sorted(
76
76
          get_acl_preregistrations(use_source_tree_folder=False))
77
77
        self.assertEqual(our_list, their_list)
78
 
        
 
78
 
79
79
    def test_set_single_acl(self):
80
80
        """Does set_single_acl work?"""
81
81
 
82
 
        giifr = self.mocker.replace(
83
 
          "ubuntuone.oauthdesktop.key_acls.get_item_ids_for_realm")
 
82
        giifr = self.mocker.replace("ubuntu.sso.key_acls.get_item_ids_for_realm")
84
83
        igas = self.mocker.replace("gnomekeyring.item_get_acl_sync")
85
84
        isas = self.mocker.replace("gnomekeyring.item_set_acl_sync")
86
85
        acon = self.mocker.replace("gnomekeyring.AccessControl")
104
103
          ("realm", "consumer_key", "/tmp/exe_path", "application_name"),
105
104
          ("realm2", "consumer_key2", "/tmp/exe_path2", "application_name2"),
106
105
        ])
107
 
        
108
 
        
 
106
 
109
107
    def test_etc_files_parsed(self):
110
108
        """Are files in /etc parsed correctly?"""
111
109
        
145
143
        self.mocker.result(sio1)
146
144
        mock_open(os.path.join(ETC_FILES_FOLDER, "b"))
147
145
        self.mocker.result(sio2)
148
 
        
149
 
        ssa = self.mocker.replace(
150
 
          "ubuntuone.oauthdesktop.key_acls.set_single_acl")
 
146
 
 
147
        ssa = self.mocker.replace("ubuntu.sso.key_acls.set_single_acl")
151
148
        # list may come up in any order
152
149
        ssa(IN([
153
150
              [
154
 
                ("https://realm.example.com/", "example_key", 
 
151
                ("https://realm.example.com/", "example_key",
155
152
                "/nowhere/executable/path", "example_app_name"),
156
 
                ("https://other.example.com/", "example_key", 
 
153
                ("https://other.example.com/", "example_key",
157
154
                "/nowhere/executable/path", "example_app_name"),
158
155
              ],
159
156
              [
160
 
                ("https://other.example.com/", "example_key", 
 
157
                ("https://other.example.com/", "example_key",
161
158
                "/nowhere/executable/path", "example_app_name"),
162
 
                ("https://realm.example.com/", "example_key", 
 
159
                ("https://realm.example.com/", "example_key",
163
160
                "/nowhere/executable/path", "example_app_name"),
164
161
              ],
165
162
            ]), specific_item_id=None
166
163
        )
167
164
        self.mocker.result(None)
168
165
        ssa([
169
 
            ("https://realm2.example.com/", "example_key2", 
 
166
            ("https://realm2.example.com/", "example_key2",
170
167
            "/nowhere/path/2", "example_app_name2")
171
168
            ], specific_item_id=None)
172
169
        self.mocker.result(None)
173
170
        self.mocker.replay()
174
 
        
 
171
 
175
172
        set_all_key_acls(use_source_tree_folder=False)
176
 
    
177
 
    
178
 
    
179
 
    
180
 
    
181