示例#1
0
    def test_deactivate_additional_users(self):
        update_limits({'users': get_total_users() + 1})

        if not frappe.db.exists(
                "User", "*****@*****.**"):
            user = frappe.new_doc('User')
            user.email = '*****@*****.**'
            user.first_name = 'Test Deactivate Additional Users'
            user.add_roles("System Manager")

        #update limits
        update_limits({"users": get_total_users() - 1})
        self.assertEqual(
            frappe.db.get_value(
                "User", "*****@*****.**",
                "enabled"), 0)

        if frappe.db.exists("User",
                            "*****@*****.**"):
            delete_contact('*****@*****.**')
            frappe.delete_doc('User',
                              '*****@*****.**')

        # Clear the user limit
        clear_limit('users')
示例#2
0
    def test_site_expiry(self):
        user = frappe.get_doc('User', '*****@*****.**')
        user.enabled = 1
        user.new_password = '******'
        user.save()

        update_limits({
            'expiry': add_to_date(today(), days=-1),
            'support_email': '*****@*****.**'
        })
        frappe.local.conf = _dict(frappe.get_site_config())

        frappe.db.commit()

        res = requests.post(get_url(),
                            params={
                                'cmd': 'login',
                                'usr': '******',
                                'pwd': 'Eastern_43A1W',
                                'device': 'desktop'
                            })

        # While site is expired status code returned is 417 Failed Expectation
        self.assertEqual(res.status_code, 417)

        clear_limit("expiry")
        frappe.local.conf = _dict(frappe.get_site_config())
示例#3
0
	def test_restrict_scheduler_events(self):
		frappe.set_user("Administrator")
		dormant_date = add_days(today(), -5)
		frappe.db.sql('update tabUser set last_active=%s', dormant_date)

		restrict_scheduler_events_if_dormant()
		frappe.local.conf = _dict(frappe.get_site_config())

		self.assertFalse("all" in get_enabled_scheduler_events())
		self.assertTrue(frappe.conf.get('dormant', False))

		clear_limit("expiry")
		frappe.local.conf = _dict(frappe.get_site_config())
	def test_site_expiry(self):
		update_limits({'expiry': add_to_date(today(), days=-1)})
		frappe.local.conf = _dict(frappe.get_site_config())

		frappe.db.commit()

		res = requests.post(get_url(), params={'cmd': 'login', 'usr': '******', 'pwd': 'testpassword',
			'device': 'desktop'})

		# While site is expired status code returned is 417 Failed Expectation
		self.assertEqual(res.status_code, 417)

		clear_limit("expiry")
		frappe.local.conf = _dict(frappe.get_site_config())
示例#5
0
    def test_site_expiry(self):
        update_limits({"expiry": add_to_date(today(), days=-1)})
        frappe.local.conf = _dict(frappe.get_site_config())

        frappe.db.commit()

        res = requests.post(
            get_url(), params={"cmd": "login", "usr": "******", "pwd": "testpassword", "device": "desktop"}
        )

        # While site is expired status code returned is 417 Failed Expectation
        self.assertEqual(res.status_code, 417)

        clear_limit("expiry")
        frappe.local.conf = _dict(frappe.get_site_config())
示例#6
0
	def test_restrict_scheduler_events(self):
		frappe.set_user("Administrator")
		user = frappe.get_doc("User", "Administrator")
		dormant_date = add_days(today(), -5)
		user.last_active = dormant_date
		user.save()

		restrict_scheduler_events_if_dormant()
		frappe.local.conf = _dict(frappe.get_site_config())

		self.assertFalse("all" in get_enabled_scheduler_events())
		self.assertTrue(frappe.conf.get('dormant', False))

		clear_limit("expiry")
		frappe.local.conf = _dict(frappe.get_site_config())
示例#7
0
    def test_user_limit_for_site_with_simultaneous_sessions(self):
        clear_limit('users')

        # make sure this user counts
        user = frappe.get_doc('User', '*****@*****.**')
        user.add_roles('Website Manager')
        user.save()

        update_limits({'users': get_total_users()})

        user.simultaneous_sessions = user.simultaneous_sessions + 1

        self.assertRaises(MaxUsersReachedError, user.save)

        # Clear the user limit
        clear_limit('users')
示例#8
0
	def test_user_limit_for_site_with_simultaneous_sessions(self):
		clear_limit('users')

		# make sure this user counts
		user = frappe.get_doc('User', '*****@*****.**')
		user.add_roles('Website Manager')
		user.save()

		update_limits({'users': get_total_users()})

		user.simultaneous_sessions = user.simultaneous_sessions + 1

		self.assertRaises(MaxUsersReachedError, user.save)

		# Clear the user limit
		clear_limit('users')
