Ejemplo n.º 1
0
 def test_validate(self):
     issuer = SetupPersonPortfolio().perform(PersonData(**Generate.person_data()[0]))
     foreign_issuer = issuer.to_portfolio()
     owner = SetupPersonPortfolio().perform(PersonData(**Generate.person_data()[0]))
     statement = CreateVerifiedStatement().perform(issuer, owner)
     with evaluate("Verified:Validate") as report:
         ValidateVerifiedStatement().validate(foreign_issuer, statement)
         self.assertNotIn(statement, foreign_issuer.verified_issuer)
     self.assertTrue(report)
Ejemplo n.º 2
0
 def test_perform(self):
     issuer = SetupPersonPortfolio().perform(
         PersonData(**Generate.person_data()[0]))
     owner = SetupPersonPortfolio().perform(
         PersonData(**Generate.person_data()[0]))
     with evaluate("Verified:Create") as report:
         verified = CreateVerifiedStatement().perform(issuer, owner)
         self.assertIn(verified, issuer.verified_issuer)
     self.assertTrue(report)
 def test_validate(self):
     issuer = SetupPersonPortfolio().perform(
         PersonData(**Generate.person_data()[0]))
     foreign_issuer = issuer.to_portfolio()
     owner = SetupPersonPortfolio().perform(
         PersonData(**Generate.person_data()[0]))
     statement = CreateVerifiedStatement().perform(issuer, owner)
     revoked = CreateRevokedStatement().perform(issuer, statement)
     with evaluate("Revoked:Accept") as report:
         AcceptRevokedStatement().validate(foreign_issuer, revoked)
         self.assertIn(revoked, foreign_issuer.revoked_issuer)
     self.assertTrue(report)
Ejemplo n.º 4
0
 def setUp(self) -> None:
     self.secret = os.urandom(32)
     self.dir = TemporaryDirectory()
     self.home = Path(self.dir.name)
     self.facade = Facade(self.home, self.secret,
         SetupPersonPortfolio().perform(PersonData(**Generate.church_data()[0])),
         role=Const.A_ROLE_PRIMARY, server=False
     )
Ejemplo n.º 5
0
    def test_perform(self):
        issuer = SetupPersonPortfolio().perform(
            PersonData(**Generate.person_data()[0]))
        owner = SetupPersonPortfolio().perform(
            PersonData(**Generate.person_data()[0]))

        foreign_issuer = issuer.to_portfolio()
        verified = CreateVerifiedStatement().perform(issuer, owner)
        AcceptVerifiedStatement().validate(foreign_issuer, verified)
        self.assertIn(verified, foreign_issuer.verified_issuer)

        revoked = CreateRevokedStatement().perform(issuer, verified)
        AcceptRevokedStatement().validate(foreign_issuer, revoked)
        self.assertIn(revoked, foreign_issuer.revoked_issuer)

        with evaluate("Revoked:Remove") as report:
            RemoveRevokedStatement().perform(foreign_issuer, revoked)
            self.assertIn(revoked, foreign_issuer.revoked_issuer)
            self.assertNotIn(verified, foreign_issuer.verified_issuer)
        self.assertTrue(report)
Ejemplo n.º 6
0
    async def create(cls, home_dir: Path, secret: bytes, data: BaseData) -> TypeFacadeMixin:
        """Implement facade generation logic here."""
        if isinstance(data, PersonData):
            portfolio = SetupPersonPortfolio.perform(data, server=cls.STUB_SERVER)
        elif isinstance(data, MinistryData):
            portfolio = SetupMinistryPortfolio.perform(data, server=cls.STUB_SERVER)
        elif isinstance(data, ChurchData):
            portfolio = SetupChurchPortfolio.perform(data, server=cls.STUB_SERVER)
        else:
            raise TypeError()

        return Facade(home_dir, secret, Const.A_ROLE_PRIMARY, cls.STUB_SERVER, portfolio=portfolio)
Ejemplo n.º 7
0
    async def test_facade(self):
        facade = Facade(self.home,
                        self.secret,
                        SetupPersonPortfolio().perform(
                            PersonData(**Generate.person_data()[0])),
                        role=Const.A_ROLE_PRIMARY,
                        server=True)
        self.services_server(facade)
        self.assertIsInstance(facade, PersonServerFacade)
        self.assertIsInstance(facade.data.portfolio.entity, Person)
        self.assertIsInstance(facade.data.portfolio.node, Node)
        self.extension_type(facade)
        facade.close()

        facade = Facade(self.home, self.secret)
        self.assertIsInstance(facade.data.portfolio.entity, Person)
        self.assertIsInstance(facade.data.portfolio.node, Node)
        self.extension_type(facade)
        facade.close()
Ejemplo n.º 8
0
 async def create_client(cls) -> "ApplicationContext":
     """Create a stub client."""
     return await cls._setup(
         StubClient, SetupPersonPortfolio().perform(
             PersonData(**Generate.person_data()[0]), server=StubClient.STUB_SERVER))
 def test_validate(self):
     data = PersonData(**Generate.person_data()[0])
     portfolio = SetupPersonPortfolio().perform(data)
     with evaluate("Entity:Accpept") as report:
         AcceptEntity().validate(portfolio)
     self.assertTrue(report)
Ejemplo n.º 10
0
 def create_client(cls) -> "FacadeContext":
     """Create a stub client."""
     return cls(
         SetupPersonPortfolio().perform(
             PersonData(**Generate.person_data()[0]), server=False), False)
Ejemplo n.º 11
0
 def test_perform(self):
     data = PersonData(**Generate.person_data()[0])
     with evaluate("Person:Setup") as report:
         portfolio = SetupPersonPortfolio().perform(data)
     self.assertTrue(report)