Пример #1
0
def test_system_2_0_0(role_assignment_for_system_scope):
    system = System(
        version="2.0.0", **role_assignment_for_system_scope.domain.identifiers
    ).save()

    yield system
    system.delete()
Пример #2
0
def local_system(local_garden):
    system = System(name="somesystem",
                    version="1.0.0",
                    namespace=local_garden.name).save()

    yield system
    system.delete()
Пример #3
0
def remote_system(remote_garden):
    system = System(name="somesystem",
                    version="1.0.0",
                    namespace=remote_garden.name).save()

    yield system
    system.delete()
Пример #4
0
def system_not_permitted(garden):
    system = System(name="not_permitted",
                    version="1.0.0",
                    namespace=garden.name).save()

    yield system
    system.delete()
Пример #5
0
def system_not_permitted(garden):
    system = System(
        name="system_not_permitted",
        version="0.0.1",
        namespace=garden.name,
        commands=[Command(name="command_not_permitted")],
    ).save()

    yield system
    system.delete()
Пример #6
0
def system_permitted(garden):
    system = System(
        name="permitted_system",
        version="0.0.1",
        namespace=garden.name,
        commands=[Command(name="icandoit")],
    ).save()

    yield system
    system.delete()
Пример #7
0
def system():
    yield create_system(
        BrewtilsSystem(
            name="original",
            version="v0.0.1",
            namespace="beer_garden",
            commands=[BrewtilsCommand(name="original")],
        ))

    System.drop_collection()
Пример #8
0
def system(garden):
    instance = Instance(name="instance")
    system = System(
        name="system",
        version="1.0.0",
        namespace=garden.name,
        instances=[instance],
    ).save()

    yield system
    system.delete()
Пример #9
0
    def default_system(self, default_command, default_instance):
        default_system = System(
            id="1234",
            name="foo",
            version="1.0.0",
            namespace="ns",
            instances=[default_instance],
            commands=[default_command],
        )
        default_system.save = Mock()
        default_system.validate = Mock()
        default_system.delete = Mock()

        return default_system
Пример #10
0
def data_cleanup():
    """Cleanup all data between test modules to ensure each one is independent"""
    yield
    Event.drop_collection()
    File.drop_collection()
    Garden.drop_collection()
    Job.drop_collection()
    RawFile.drop_collection()
    Request.drop_collection()
    RemoteUser.drop_collection()
    Role.drop_collection()
    System.drop_collection()
    User.drop_collection()
    UserToken.drop_collection()
Пример #11
0
    def setUp(self):
        self.app = brew_view.app.test_client()

        self.default_instance = Instance(name="default", status="RUNNING")
        self.default_command = Command(id="54ac18f778c4b57e963f3c18",
                                       name="command",
                                       description="foo")
        self.default_system = System(
            id="54ac18f778c4b57e963f3c18",
            name="default_system",
            version="1.0.0",
            instances=[self.default_instance],
            commands=[self.default_command],
            max_instances="1",
        )
Пример #12
0
def ensure_v2_to_v3_model_migration():
    """Ensures that the Role model is flatten and Command model is an
    EmbeddedDocument

    In Version 2 and earlier the Role model allowed for nested roles. This caused
    recursive approach to determining Principal permissions. This is changed in
    Version 3 to allow for Roles to add complexity of Namespace restrictions which
    would not work properly with nesting.

    Right now if the check fails this will just drop the Roles and Principle
    collections. Since they'll be recreated anyway this isn't the worst, but
    it would be better if we could seamlessly flatten existing permissions.

    In version 2 and earlier the Command model was a top-level collection. This
    causes organization and performance issues, so in version 3 it was changed to be an
    embedded document of the System model. This ensures that's the case.

    Right now if the check fails this will just drop the Systems, Commands, and
    Instances collections. Since they'll be recreated anyway this isn't the worst, but
    it would be better if we could seamlessly move the existing commands into existing
    Systems.
    """
    from beer_garden.db.mongo.models import LegacyRole, System

    try:
        if LegacyRole.objects.count() > 0:
            _ = LegacyRole.objects()[0]
        if System.objects.count() > 0:
            _ = System.objects()[0]
    except (FieldDoesNotExist, InvalidDocumentError):
        logger.warning(
            "Encountered an error loading Roles or Systems. This is most likely because"
            " the database is using the old (v2) style of storing in the database. To"
            " fix this the roles, principles, systems, instances, and commands"
            " collections will be dropped.")

        db = get_db()
        db.drop_collection("principal")
        db.drop_collection("role")
        db.drop_collection("command")
        db.drop_collection("instance")
        db.drop_collection("system")
Пример #13
0
    def setUp(self):
        self.app = brew_view.app.test_client()

        self.default_instance = Instance(name="default", status="RUNNING")
        self.default_command = Command(id="54ac18f778c4b57e963f3c18",
                                       name="command",
                                       description="foo")
        self.default_system = System(
            id="54ac18f778c4b57e963f3c18",
            name="default_system",
            version="1.0.0",
            instances=[self.default_instance],
            commands=[self.default_command],
            max_instances="1",
        )

        self.client_mock = Mock(name="client_mock")
        self.fake_context = MagicMock(
            __enter__=Mock(return_value=self.client_mock),
            __exit__=Mock(return_value=False),
        )
Пример #14
0
 def child_system(self):
     return System(name="echoer", namespace="child_garden")
Пример #15
0
def setup_systems(app, mongo_system):
    System.drop_collection()
    mongo_system.deep_save()
Пример #16
0
def system_cleanup():
    yield
    System.drop_collection()
Пример #17
0
def drop():
    Garden.drop_collection()
    Role.drop_collection()
    System.drop_collection()
    User.drop_collection()
Пример #18
0
def drop():
    yield
    Garden.drop_collection()
    System.drop_collection()
Пример #19
0
def drop_systems(app):
    System.drop_collection()
Пример #20
0
 def drop(self, mongo_conn):
     System.drop_collection()