Beispiel #1
0
        public async Task InitializeTestAsync()
        {
            await initializer.InitializeAsync();

            var project = new Project("Basic", Path.GetTempPath());

            // check thumbnail generated
            List <ObjectDetails> objects = await forgeOSS.GetBucketObjectsAsync(projectsBucketKey, project.OssAttributes.Thumbnail);

            Assert.Single(objects);
            string signedOssUrl = await forgeOSS.CreateSignedUrlAsync(projectsBucketKey, objects[0].ObjectKey);

            string testComparisonFilePath = await DownloadTestComparisonFile("http://testipt.s3-us-west-2.amazonaws.com/iLogicBasic1IamThumbnail.png", "iLogicBasic1IamThumbnail.png");

            await CompareOutputFileBytes(testComparisonFilePath, signedOssUrl);

            // check parameters generated with hashed name
            var ossNames = project.OssNameProvider("13B8EF6A8506CC3ECB08FF6F0B09ACD194DE6A55");

            objects = await forgeOSS.GetBucketObjectsAsync(projectsBucketKey, ossNames.Parameters);

            Assert.Single(objects);
            signedOssUrl = await forgeOSS.CreateSignedUrlAsync(projectsBucketKey, objects[0].ObjectKey);

            testComparisonFilePath = await DownloadTestComparisonFile("http://testipt.s3-us-west-2.amazonaws.com/iLogicBasic1IamDocumentParams.json", "iLogicBasic1IamDocumentParams.json");
            await CompareOutputFileBytes(testComparisonFilePath, signedOssUrl);

            // check model view generated with hashed name (zip of SVF size/content varies slightly each time so we can only check if it was created)
            objects = await forgeOSS.GetBucketObjectsAsync(projectsBucketKey, ossNames.ModelView);

            Assert.Single(objects);
        }
Beispiel #2
0
        public async Task <StatusCodeResult> DeleteProjects([FromBody] List <string> projectNameList)
        {
            if (!_userResolver.IsAuthenticated)
            {
                _logger.LogError("Attempt to delete projects for anonymous user");
                return(BadRequest());
            }

            var bucket = await _userResolver.GetBucketAsync(true);

            // collect all oss objects for all provided projects
            var tasks = new List <Task>();

            foreach (var projectName in projectNameList)
            {
                tasks.Add(bucket.DeleteObjectAsync(Project.ExactOssName(projectName)));

                foreach (var searchMask in ONC.ProjectFileMasks(projectName))
                {
                    var objects = await bucket.GetObjectsAsync(searchMask);

                    foreach (var objectDetail in objects)
                    {
                        tasks.Add(bucket.DeleteObjectAsync(objectDetail.ObjectKey));
                    }
                }
            }

            // delete the OSS objects
            await Task.WhenAll(tasks);

            for (var i = 0; i < tasks.Count; i++)
            {
                if (tasks[i].IsFaulted)
                {
                    _logger.LogError($"Failed to delete file #{i}");
                }
            }

            // delete local cache for all provided projects
            foreach (var projectName in projectNameList)
            {
                var projectStorage = await _userResolver.GetProjectStorageAsync(projectName, ensureDir : false);

                projectStorage.DeleteLocal();
            }

            return(NoContent());
        }