def setUp(self): self.service1 = BaseService("MusterService", ["fileStorage"], FileTransferMode.active, FileTransferArchive.none) self.service2 = BaseService("BetonService", ["fileStorage"], FileTransferMode.active, FileTransferArchive.none) self.service3 = BaseService("FahrService", ["fileStorage"], FileTransferMode.active, FileTransferArchive.none) self.oauthservice1 = OAuth2Service.from_service( self.service1, "http://localhost:5000/oauth/authorize", "http://localhost:5000/oauth/refresh", "ABC", "XYZ", ) self.oauthservice2 = OAuth2Service.from_service( self.service2, "http://localhost:5001/oauth/authorize", "http://localhost:5001/oauth/refresh", "DEF", "UVW", ) self.oauthservice3 = OAuth2Service.from_service( self.service3, "http://localhost:5001/api/authorize", "http://localhost:5001/api/refresh", "GHI", "MNO", )
def setUp(self): self.service1 = LoginService("MusterService", ["fileStorage"]) self.service2 = LoginService("BetonService", ["fileStorage"]) self.oauthservice1 = OAuth2Service.from_service( self.service1, "http://localhost:5000/oauth/authorize", "http://localhost:5000/oauth/refresh", "ABC", "XYZ", ) self.oauthservice2 = OAuth2Service.from_service( self.service2, "http://localhost:5000/oauth/authorize", "http://localhost:5000/oauth/refresh", "DEF", "MNO", ) self.user1 = User("Max Mustermann") self.user2 = User("Mimi Mimikri") self.token1 = Token(self.user1, self.service1, "ABC") self.token2 = Token(self.user1, self.service2, "DEF") self.oauthtoken1 = OAuth2Token(self.user1, self.oauthservice1, "ABC", "XYZ") self.oauthtoken2 = OAuth2Token(self.user1, self.oauthservice2, "DEF", "UVW")
def test_compare_service(self): s1 = BaseService("MusterService", ["fileStorage"], FileTransferMode.active, FileTransferArchive.none) s2 = BaseService("MusterService", ["metadata"], FileTransferMode.passive, FileTransferArchive.zip) s3 = BaseService("FahrService", ["fileStorage"], FileTransferMode.active, FileTransferArchive.none) os1 = OAuth2Service.from_service( s1, "http://localhost:5000/oauth/authorize", "http://localhost:5000/oauth/refresh", "ABC", "XYZ", ) os2 = OAuth2Service.from_service( s2, "http://localhost:5000/oauth/authorize", "http://localhost:5000/oauth/refresh", "ABC", "XYZ", ) os3 = OAuth2Service.from_service( s3, "http://localhost123:5000/oauth/authorize", "http://localhost123:5000/oauth/refresh", "WER", "DA", ) os4 = OAuth2Service.from_service( s1, "http://localhost:5000/oauth/authorize", "http://localhost:5000/oauth/refresh", "QWE", "RTZ", ) self.assertEqual(s1, s2) self.assertNotEqual(s1, s3) self.assertFalse(s1 is s2) self.assertEqual(os1, os2) self.assertEqual(os1, os4) self.assertNotEqual(os1, os3) self.assertEqual(s1, os1)
def setUp(self): self.app = create_app() self.client = self.app.test_client() self.empty_storage = Storage() self.success = {"success": True} self.user1 = User("Max Mustermann") self.user2 = User("Mimi Mimikri") self.user3 = User("Karla Kolumda") self.service1 = LoginService(servicename="MusterService", implements=["metadata"]) self.service2 = LoginService(servicename="BetonService", implements=["metadata"]) self.service3 = LoginService(servicename="FahrService", implements=["metadata"]) self.oauthservice1 = OAuth2Service.from_service( self.service1, f"{pact_host_fqdn}/owncloud/index.php/apps/oauth2/authorize", f"{pact_host_fqdn}/owncloud/index.php/apps/oauth2/api/v1/token", "ABC", "XYZ", ) self.oauthservice2 = OAuth2Service.from_service( self.service2, f"{pact_host_fqdn}/oauth/authorize", f"{pact_host_fqdn}/oauth/token", "DEF", "UVW", ) self.oauthservice3 = OAuth2Service.from_service( self.service3, f"{pact_host_fqdn}/api/authorize", f"{pact_host_fqdn}/api/token", "GHI", "MNO", ) self.token1 = Token(self.user1, self.service1, "ABC") self.token_like_token1 = Token(self.user1, self.service1, "DEF") self.token2 = Token(self.user2, self.service2, "XYZ") self.token3 = Token(self.user1, self.service3, "GHI") self.oauthtoken1 = OAuth2Token(self.user1, self.oauthservice1, "ABC", "X_ABC") self.oauthtoken_like_token1 = OAuth2Token(self.user1, self.oauthservice1, "X_DEF") self.oauthtoken2 = OAuth2Token(self.user2, self.oauthservice2, "XYZ", "X_XYZ") self.oauthtoken3 = OAuth2Token(self.user1, self.oauthservice3, "GHI", "X_GHI") self.services = [ self.service1, self.service2, self.service3, self.oauthservice1, self.oauthservice2, self.oauthservice3, ] self.filled_storage_without_tokens = Storage() self.filled_storage_without_tokens.addUser(self.user1) self.filled_storage_without_tokens.addUser(self.user2) self.filled_storage_without_tokens.addUser(self.user3) self.filled_storage = Storage() self.filled_storage.addService(self.oauthservice1) self.filled_storage.addService(self.oauthservice2) self.filled_storage.addService(self.oauthservice3) # user1 is filled with mixed token and oauth2token self.filled_storage.addUser(self.user1) self.filled_storage.addTokenToUser(self.token1, self.user1) self.filled_storage.addTokenToUser(self.token3, self.user1) self.filled_storage.addTokenToUser(self.oauthtoken1, self.user1, Force=True) # user2 is only filled with token self.filled_storage.addUser(self.user2) self.filled_storage.addTokenToUser(self.token2, self.user2)