Ejemplo n.º 1
0
        public static void UploadLibrarySet(this ICakeContext context, LibraryTargetArgs args)
        {
            DependencyConfig.Setup(args, context).GetAwaiter().GetResult();
            var cmd = DependencyConfig.Container.GetService <UploadLibraryCommand>();

            cmd.Execute().GetAwaiter().GetResult();
        }
 public UploadLibraryCommand(LibraryTargetArgs args, ISecretsMananger secretsMananger, ILibraryManager libraryMananger, VariableConverter variableConverter, ILogger logger, IFileSystem fileSystem)
 {
     _args            = args ?? throw new ArgumentNullException(nameof(args));
     _secretsMananger = secretsMananger ?? throw new ArgumentNullException(nameof(secretsMananger));
     _libraryManager  = libraryMananger ?? throw new ArgumentNullException(nameof(libraryMananger));
     _varConverter    = variableConverter ?? throw new ArgumentNullException(nameof(variableConverter));
     _logger          = logger ?? throw new ArgumentNullException(nameof(logger));
     _fileSystem      = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem));
 }
Ejemplo n.º 3
0
            public async Task SecretsAreReplaced(string json, [Frozen] Mock <ISecretsMananger> mockSecret, [Frozen] MockFileSystem mockFileSystem,
                                                 [Frozen] LibraryTargetArgs args, UploadLibraryCommand sut)
            {
                args.VaultRoleId   = "RoleId";
                args.VaultSecretId = "SecretId";
                args.VaultUri      = "Uri";
                mockFileSystem.AddFile(args.File, new MockFileData(json));
                await sut.Execute().ConfigureAwait(false);

                mockSecret.Verify(m => m.ReplaceSecrets(It.Is <List <SecretVariable> >(l => l.Count == 1), args), Times.Once);
            }
Ejemplo n.º 4
0
            public async Task CommandArgsArePassed(string json, [Frozen] Mock <ILibraryManager> mockLibraryManager,
                                                   [Frozen] MockFileSystem mockFileSystem, [Frozen] LibraryTargetArgs args, UploadLibraryCommand sut)
            {
                mockFileSystem.AddFile(args.File, new MockFileData(json));
                await sut.Execute().ConfigureAwait(false);

                mockLibraryManager.Verify(m => m.UpdateVars(It.IsAny <List <SecretVariable> >(), args.Library, args.Environments, args.OctoRoles, true), Times.Once);
            }
Ejemplo n.º 5
0
            public async Task ApplyIsSetToTrue(string json, [Frozen] Mock <ILibraryManager> mockLibraryManager,
                                               [Frozen] MockFileSystem mockFileSystem, [Frozen] LibraryTargetArgs args, UploadLibraryCommand sut)
            {
                mockFileSystem.AddFile(args.File, new MockFileData(json));
                await sut.Execute().ConfigureAwait(false);

                mockLibraryManager.Verify(m => m.UpdateVars(It.IsAny <List <SecretVariable> >(), It.IsAny <string>(), It.IsAny <IEnumerable <string> >(), It.IsAny <IEnumerable <string> >(), true), Times.Once);
            }
        public async Task LibraryTargetArgsAddedAndThrows(Mock <IServiceCollection> mockColl, LibraryTargetArgs args)
        {
            Func <Task> sut = () => DependencyConfig.Setup(args, null, mockColl.Object, false);
            await sut.Should().ThrowAsync <ArgumentException>().ConfigureAwait(false);

            mockColl.Verify(m => m.Add(It.Is <ServiceDescriptor>(s => s.ServiceType == typeof(LibraryTargetArgs))), Times.Once);
            mockColl.Verify(m => m.Add(It.Is <ServiceDescriptor>(s => s.ServiceType == typeof(ArgsBase))), Times.Once);
        }