def test_find_by_uuid(self): from cis_identity_vault import vault from cis_identity_vault.models import user v = vault.RelationalIdentityVault() v.create() u = user.ProfileRDS() u.create(user_profile=self.user_profile) s = user.ProfileRDS() search_result = s.find_by_uuid(self.user_profile["uuid"]["value"]) assert search_result.profile["uuid"]["value"] == self.user_profile[ "uuid"]["value"]
def test_find_by_email(self): from cis_identity_vault import vault from cis_identity_vault.models import user v = vault.RelationalIdentityVault() v.create() u = user.ProfileRDS() self.user_profile["primary_email"]["value"] = "*****@*****.**" u.create(user_profile=self.user_profile) primary_email = self.user_profile["primary_email"]["value"] s = user.ProfileRDS() search_result = s.find_by_email(primary_email) assert len(search_result) > 0
def test_find_by_uuid(self): os.environ["CIS_POSTGRES_HOST"] = "db" os.environ["CIS_POSTGRES_PORT"] = "5432" os.environ["CIS_DB_USER"] = "******" os.environ["CIS_DB_PASSWORD"] = "******" from cis_identity_vault import vault from cis_identity_vault.models import user v = vault.RelationalIdentityVault() v.create() u = user.ProfileRDS() u.create(user_profile=self.user_profile) s = user.ProfileRDS() search_result = s.find_by_uuid(self.user_profile["uuid"]["value"]) assert search_result.profile["uuid"]["value"] == self.user_profile[ "uuid"]["value"]
def test_find_by_email(self): os.environ["CIS_POSTGRES_HOST"] = "db" os.environ["CIS_POSTGRES_PORT"] = "5432" os.environ["CIS_DB_USER"] = "******" os.environ["CIS_DB_PASSWORD"] = "******" from cis_identity_vault import vault from cis_identity_vault.models import user v = vault.RelationalIdentityVault() v.create() u = user.ProfileRDS() self.user_profile["primary_email"]["value"] = "*****@*****.**" u.create(user_profile=self.user_profile) primary_email = self.user_profile["primary_email"]["value"] s = user.ProfileRDS() search_result = s.find_by_email(primary_email) assert len(search_result) > 0
def to_postgres(self, profiles): rds_vault = user.ProfileRDS() results = [] for this_profile in profiles: results.append(rds_vault.find_or_create(this_profile)) logger.info( f"{len(results)} profiles have been written to the postgresql identity vault." ) return results
def test_user_delete(self): from cis_identity_vault import vault from cis_identity_vault.models import user v = vault.RelationalIdentityVault() v.create() u = user.ProfileRDS() u.create(user_profile=self.user_profile) u.delete(user_profile=self.user_profile) assert u.find(self.user_profile) is None
def test_user_update(self): from cis_identity_vault import vault from cis_identity_vault.models import user v = vault.RelationalIdentityVault() v.create() u = user.ProfileRDS() u.create(user_profile=self.user_profile) mutated_user_profile = self.user_profile mutated_user_profile["active"]["value"] = False u.update(user_profile=mutated_user_profile) u.delete(user_profile=self.user_profile)
def test_user_delete(self): os.environ["CIS_POSTGRES_HOST"] = "db" os.environ["CIS_POSTGRES_PORT"] = "5432" os.environ["CIS_DB_USER"] = "******" os.environ["CIS_DB_PASSWORD"] = "******" from cis_identity_vault import vault from cis_identity_vault.models import user v = vault.RelationalIdentityVault() v.create() u = user.ProfileRDS() u.create(user_profile=self.user_profile) u.delete(user_profile=self.user_profile) assert u.find(self.user_profile) is None
def test_user_find(self): from cis_identity_vault import vault from cis_identity_vault.models import user v = vault.RelationalIdentityVault() v.create() u = user.ProfileRDS() res = u.create(user_profile=self.user_profile) positive_search_result = u.find(self.user_profile) assert positive_search_result is not None non_existant_user = FakeUser().as_dict() negative_search_result = u.find(non_existant_user) assert negative_search_result is None u.delete(user_profile=self.user_profile) assert res is not None
def test_user_update(self): os.environ["CIS_POSTGRES_HOST"] = "db" os.environ["CIS_POSTGRES_PORT"] = "5432" os.environ["CIS_DB_USER"] = "******" os.environ["CIS_DB_PASSWORD"] = "******" from cis_identity_vault import vault from cis_identity_vault.models import user v = vault.RelationalIdentityVault() v.create() u = user.ProfileRDS() u.create(user_profile=self.user_profile) mutated_user_profile = self.user_profile mutated_user_profile["active"]["value"] = False u.update(user_profile=mutated_user_profile) u.delete(user_profile=self.user_profile)
def test_user_find(self): os.environ["CIS_POSTGRES_HOST"] = "db" os.environ["CIS_POSTGRES_PORT"] = "5432" os.environ["CIS_DB_USER"] = "******" os.environ["CIS_DB_PASSWORD"] = "******" from cis_identity_vault import vault from cis_identity_vault.models import user v = vault.RelationalIdentityVault() v.create() u = user.ProfileRDS() res = u.create(user_profile=self.user_profile) positive_search_result = u.find(self.user_profile) assert positive_search_result is not None non_existant_user = FakeUser().as_dict() negative_search_result = u.find(non_existant_user) assert negative_search_result is None u.delete(user_profile=self.user_profile) assert res is not None v.delete()