Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion glazier/lib/beyondcorp_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,35 @@ def tearDown(self):
@mock.patch.object(winpe, 'check_winpe', autospec=True)
def test_seed_path_sys(self, mock_check_winpe):
mock_check_winpe.return_value = False
self.assertEqual(self.beyondcorp._SeedPath(), constants.SYS_SEED_FILE)
# Compare with the constants module that beyondcorp reads, which can
# override SYS_SEED_FILE. WINPE_SEED_FILE is not overridden, so the
# WinPE test can use the constants imported here.
self.assertEqual(
self.beyondcorp._SeedPath(), beyondcorp.constants.SYS_SEED_FILE
)

@mock.patch.object(beyondcorp.BeyondCorp, '_WriteSeedFile', autospec=True)
@mock.patch.object(beyondcorp.BeyondCorp, '_GetDisk', autospec=True)
@mock.patch.object(beyondcorp.requests, 'post', autospec=True)
@mock.patch.object(winpe, 'check_winpe', autospec=True)
def test_get_signed_url_existing_sys_seed(
self, mock_check_winpe, mock_post, mock_getdisk, mock_write_seed_file
):
mock_check_winpe.return_value = False
self.patch_constant(beyondcorp.constants, 'SYS_SEED_FILE', self.seed_dst)
mock_getdisk.side_effect = beyondcorp.BeyondCorpDriveLetterError(
'No Removable Media was found.'
)
mock_post.return_value = _create_sign_response(200, 'Success', DECODED_HASH)
FLAGS.use_signed_url = True
FLAGS.sign_endpoint = 'https://sign-endpoint/sign'

sign = self.beyondcorp.GetSignedUrl('unstable/test.yaml')

self.assertEqual(sign, DECODED_HASH)
mock_post.assert_called_once_with(FLAGS.sign_endpoint, data=_TEST_SEED)
mock_getdisk.assert_not_called()
mock_write_seed_file.assert_not_called()

@mock.patch.object(winpe, 'check_winpe', autospec=True)
def test_seed_path_winpe(self, mock_check_winpe):
Expand Down
2 changes: 1 addition & 1 deletion glazier/lib/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
SYS_SYSTEM32, 'WindowsPowerShell', 'v1.0', 'powershell.exe'
)
SYS_GOOGETROOT = os.path.join(SYS_ROOT, os.sep, 'ProgramData', 'GooGet')
SYS_SEED_FILE = os.path.join(SYS_CACHE, os.sep, 'resources', 'seed.json')
SYS_SEED_FILE = os.path.join(SYS_CACHE, 'resources', 'seed.json')

# WinPE
WINPE_ROOT = 'X:'
Expand Down
Loading