示例#9
0
	def test_deactivate_additional_users(self):
		update_limits({'users': get_total_users()+1})
		
		if not frappe.db.exists("User", "*****@*****.**"):
			user = frappe.new_doc('User')
			user.email = '*****@*****.**'
			user.first_name = 'Test Deactivate Additional Users'
			user.add_roles("System Manager")

		#update limits
		update_limits({"users": get_total_users()-1})
		self.assertEqual(frappe.db.get_value("User", "*****@*****.**", "enabled"), 0)
		
		if frappe.db.exists("User", "*****@*****.**"):
			frappe.delete_doc('User', '*****@*****.**')

		# Clear the user limit
		clear_limit('users')
	def test_user_limit_for_site(self):
		update_limits({'users': get_total_users()})

		# reload site config
		from frappe import _dict
		frappe.local.conf = _dict(frappe.get_site_config())

		# Create a new user
		user = frappe.new_doc('User')
		user.email = '*****@*****.**'
		user.first_name = 'Test_max_user'

		self.assertRaises(MaxUsersReachedError, user.add_roles, 'System Manager')

		if frappe.db.exists('User', '*****@*****.**'):
			frappe.delete_doc('User', '*****@*****.**')

		# Clear the user limit
		clear_limit('users')
示例#11
0
	def test_site_expiry(self):
		user = frappe.get_doc('User', '*****@*****.**')
		user.enabled = 1
		user.new_password = '******'
		user.save()

		update_limits({'expiry': add_to_date(today(), days=-1), 'support_email': '*****@*****.**'})
		frappe.local.conf = _dict(frappe.get_site_config())

		frappe.db.commit()

		res = requests.post(get_url(), params={'cmd': 'login', 'usr':
			'******', 'pwd': 'Eastern_43A1W', 'device': 'desktop'})

		# While site is expired status code returned is 417 Failed Expectation
		self.assertEqual(res.status_code, 417)

		clear_limit("expiry")
		frappe.local.conf = _dict(frappe.get_site_config())
示例#12
0
	def test_disable_scheduler_on_expiry(self):
		update_limits({'expiry': add_to_date(today(), days=-1)})
		frappe.local.conf = _dict(frappe.get_site_config())

		if not frappe.db.exists('User', '*****@*****.**'):
			user = frappe.new_doc('User')
			user.email = '*****@*****.**'
			user.first_name = 'Test_scheduler'
			user.save()
			user.add_roles('System Manager')

		frappe.db.commit()
		frappe.set_user("*****@*****.**")

		disable_scheduler_on_expiry()

		ss = frappe.get_doc("System Settings")
		self.assertFalse(ss.enable_scheduler)

		clear_limit("expiry")
		frappe.local.conf = _dict(frappe.get_site_config())
示例#13
0
    def test_user_limit_for_site(self):
        from frappe.core.doctype.user.user import get_total_users

        update_limits({"users": get_total_users()})

        # reload site config
        from frappe import _dict

        frappe.local.conf = _dict(frappe.get_site_config())

        # Create a new user
        user = frappe.new_doc("User")
        user.email = "*****@*****.**"
        user.first_name = "Test_max_user"

        self.assertRaises(MaxUsersReachedError, user.add_roles, "System Manager")

        if frappe.db.exists("User", "*****@*****.**"):
            frappe.delete_doc("User", "*****@*****.**")

            # Clear the user limit
        clear_limit("users")
示例#14
0
    def test_file_upload_limit(self):
        from frappe.core.doctype.file.file import MaxFileSizeReachedError
        from frappe.limits import update_limits, clear_limit
        from frappe import _dict

        update_limits({
            'space': 1,
            'space_usage': {
                'files_size': (1024**2),
                'database_size': 0,
                'backup_size': 0,
                'total': (1024**2)
            }
        })

        # Rebuild the frappe.local.conf to take up the changes from site_config
        frappe.local.conf = _dict(frappe.get_site_config())

        _file = frappe.get_doc({
            "doctype":
            "File",
            "file_name":
            "_test_max_space.txt",
            "attached_to_name":
            "",
            "attached_to_doctype":
            "",
            "folder":
            self.get_folder("Test Folder 2", "Home").name,
            "content":
            "This file tests for max space usage"
        })
        self.assertRaises(MaxFileSizeReachedError, _file.save)

        # Scrub the site_config and rebuild frappe.local.conf
        clear_limit("space")
        frappe.local.conf = _dict(frappe.get_site_config())
示例#15
0
	def test_file_upload_limit(self):
		from frappe.utils.file_manager import MaxFileSizeReachedError
		from frappe.limits import update_limits, clear_limit
		from frappe import _dict

		update_limits({
			'space': 1,
			'space_usage': {
				'files_size': (1024 ** 2),
				'database_size': 0,
				'backup_size': 0,
				'total': (1024 ** 2)
			}
		})

		# Rebuild the frappe.local.conf to take up the changes from site_config
		frappe.local.conf = _dict(frappe.get_site_config())

		self.assertRaises(MaxFileSizeReachedError, save_file, '_test_max_space.txt',
			'This files test for max space usage', "", "", self.get_folder("Test Folder 2", "Home").name)

		# Scrub the site_config and rebuild frappe.local.conf
		clear_limit("space")
		frappe.local.conf = _dict(frappe.get_site_config())
def execute():
	limits = get_limits()
	if limits and limits.upgrade_link:
		upgrade_url = limits.upgrade_link
		clear_limit('upgrade_link')
		update_limits({'upgrade_url': upgrade_url})
示例#17
0
def execute():
    limits = get_limits()
    if limits and limits.upgrade_link:
        upgrade_url = limits.upgrade_link
        clear_limit('upgrade_link')
        update_limits({'upgrade_url': upgrade_url})