Esempio n. 1
0
    def test_deleteAccount(self):
        userdata = USER.objects.get(username="******")
        user = User.User(userdata.permission, userdata.username,
                         userdata.password, userdata.id, userdata.email,
                         userdata.firstName, userdata.lastName,
                         userdata.contactPhone, userdata.officePhone,
                         userdata.extension)
        userdata2 = USER.objects.get(username="******")
        user2 = User.User(userdata2.permission, userdata2.username,
                          userdata2.password, userdata2.id, userdata2.email,
                          userdata2.firstName, userdata2.lastName,
                          userdata2.contactPhone, userdata2.officePhone,
                          userdata2.extension)
        userdata3 = USER.objects.get(username="******")
        user3 = User.User(userdata3.permission, userdata3.username,
                          userdata3.password, userdata3.id, userdata3.email,
                          userdata3.firstName, userdata3.lastName,
                          userdata3.contactPhone, userdata3.officePhone,
                          userdata3.extension)

        self.assertTrue(user.permission[1] == '1')
        self.assertTrue(user2.permission[1] == '2')
        self.assertTrue(user3.permission[1] != '1',
                        "Not Authorized To Use This Command")
        self.assertTrue(user2.permission == '2',
                        "Not Authorized To Use This Command")
        self.assertEqual(Terminal.deleteAccount('314351'), "User Not Found")
        self.assertEqual(Terminal.deleteAccount(user.databaseID),
                         "Account Deleted")
Esempio n. 2
0
    def post(self, request):
        terminalInstance = Terminal()
        user = USER.objects.get(id=request.session['userid'])
        terminalInstance.login(user.username, user.password)

        ret, success = terminalInstance.deleteAccount(
            request.POST['accountID'])

        if success is False:
            return render(request, 'shell/error.html', {"message": ret})

        return redirect('/commands/')