File tree 3 files changed +33
-6
lines changed
monkey_island/cc/environment
3 files changed +33
-6
lines changed Original file line number Diff line number Diff line change 4
4
5
5
MAJOR = "1"
6
6
MINOR = "8"
7
- PATCH = "0 "
7
+ PATCH = "1 "
8
8
build_file_path = Path (__file__ ).parent .joinpath ("BUILD" )
9
9
with open (build_file_path , "r" ) as build_file :
10
10
BUILD = build_file .read ()
Original file line number Diff line number Diff line change 1
1
from abc import ABCMeta , abstractmethod
2
2
from datetime import timedelta
3
3
import os
4
- from Crypto . Hash import SHA3_512
4
+ import hashlib
5
5
6
6
__author__ = 'itay.mizeretz'
7
7
@@ -45,10 +45,11 @@ def is_debug(self):
45
45
def get_auth_expiration_time (self ):
46
46
return self ._AUTH_EXPIRATION_TIME
47
47
48
- def hash_secret (self , secret ):
49
- h = SHA3_512 .new ()
50
- h .update (secret )
51
- return h .hexdigest ()
48
+ @staticmethod
49
+ def hash_secret (secret ):
50
+ hash_obj = hashlib .sha3_512 ()
51
+ hash_obj .update (secret .encode ('utf-8' ))
52
+ return hash_obj .hexdigest ()
52
53
53
54
def get_deployment (self ):
54
55
return self ._get_from_config ('deployment' , 'unknown' )
Original file line number Diff line number Diff line change
1
+ from monkey_island .cc .auth import User
2
+ from monkey_island .cc .testing .IslandTestCase import IslandTestCase
3
+ from monkey_island .cc .environment .aws import AwsEnvironment
4
+
5
+ import hashlib
6
+
7
+
8
+ class TestAwsEnvironment (IslandTestCase ):
9
+ def test_get_auth_users (self ):
10
+ env = AwsEnvironment ()
11
+ # This is "injecting" the instance id to the env. This is the UTs aren't always executed on the same AWS machine
12
+ # (might not be an AWS machine at all). Perhaps it would have been more elegant to create a Mock, but not worth it for
13
+ # this small test.
14
+ env ._instance_id = "i-666"
15
+ hash_obj = hashlib .sha3_512 ()
16
+ hash_obj .update (b"i-666" )
17
+ auth_users = env .get_auth_users ()
18
+ assert isinstance (auth_users , list )
19
+ assert len (auth_users ) == 1
20
+ auth_user = auth_users [0 ]
21
+ assert isinstance (auth_user , User )
22
+ assert auth_user .id == 1
23
+ assert auth_user .username == "monkey"
24
+ assert auth_user .secret == hash_obj .hexdigest ()
25
+
26
+
You can’t perform that action at this time.
0 commit comments