119
119
credentials_path = os.path.join(service_path, 'credentials')
120
120
self.assertTrue(os.path.isdir(credentials_path))
122
def test_dirs_created_are_changed_to_secure(self):
123
launchpadlib_dir = os.path.join(self.temp_dir, 'launchpadlib')
124
# Verify a newly created-by-hand directory is insecure
125
os.mkdir(launchpadlib_dir)
126
os.chmod(launchpadlib_dir, 0755)
127
self.assertTrue(os.path.isdir(launchpadlib_dir))
128
statinfo = os.stat(launchpadlib_dir)
129
mode = stat.S_IMODE(statinfo.st_mode)
130
self.assertNotEqual(mode, stat.S_IWRITE | stat.S_IREAD | stat.S_IEXEC)
131
launchpad = NoNetworkLaunchpad.login_with(
132
'not important', service_root='http://api.example.com/beta',
133
launchpadlib_dir=launchpadlib_dir)
134
# Verify the mode has been changed to 0700
135
statinfo = os.stat(launchpadlib_dir)
136
mode = stat.S_IMODE(statinfo.st_mode)
137
self.assertEqual(mode, stat.S_IWRITE | stat.S_IREAD | stat.S_IEXEC)
139
def test_dirs_created_are_secure(self):
140
launchpadlib_dir = os.path.join(self.temp_dir, 'launchpadlib')
141
launchpad = NoNetworkLaunchpad.login_with(
142
'not important', service_root='http://api.example.com/beta',
143
launchpadlib_dir=launchpadlib_dir)
144
self.assertTrue(os.path.isdir(launchpadlib_dir))
145
# Verify the mode is safe
146
statinfo = os.stat(launchpadlib_dir)
147
mode = stat.S_IMODE(statinfo.st_mode)
148
self.assertEqual(mode, stat.S_IWRITE | stat.S_IREAD | stat.S_IEXEC)
122
150
def test_no_credentials_calls_get_token_and_login(self):
123
151
# If no credentials are found, get_token_and_login() is called.
124
152
service_root = 'http://api.example.com/beta'