Exemple #1
0
        private void SetupApplicationsGroupsAndUsers(Permission permission)
        {
            // add permissions
            int groupId = 12;

            GroupStorageView[] groups = new GroupStorageView[1];

            groups[0] = new GroupStorageView(groupId, "test1");

            UserStorageView[] users = new UserStorageView[1];

            users[0] = new UserStorageView("username1", "password1", groupId);

            _managerStorage.AddGroups(groups);

            _managerStorage.AddUsers(users);

            _managerStorage.AddGroupPermission(groupId, permission);

            SecurityCredentials sc = new SecurityCredentials("username1", HashUtil.GetHash("password1", HashType.MD5));

            // add applications, only one assigned to this user

            _managerStorage.AddApplication(new ApplicationStorageView("username1"));
            _managerStorage.AddApplication(new ApplicationStorageView("username2"));
            _managerStorage.AddApplication(new ApplicationStorageView("username3"));
        }
        /// <summary>
        /// Add all kinds of objects to the storage so the maintenance functions have something to play with.
        /// </summary>
        private void PrepareComplexStorageForMaintenanceTests()
        {
            DateTime pingTime = DateTime.Now;

            _managerStorage.AddExecutor(new ExecutorStorageView(true, true, pingTime.AddDays(-1), "hostname", 1, "username", 1, 2, 3, 4));
            _managerStorage.AddExecutor(new ExecutorStorageView(false, true, pingTime.AddDays(2), "hostname", 1, "username", 1, 2, 3, 4));
            _managerStorage.AddExecutor(new ExecutorStorageView(true, false, pingTime.AddDays(1), "hostname", 1, "username", 1, 2, 3, 4));
            _managerStorage.AddExecutor(new ExecutorStorageView(false, false, pingTime.AddDays(-2), "hostname", 1, "username", 1, 2, 3, 4));

            DateTime timeCreated = DateTime.Now;

            ApplicationStorageView application1;
            ApplicationStorageView application2;
            ApplicationStorageView application3;
            ApplicationStorageView application4;
            ApplicationStorageView application5;

            application1 = new ApplicationStorageView(ApplicationState.AwaitingManifest, timeCreated.AddDays(-5), false, "username1");
            application2 = new ApplicationStorageView(ApplicationState.Stopped, timeCreated.AddDays(-4), false, "username1");
            application3 = new ApplicationStorageView(ApplicationState.Ready, timeCreated.AddDays(1), false, "username1");
            application4 = new ApplicationStorageView(ApplicationState.AwaitingManifest, timeCreated.AddDays(-3), false, "username1");
            application5 = new ApplicationStorageView(ApplicationState.Stopped, timeCreated.AddDays(2), false, "username1");

            // leave time completed not set for application1 to test that scenario as well
            application2.TimeCompleted = DateTime.Now.AddDays(-4);
            application3.TimeCompleted = DateTime.Now.AddDays(2);
            application4.TimeCompleted = DateTime.Now.AddDays(-3);
            application5.TimeCompleted = DateTime.Now.AddDays(3);

            _managerStorage.AddApplication(application1);
            _managerStorage.AddApplication(application2);
            _managerStorage.AddApplication(application3);
            _managerStorage.AddApplication(application4);
            _managerStorage.AddApplication(application5);
        }