This repository was archived by the owner on Oct 9, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +19
-9
lines changed
Expand file tree Collapse file tree 2 files changed +19
-9
lines changed Original file line number Diff line number Diff line change @@ -136,24 +136,37 @@ class Args(object):
136136 self .assertNothingLogged (logs )
137137
138138 @log_capture ()
139- def test_sanitize_does_nothing_when_type_not_file (self , logs ):
139+ def test_sanitize_removes_sensitive_data_when_type_not_file (self , logs ):
140140 logging .disable (logging .NOTSET )
141141
142142 class Args (object ):
143+ exclude = []
143144 hide_file_names = ['.*' ]
144145 hide_project_names = []
145146 hide_branch_names = None
147+ include = []
146148 plugin = None
149+ include_only_with_project_file = None
150+ local_file = None
147151
148- branch = 'abc123'
149152 data = {
150- 'entity' : 'not.a.file' ,
153+ 'entity' : os . path . realpath ( 'tests/samples/codefiles/python.py' ) ,
151154 'type' : 'app' ,
152- 'branch' : branch ,
155+ 'project' : 'aproject' ,
156+ 'branch' : 'abranch' ,
153157 }
154- heartbeat = Heartbeat (data , Args (), None , _clone = True )
158+ heartbeat = Heartbeat (data , Args (), None )
155159 sanitized = heartbeat .sanitize ()
156- self .assertEquals (branch , sanitized .branch )
160+ self .assertEquals ('HIDDEN.py' , sanitized .entity )
161+ sensitive = [
162+ 'branch' ,
163+ 'dependencies' ,
164+ 'lines' ,
165+ 'lineno' ,
166+ 'cursorpos' ,
167+ ]
168+ for item in sensitive :
169+ self .assertIsNone (getattr (sanitized , item ))
157170
158171 self .assertNothingPrinted ()
159172 self .assertNothingLogged (logs )
Original file line number Diff line number Diff line change @@ -152,9 +152,6 @@ def sanitize(self):
152152 if self .entity is None :
153153 return self
154154
155- if self .type != 'file' :
156- return self
157-
158155 if self ._should_obfuscate_filename ():
159156 self ._sanitize_metadata (keys = self ._sensitive_when_hiding_filename )
160157 if self ._should_obfuscate_branch (default = True ):
You can’t perform that action at this time.
0 commit comments