#! /usr/bin/python
#-*- coding: utf-8 -*-
#FileName: NotificationSimu.py
from BaseModule import BaseSimu
import urllib
import httplib
import base64
import json
import string
import ConfigParser
import multiprocessing
import uuid
import time
from datetime import datetime
import tmslog
import threading
import Queue
import sys
CFG_DATA = "test_cfg.txt"
DEVICES_DATA = "view_devices.txt"
SIMU_LOG = 'mdmi_simu_log.txt'
TEST_DATA = ConfigParser.ConfigParser()
TEST_DATA.read(CFG_DATA)
class NotificationSimu(BaseSimu):
def __init__(self, flag=0, acct_index=0, url_tab=()):
BaseSimu.__init__(self)
auth_list = []
auth = self._init_auth_str(self.username, self.password)
auth_list.append(auth)
auth = self._init_auth_str(self.username2, self.password)
auth_list.append(auth)
auth = self._init_auth_str(self.username3, self.password)
auth_list.append(auth)
auth = self._init_auth_str(self.username4, self.password)
auth_list.append(auth)
auth = self._init_auth_str(self.username, self.wrongpassword)
auth_list.append(auth)
self.auth_str_tab = tuple(auth_list)
self.install_url_tab = url_tab
pass
def _init_auth_str(self, username, password):
auth = base64.b64encode(username + ':' + password)
auth = ' '.join(['Basic', auth])
return auth
pass
def rest_removeprofile(self):
"""
this method is used for simulating air-watch call to remove device profile to REST Service
"""
params = {
"RequestID": "123456789abcdef",
"User": {
"Email": "xwang@websense.com"
},
"Device": {
"Udid": "4B6D5E40DFB22BD57EC4AF54DA1F297A3221388B"
}
}
ns_url = TEST_DATA.get("Notification Server", "REST_RemoveProfile")
response = self.execute_request('POST', ns_url, params, 0, 0)
print response
return response
def rest_removeprofile_406(self):
"""
this method is used for simulating air-watch call to remove device profile to REST Service
"""
params = {
"RequestID": "123456789abcdef",
"User": {
"Email": "xwang@websense.com"
},
"Device": {
"Udid": "4B6D5E40DFB22BD57EC4AF54DA1F297A3221388B"
}
}
ns_url = TEST_DATA.get("Notification Server", "REST_RemoveProfile")
response = self.execute_request('POST', ns_url, params, 1, 0)
print response
return response
def rest_removeprofile_401(self):
"""
this method is used for simulating air-watch call to remove device profile to REST Service
"""
params = {
"RequestID": "123456789abcdef",
"User": {
"Email": "xwang@websense.com"
},
"Device": {
"Udid": "4B6D5E40DFB22BD57EC4AF54DA1F297A3221388B"
}
}
ns_url = TEST_DATA.get("Notification Server", "REST_RemoveProfile")
response = self.execute_request('POST', ns_url, params, 0, 1)
print response
return response
def update_params(self, device, params, acct_index):
"""
this method is used to update the params payload with the device info.
"""
device = device.split()
print "%s - Account:%d " % (device, acct_index)
request_id = base64.b64encode(uuid.uuid4().get_bytes())
callback_url = "http://10.230.48.19:80/cgi-py/installvpn.py?requestid=%s" % request_id
params['RequestID']
#-*- coding: utf-8 -*-
#FileName: NotificationSimu.py
from BaseModule import BaseSimu
import urllib
import httplib
import base64
import json
import string
import ConfigParser
import multiprocessing
import uuid
import time
from datetime import datetime
import tmslog
import threading
import Queue
import sys
CFG_DATA = "test_cfg.txt"
DEVICES_DATA = "view_devices.txt"
SIMU_LOG = 'mdmi_simu_log.txt'
TEST_DATA = ConfigParser.ConfigParser()
TEST_DATA.read(CFG_DATA)
class NotificationSimu(BaseSimu):
def __init__(self, flag=0, acct_index=0, url_tab=()):
BaseSimu.__init__(self)
auth_list = []
auth = self._init_auth_str(self.username, self.password)
auth_list.append(auth)
auth = self._init_auth_str(self.username2, self.password)
auth_list.append(auth)
auth = self._init_auth_str(self.username3, self.password)
auth_list.append(auth)
auth = self._init_auth_str(self.username4, self.password)
auth_list.append(auth)
auth = self._init_auth_str(self.username, self.wrongpassword)
auth_list.append(auth)
self.auth_str_tab = tuple(auth_list)
self.install_url_tab = url_tab
pass
def _init_auth_str(self, username, password):
auth = base64.b64encode(username + ':' + password)
auth = ' '.join(['Basic', auth])
return auth
pass
def rest_removeprofile(self):
"""
this method is used for simulating air-watch call to remove device profile to REST Service
"""
params = {
"RequestID": "123456789abcdef",
"User": {
"Email": "xwang@websense.com"
},
"Device": {
"Udid": "4B6D5E40DFB22BD57EC4AF54DA1F297A3221388B"
}
}
ns_url = TEST_DATA.get("Notification Server", "REST_RemoveProfile")
response = self.execute_request('POST', ns_url, params, 0, 0)
print response
return response
def rest_removeprofile_406(self):
"""
this method is used for simulating air-watch call to remove device profile to REST Service
"""
params = {
"RequestID": "123456789abcdef",
"User": {
"Email": "xwang@websense.com"
},
"Device": {
"Udid": "4B6D5E40DFB22BD57EC4AF54DA1F297A3221388B"
}
}
ns_url = TEST_DATA.get("Notification Server", "REST_RemoveProfile")
response = self.execute_request('POST', ns_url, params, 1, 0)
print response
return response
def rest_removeprofile_401(self):
"""
this method is used for simulating air-watch call to remove device profile to REST Service
"""
params = {
"RequestID": "123456789abcdef",
"User": {
"Email": "xwang@websense.com"
},
"Device": {
"Udid": "4B6D5E40DFB22BD57EC4AF54DA1F297A3221388B"
}
}
ns_url = TEST_DATA.get("Notification Server", "REST_RemoveProfile")
response = self.execute_request('POST', ns_url, params, 0, 1)
print response
return response
def update_params(self, device, params, acct_index):
"""
this method is used to update the params payload with the device info.
"""
device = device.split()
print "%s - Account:%d " % (device, acct_index)
request_id = base64.b64encode(uuid.uuid4().get_bytes())
callback_url = "http://10.230.48.19:80/cgi-py/installvpn.py?requestid=%s" % request_id
params['RequestID']