def setUp(self): super(TrafficEmulatorPacketTests, self).setUp() self.server = os.environ["SERVER"] self.domain = os.environ["DOMAIN"] self.host = os.environ["SERVER_IP"] self.lp = self.get_loadparm() self.session = system_session() self.credentials = self.get_credentials() self.ldb = SamDB(url="ldap://%s" % self.host, session_info=self.session, credentials=self.credentials, lp=self.lp) self.domain_sid = self.ldb.get_domain_sid() traffic.clean_up_accounts(self.ldb, 1) self.tempdir = tempfile.mkdtemp(prefix="traffic_packet_test_") self.context = traffic.ReplayContext(server=self.server, lp=self.lp, creds=self.credentials, tempdir=self.tempdir, ou=traffic.ou_name(self.ldb, 1), domain_sid=self.domain_sid) self.conversation = traffic.Conversation() self.conversation.conversation_id = 1 self.machinename = "STGM-1-1" self.machinepass = samba.generate_random_password(32, 32) self.username = "******" self.userpass = samba.generate_random_password(32, 32) account = traffic.ConversationAccounts( self.machinename, self.machinepass, self.username, self.userpass) traffic.create_ou(self.ldb, 1) traffic.create_machine_account(self.ldb, 1, self.machinename, self.machinepass) traffic.create_user_account(self.ldb, 1, self.username, self.userpass) self.context.generate_process_local_config(account, self.conversation) # grant user write permission to do things like write account SPN sdutils = sd_utils.SDUtils(self.ldb) mod = "(A;;WP;;;PS)" sdutils.dacl_add_ace(self.context.user_dn, mod)
def tearDown(self): super(TrafficEmulatorPacketTests, self).tearDown() traffic.clean_up_accounts(self.ldb, 1) del self.ldb shutil.rmtree(self.tempdir)