# (c) cavaliba.com - tests / ipam / permission gating on the surviving IPAM views
# (p_ipam_access). ip_view/ip_list/subnet_view/subnet_list/vlan_view/vlan_list were all
# removed - ipam_ip/ipam_subnet/ipam_vlan now use the regular app_data instance_detail/
# instance_list views (gated by p_data_access, see test_ipam_ip_related.py) plus
# app_data:ipam_ip_jump (gated the same way, see test_views_ipam_ip_jump.py). Only
# private (search/menu landing page) and calculator are left - both moved out of
# app_ipam entirely, to app_data/views_ipam.py, routed as app_data:ipam_private/
# app_data:ipam_calculator (/data/private/ipam/...).

from django.test import TestCase, override_settings
from django.urls import reverse

import app_home.cache as cache


@override_settings(CAVALIBA_AUTH_MODE="local")
class IpamViewPermissionTest(TestCase):
    def setUp(self):
        cache.clear()
        self.client.logout()

    def test_private_unauthenticated_redirects(self):
        response = self.client.get(reverse("app_data:ipam_private"))
        self.assertEqual(response.status_code, 302)

    def test_calculator_unauthenticated_redirects(self):
        response = self.client.get(reverse("app_data:ipam_calculator"))
        self.assertEqual(response.status_code, 302)
