Exemple #1
0
 def test_request_passes_correct_data_to_template(self):
     admin = User.objects.create_superuser("admin", "*****@*****.**", "sekrit")
     tech = User.objects.create_user("tech", "*****@*****.**", "password")
     tech.save()
     tech_test_computer = Computer(serial="TECHSERIAL",
                                   username="******",
                                   computername="compy587")
     tech_test_computer.save()
     test_secret = Secret(
         computer=tech_test_computer,
         secret="SHHH-DONT-TELL",
         date_escrowed=datetime.now(),
     )
     test_secret.save()
     secret_request = Request(secret=test_secret, requesting_user=tech)
     secret_request.save()
     client = Client()
     login_response = self.client.post("/login/", {
         "username": "******",
         "password": "******"
     },
                                       follow=True)
     response = self.client.get("/manage-requests/", follow=True)
     print(response)
     self.assertTrue(response.context["user"].is_authenticated)
Exemple #2
0
 def test_request_passes_correct_data_to_template(self):
     admin = User.objects.create_superuser('admin', '*****@*****.**', 'sekrit')
     tech = User.objects.create_user('tech', '*****@*****.**', 'password')
     tech.save()
     tech_test_computer = Computer(serial = 'TECHSERIAL', username = '******',
                                   computername ='compy587')
     tech_test_computer.save()
     test_secret = Secret(computer = tech_test_computer, secret = 'SHHH-DONT-TELL',
                     date_escrowed = datetime.now())
     test_secret.save()
     secret_request = Request(secret = test_secret, requesting_user = tech)
     secret_request.save()
     client = Client()
     login_response = self.client.post('/login/', {'username': '******', 'password': '******'}, follow=True)
     response = self.client.get('/manage-requests/', follow=True)
     print response
     self.assertTrue(response.context['user'].is_authenticated)
Exemple #3
0
 def test_request_passes_correct_data_to_template(self):
     admin = User.objects.create_superuser('admin', '*****@*****.**', 'sekrit')
     tech = User.objects.create_user('tech', '*****@*****.**', 'password')
     tech.save()
     tech_test_computer = Computer(serial='TECHSERIAL',
                                   username='******',
                                   computername='compy587')
     tech_test_computer.save()
     test_secret = Secret(computer=tech_test_computer,
                          secret='SHHH-DONT-TELL',
                          date_escrowed=datetime.now())
     test_secret.save()
     secret_request = Request(secret=test_secret, requesting_user=tech)
     secret_request.save()
     client = Client()
     login_response = self.client.post('/login/', {
         'username': '******',
         'password': '******'
     },
                                       follow=True)
     response = self.client.get('/manage-requests/', follow=True)
     print response
     self.assertTrue(response.context['user'].is_authenticated)
Exemple #4
0
 def test_request_passes_correct_data_to_template(self):
     admin = User.objects.create_superuser("admin", "*****@*****.**", "sekrit")
     tech = User.objects.create_user("tech", "*****@*****.**", "password")
     tech.save()
     tech_test_computer = Computer(
         serial="TECHSERIAL", username="******", computername="compy587"
     )
     tech_test_computer.save()
     test_secret = Secret(
         computer=tech_test_computer,
         secret="SHHH-DONT-TELL",
         date_escrowed=datetime.now(),
     )
     test_secret.save()
     secret_request = Request(secret=test_secret, requesting_user=tech)
     secret_request.save()
     client = Client()
     login_response = self.client.post(
         "/login/", {"username": "******", "password": "******"}, follow=True
     )
     response = self.client.get("/manage-requests/", follow=True)
     print(response)
     self.assertTrue(response.context["user"].is_authenticated)
Exemple #5
0
 def setUp(self):
     self.browser = webdriver.Firefox()
     User.objects.create_superuser('admin', '*****@*****.**', 'sekrit')
     User.objects._create_user('tech', '*****@*****.**', 'password', is_staff=True, is_superuser=False)
     tech_test_computer = Computer(serial = 'TECHSERIAL')
     tech_test_computer.username = '******'
     tech_test_computer.computername ='compy587'
     tech_test_computer.save()
     secret = Secret(computer = tech_test_computer, secret = 'SHHH-DONT-TELL', date_escrowed = datetime.now())
     secret.save()
Exemple #6
0
 def setUp(self):
     self.browser = webdriver.Firefox()
     User.objects.create_superuser("admin", "*****@*****.**", "sekrit")
     User.objects._create_user(
         "tech", "*****@*****.**", "password", is_staff=True, is_superuser=False
     )
     tech_test_computer = Computer(serial="TECHSERIAL")
     tech_test_computer.username = "******"
     tech_test_computer.computername = "compy587"
     tech_test_computer.save()
     secret = Secret(
         computer=tech_test_computer,
         secret="SHHH-DONT-TELL",
         date_escrowed=datetime.now(),
     )
     secret.save()
def check_in(request):
    if not request.method == 'POST':
        return HttpResponse('away, hacker!')
    clientId = request.POST.get('clientId')
	
    if not clientId:
        name = request.POST.get('name')
        if not name:
            return HttpResponse('0')
        computer = Computer()
        computer.name = name
        computer.lastConnection = datetime.now(utc)
        computer.key = request.POST.get('key')
        computer.save()
        return HttpResponse(computer.pk, mimetype='text/plain')
		
    clientPws = request.POST.get('key')
    
    computer = get_object_or_404(Computer, pk=clientId)
    #authenticate the client
    if clientPws != computer.key:
        return HttpResponse('nope', mimetype='text/plain')
	
    computer.lastConnection = datetime.now(utc)
    computer.connected = True
    status = computer.status
    if computer.status != 'ok':
        computer.status = 'ok'
    computer.save()
    return HttpResponse(status + "~" + SECRET_KEY, mimetype='text/plain')