def test_logout(self, mock_persist_creds, mock_read_cred_file): #setup mock_read_cred_file.return_value = json.dumps( [Test_Profile.token_entry1]) storage_mock = {'subscriptions': None} profile = Profile(storage_mock) consolidated = Profile._normalize_properties(self.user1, [self.subscription1], False, ENV_DEFAULT) profile._set_subscriptions(consolidated) self.assertEqual(1, len(storage_mock['subscriptions'])) #action profile.logout(self.user1) #verify self.assertEqual(0, len(storage_mock['subscriptions'])) self.assertEqual(mock_read_cred_file.call_count, 1) self.assertEqual(mock_persist_creds.call_count, 1)
def test_logout(self, mock_persist_creds, mock_read_cred_file): #setup mock_read_cred_file.return_value = json.dumps([Test_Profile.token_entry1]) storage_mock = {'subscriptions': None} profile = Profile(storage_mock) consolidated = Profile._normalize_properties(self.user1, [self.subscription1], False, ENV_DEFAULT) profile._set_subscriptions(consolidated) self.assertEqual(1, len(storage_mock['subscriptions'])) #action profile.logout(self.user1) #verify self.assertEqual(0, len(storage_mock['subscriptions'])) self.assertEqual(mock_read_cred_file.call_count, 1) self.assertEqual(mock_persist_creds.call_count, 1)
def logout(username=None): '''Log out from Azure subscription using Active Directory''' profile = Profile() if not username: username = profile.get_current_account_user() profile.logout(username)