1- using System ;
2- using System . Collections . Generic ;
3-
4- using Cake . Core ;
5- using Cake . Core . IO ;
6-
7- using FakeItEasy ;
1+ using System . Collections . Generic ;
82
93using FluentAssertions ;
104
@@ -16,24 +10,27 @@ namespace Cake.OctoVariapus.Tests
1610{
1711 public class CakeOctoVariapus_Tests
1812 {
13+ private const string OctopusUrl = "http://local.octopus.com" ;
14+
15+ private const string OctoProjectName = "Cake.OctoVariapus" ;
16+
17+ private const string OctoApiKey = "API-OW0PLJT3JLSZXFCRBE0EKQ7KU9I" ;
18+
1919 [ Fact ]
2020 public void import_with_handwritten_list_should_work ( )
2121 {
2222 //-----------------------------------------------------------------------------------------------------------
2323 // Arrange
2424 //-----------------------------------------------------------------------------------------------------------
2525 var octoVaribleImportAlias = new CakeOctoVariableImportAliasFixture ( 0 ) ;
26- const string octopusUrl = "http://local.octopus.com" ;
27- const string octoProjectName = "Cake.OctoVariapus" ;
28- const string octoApiKey = "API-FZNNNTXZK0NWFHLLMYJL4JGFIU" ;
2926
3027 //-----------------------------------------------------------------------------------------------------------
3128 // Act
3229 //-----------------------------------------------------------------------------------------------------------
3330 HttpMockRepository . At ( "http://localhost/api/variables/variableset-Projects-1" ) ;
34- octoVaribleImportAlias . CakeContext . OctoImportVariables ( octopusUrl ,
35- octoProjectName ,
36- octoApiKey ,
31+ octoVaribleImportAlias . CakeContext . OctoImportVariables ( OctopusUrl ,
32+ OctoProjectName ,
33+ OctoApiKey ,
3734 new List < OctoVariable >
3835 {
3936 new OctoVariable
@@ -48,11 +45,6 @@ public void import_with_handwritten_list_should_work()
4845 {
4946 Name = "Environment" ,
5047 Values = new List < string > { "Development" , "Stage" }
51- } ,
52- new OctoScope
53- {
54- Name = "Role" ,
55- Values = new List < string > { "Development" }
5648 }
5749 }
5850 }
@@ -65,60 +57,77 @@ public void import_with_handwritten_list_should_work()
6557 }
6658
6759 [ Fact ]
68- public void import_from_a_json_file_should_work ( )
60+ public void clear_nonsensitive_variables_should_work ( )
6961 {
7062 //-----------------------------------------------------------------------------------------------------------
7163 // Arrange
7264 //-----------------------------------------------------------------------------------------------------------
7365 var octoVaribleImportAlias = new CakeOctoVariableImportAliasFixture ( 0 ) ;
74- const string octopusUrl = "http://local.octopus.com" ;
75- const string octoProjectName = "Cake.OctoVariapus" ;
76- const string octoApiKey = "API-FZNNNTXZK0NWFHLLMYJL4JGFIU" ;
7766
7867 //-----------------------------------------------------------------------------------------------------------
7968 // Act
8069 //-----------------------------------------------------------------------------------------------------------
81-
82- octoVaribleImportAlias . CakeContext . OctoImportVariables ( octopusUrl ,
83- octoProjectName ,
84- octoApiKey ,
85- "variables.json" ) ;
70+ HttpMockRepository . At ( "http://localhost/api/variables/variableset-Projects-1" ) ;
71+ octoVaribleImportAlias . CakeContext . OctoImportVariables ( OctopusUrl ,
72+ OctoProjectName ,
73+ OctoApiKey ,
74+ new List < OctoVariable >
75+ {
76+ new OctoVariable
77+ {
78+ Name = "Username" ,
79+ IsSensitive = false ,
80+ IsEditable = true ,
81+ Value = "user" ,
82+ Scopes = new List < OctoScope >
83+ {
84+ new OctoScope
85+ {
86+ Name = "Environment" ,
87+ Values = new List < string > { "Development" , "Stage" }
88+ }
89+ }
90+ } ,
91+ new OctoVariable
92+ {
93+ Name = "Password" ,
94+ IsSensitive = true ,
95+ IsEditable = true ,
96+ Value = "123456" ,
97+ Scopes = new List < OctoScope >
98+ {
99+ new OctoScope
100+ {
101+ Name = "Environment" ,
102+ Values = new List < string > { "Development" , "Stage" }
103+ }
104+ }
105+ }
106+ } , true ) ;
86107
87108 //-----------------------------------------------------------------------------------------------------------
88109 // Assert
89110 //-----------------------------------------------------------------------------------------------------------
90111 octoVaribleImportAlias . GetCakeLog . Messages . Count . Should ( ) . BeGreaterThan ( 0 ) ;
91112 }
92113
93- private class CakeOctoVariableImportAliasFixture
114+ [ Fact ]
115+ public void import_from_a_json_file_should_work ( )
94116 {
95- public CakeOctoVariableImportAliasFixture ( int exitCode )
96- {
97- GetDirectoryPath = Guid . NewGuid ( ) . ToString ( ) ;
98-
99- A . CallTo ( ( ) => CakeContext . ProcessRunner ) . Returns ( ProcessRunner ) ;
100- A . CallTo ( ( ) => CakeContext . FileSystem ) . Returns ( FileSystem ) ;
101- A . CallTo ( ( ) => CakeContext . Log ) . Returns ( GetCakeLog ) ;
102- A . CallTo ( ( ) => ProcessRunner . Start ( A < FilePath > . _ , A < ProcessSettings > . _ ) ) . Returns ( Process ) ;
103- A . CallTo ( ( ) => Process . GetExitCode ( ) ) . Returns ( exitCode ) ;
104- }
105-
106- public CakeOctoVariableImportAliasFixture ( )
107- : this ( 0 )
108- {
109- }
110-
111- public ICakeContext CakeContext { get ; } = A . Fake < ICakeContext > ( ) ;
112-
113- public IFileSystem FileSystem { get ; } = A . Fake < IFileSystem > ( ) ;
114-
115- public DirectoryPath GetDirectoryPath { get ; }
116-
117- public IProcess Process { get ; } = A . Fake < IProcess > ( ) ;
117+ //-----------------------------------------------------------------------------------------------------------
118+ // Arrange
119+ //-----------------------------------------------------------------------------------------------------------
120+ var octoVaribleImportAlias = new CakeOctoVariableImportAliasFixture ( 0 ) ;
118121
119- public IProcessRunner ProcessRunner { get ; } = A . Fake < IProcessRunner > ( ) ;
122+ //-----------------------------------------------------------------------------------------------------------
123+ // Act
124+ //-----------------------------------------------------------------------------------------------------------
125+ octoVaribleImportAlias . CakeContext . OctoImportVariables ( OctopusUrl , OctoProjectName , OctoApiKey , "variables.json" ) ;
120126
121- public CakeLogFixture GetCakeLog { get ; } = new CakeLogFixture ( ) ;
127+ //-----------------------------------------------------------------------------------------------------------
128+ // Assert
129+ //-----------------------------------------------------------------------------------------------------------
130+ octoVaribleImportAlias . GetCakeLog . Messages . Count . Should ( ) . BeGreaterThan ( 0 ) ;
122131 }
123132 }
124133}
0 commit comments