Beispiel #1
0
def super_user_save(sender, **kwargs):
    instance = kwargs["instance"]
    if (sender==User):
        if (instance.is_superuser):
            p = UserProfile.get_or_create_profile(instance)
            p.is_net_admin = True
            p.max_priority_level = 7000
            p.supervisor = instance
            p.save()
            admfs = AdminFlowSpace.objects.filter(user=instance).all()
            if (len(admfs)==0):
                AdminFlowSpace.objects.create(user=instance)   
                
Beispiel #2
0
    def test_request_flowspace(self):
        '''
        A single user and a single admin.
        User send a request. test that admin auto approve and manual approve works.
        '''
        
        u = User.objects.create_user("user", "user@user.com", "password")
        profile = UserProfile.get_or_create_profile(u)
        
        # log in as user
        logged = self.client.login(username="user",password="password")
        self.assertEqual(logged,True)
        
        response = test_get_and_post_form(
            self.client,
            reverse("user_reg_fs"),
            {"ip_addr":"176.25.10.1","mac_addr":"*"},
        )
        rufs = RequestedUserFlowSpace.objects.filter(user=u)
        self.assertEqual(rufs.count(),2)
        self.assertContains(response, "submitted successfully")
        self.assertContains(response, "awaiting approval by")
        
        # now try it with auto approve script
        self.client.logout()
        logged = self.client.login(username="admin",password="password")
        self.assertEqual(logged,True)
        response = test_get_and_post_form(
            self.client,
            reverse("set_auto_approve"),
            {"script":"Approve All Requests"},
        )
        script = AdminAutoApproveScript.objects.filter(admin=self.test_admin)
        self.assertEqual(script.count(),1)
        self.assertEqual(script[0].script_name,"Approve All Requests")
        self.client.logout()
        
        # log in as user
        logged = self.client.login(username="user",password="password")
        self.assertEqual(logged,True)
        
        response = test_get_and_post_form(
            self.client,
            reverse("user_reg_fs"),
            {"ip_addr":"176.26.10.1","mac_addr":"*"},
        )

        ufs = UserFlowSpace.objects.filter(user=u)
        self.assertEqual(ufs.count(),2)
        self.assertContains(response, "submitted successfully")
        self.assertContains(response, "approved by")
Beispiel #3
0
def set_clearinghouse(request):
    if (not request.user.is_staff):
        return HttpResponseRedirect("/dashboard")
            
    ch_users = UserProfile.objects.filter(is_clearinghouse_user=True)
    profile = None
    if len(ch_users) == 1:
        profile = ch_users[0]

    elif ch_users.count() > 1:
        #this shouldn't happen
        logger.debug("More than one clearinghouse user in OM!!!")
        raise Exception("There are more than one clearinghouse user! Unexpected error.")
        
    if (request.method == "POST"):
        form = CHUserForm(request.POST)
        if (form.is_valid()):
            if len(ch_users) == 0:
                ch_user = User(username=request.POST["username"])
                ch_user.set_password(request.POST["password1"])
                ch_user.save()
                ch_profile = UserProfile.get_or_create_profile(ch_user)
                ch_profile.is_net_admin = False
                ch_profile.is_clearinghouse_user = True
                ch_profile.max_priority_level = 0
                ch_profile.save()
            else:
                profile.user.username = request.POST["username"]
                profile.user.set_password(request.POST["password1"])
                profile.user.save()
            return HttpResponseRedirect("/dashboard")

    else:
        if len(ch_users) == 1:
            form = CHUserForm(pack_ch_user_info(profile.user))
        else:
            form = CHUserForm()
               
    return simple.direct_to_template(request,
                template = 'openflow/optin_manager/controls/set_clearinghouse.html',
                extra_context = {
                        'profile':profile,
                        'form':form,

                 }
        )
Beispiel #4
0
    def setUp(self):
        # Create the clearinghouse user
        username = "clearinghouse"
        password = "password"
        u = User.objects.create(username=username)
        u.set_password(password)
        u.save()
        
        profile = UserProfile.get_or_create_profile(u) 
        profile.is_clearinghouse_user = True
        profile.save()
        
        url = "http://%s:80/xmlrpc/xmlrpc/" % (
                HOST,
        )
        self.om_client = BasicAuthServerProxy(url,
                    username=username,
                    password=password,
                    transport=TestClientTransport())
        # Create dummy FV
        fv = DummyFV.objects.create()
        # Load up a fake topology in the Dummy FV
        fv.populateTopology(10, 20, use_random=USE_RANDOM)
            
        # create fake users for the Dummy FV
        username = "om"
        password = "password"
        u = User.objects.create(username=username)
        u.set_password(password)
        u.save()

        # Create the FV proxy connection
        FVServerProxy.objects.create(
            name="Flowvisor",
            username=username,
            password=password,

            url = SCHEME+"://%s:8443/dummyfv/1/xmlrpc/" % (
                    HOST,
            ),
        )
        
        self.test_admin = User.objects.create_superuser("admin", "admin@admin.com", "password")
Beispiel #5
0
    def setUp(self):
        """
        Load up a DB for the OM.
        Create a client to talk to the OM.
        """
        
        
        call_env_command(test_settings.OM_PROJECT_DIR, "flush",
                         interactive=False)
        self.om_env = Env(test_settings.OM_PROJECT_DIR)
        self.om_env.switch_to()
        
        from openflow.optin_manager.dummyfv.models import DummyFV
        from openflow.optin_manager.xmlrpc_server.models import FVServerProxy
        from openflow.optin_manager.users.models import UserProfile, Priority
        from django.contrib.auth.models import User 

        # Create the clearinghouse user
        username = "clearinghouse"
        password = "password"
        u = User.objects.create(username=username)
        u.set_password(password)
        u.save()
        
        profile = UserProfile.get_or_create_profile(u) 
        profile.is_clearinghouse_user = True
        profile.save()
        self.om_client = xmlrpclib.ServerProxy(
            SCHEME + "://%s:%s@%s:%s/xmlrpc/xmlrpc/" % (
                username, password, test_settings.HOST, test_settings.OM_PORT
            )
        )
        
        #create admin user: use this to look at DBs through admin interface
        username = "admin"
        password = "password"
        u = User.objects.create_superuser(username, "superuser@user.com", password)
        u.save()
        profile = UserProfile.get_or_create_profile(u) 
        profile.is_net_admin = True
        profile.supervisor = u
        profile.max_priority_level = Priority.Aggregate_Admin
        profile.admin_position = "Stanford Aggregate Admin"
        profile.save()      
         
         
        # Create dummy FVs
        for i in range(test_settings.NUM_DUMMY_FVS):
            fv = DummyFV.objects.create()
            # Load up a fake topology in the Dummy FV
            fv.populateTopology(10, 20, use_random=test_settings.USE_RANDOM)
            
            # create fake users for the Dummy FV
            username = "om%s" % i
            password = "password"
            u = User.objects.create(username=username)
            u.set_password(password)
            u.save()

            # Create the FV proxy connection
            FVServerProxy.objects.create(
                name="Flowvisor %s" % i,
                username=username,
                password=password,
                url = "test://%s:%s/dummyfv/%s/xmlrpc/" % (
                    test_settings.HOST, 8000, fv.id,
                ),
            )
Beispiel #6
0
    def prepare_om(self, proj_dir, flowvisor, ch_username, ch_passwd):
        """
        Flush the OM DB and add a flowvisor and user for the CH
        """
        call_env_command(proj_dir, "flush",
                         interactive=False)
        self.om_env = Env(proj_dir)
        self.om_env.switch_to()
        
        from django.contrib.auth.models import User
        from openflow.optin_manager.users.models import UserProfile
        from openflow.optin_manager.xmlrpc_server.models import FVServerProxy
        from openflow.optin_manager.xmlrpc_server.ch_api import om_ch_translate
        from openflow.optin_manager.opts.models import AdminFlowSpace, UserFlowSpace
        import random
        
        # Create the Expedient user
        u = User.objects.create(username=ch_username)
        u.set_password(ch_passwd)
        u.save()
        profile = UserProfile.get_or_create_profile(u) 
        profile.is_clearinghouse_user = True
        profile.save()
        
        # make a normal user on system
        username = "user"
        password = "password"
        u = User.objects.create(username=username, is_active=True)
        u.set_password(password)
        u.save()

        # assign flowspace to the user
        random.seed(0)
        self.user_ip_src_s = random.randint(0,0x80000000) & 0xFFFF0000
        self.user_ip_src_e = random.randint(0x80000000,0xFFFFFFFF) & 0xFFFF0000
        fields=["dl_src","dl_dst","vlan_id","tp_src","tp_dst"]
        random.shuffle(fields)

        (to_str,from_str,width,om_name,of_name) = om_ch_translate.attr_funcs[fields[0]]
        self.user_field_name = om_name
        self.user_field_s = random.randint(0,2**(width)-3)
        self.user_field_e = self.user_field_s + 1

        # assign full flowspace to admin:
        username = "admin"
        password = "password"
        adm = User.objects.create(username=username, is_superuser=True,
                                  is_staff=True, is_active=True)
        adm.set_password(password)
        adm.save()
        profile = UserProfile.get_or_create_profile(adm) 
        profile.is_net_admin = True
        profile.supervisor = adm
        profile.max_priority_level = 7000
        profile.save()
        AdminFlowSpace.objects.create(user=adm)
        
        # assign flowspace to user
        ufs = UserFlowSpace(user=u, ip_src_s=self.user_ip_src_s,
                             ip_src_e=self.user_ip_src_e,approver=adm)
        setattr(ufs,"%s_s"%self.user_field_name,self.user_field_s)
        setattr(ufs,"%s_e"%self.user_field_name,self.user_field_e)
        ufs.save()     

        # Create the FV proxy connection
        fv = FVServerProxy(
            name="Flowvisor",
            username=flowvisor["username"],
            password=flowvisor["password"],
            url="https://%s:%s/xmlrpc" % (
                flowvisor["host"], flowvisor["xmlrpc_port"],
            ),
            verify_certs=False,
        )
        fv.save()
        
        self.om_client = xmlrpclib.ServerProxy(
            SCHEME+"://%s:%s@%s:%s/xmlrpc/xmlrpc/" % (
                ch_username, ch_passwd,
                test_settings.HOST, test_settings.OM_PORT,
            )
        )
        
        self.om_env.switch_from()
Beispiel #7
0
    def test_update_slice_and_optin(self):
        '''
        Test if updating a slice when there are some opt-ins actually update the opt-ins
        '''
        user_ip_addr_s = "192.168.0.123"
        user_ip_addr_e = "192.168.0.124"
        ip_addr_s = "192.168.0.123"
        ip_addr_e = "192.168.0.126"
        new_ip_addr_s = "192.168.0.125"
        new_ip_addr_e = "192.168.0.128"
        
        # create a user and assign a FS to him:
        u = User.objects.create_user("username", "user@user.com", "password")
        UserProfile.get_or_create_profile(u)
        UserFlowSpace.objects.create(user=u,approver=self.test_admin,
                                     ip_src_s=dotted_ip_to_int(user_ip_addr_s)
                                     ,ip_src_e=dotted_ip_to_int(user_ip_addr_e))
        args = {
            "slice_id": 1,
            "project_name": "project_name 1",
            "project_description": "project_description 1",
            "slice_name": "new slice name-1",
            "slice_description": "new slice_description",
            "controller_url": "bla:bla.bla.bla:6633",
            "owner_email": "bla@bla.com",
            "owner_password": "new password",
            "switch_slivers": [
                {
                "datapath_id": "00:00:00:00:00:00:01",
                "flowspace": [
                              {"nw_src_start":"%s"%ip_addr_s,"nw_src_send":"%s"%ip_addr_e},
                             ],
                },
                {
                "datapath_id": "00:00:00:00:00:00:02",
                "flowspace": [
                              {"nw_src_start":"%s"%new_ip_addr_s,"nw_src_send":"%s"%new_ip_addr_e},
                             ],
                },
            ]
        }
        
        # Create!
        ret = self.om_client.create_slice(
            args["slice_id"], args["project_name"], args["project_description"],
            args["slice_name"], args["slice_description"],
            args["controller_url"], args["owner_email"], args["owner_password"],
            args["switch_slivers"]
        )
        
        # now test that just one experiment exist and that is the 
        # updated version:
        
        # check the return value
        self.assertEqual(ret, {'error_msg': "", 'switches': []})
        
        # check the OM database to see if Experiment has been created correctly
        returned = Experiment.objects.filter(slice_id=args["slice_id"])

        self.assertEqual(
            returned.count(), 1 ,
            "more than one slice with same name %s" % args["slice_name"])
        
        # now opt-in user:
        self.client.login(username="username",password="password")
        response = test_get_and_post_form(
            self.client,
            reverse("opt_in_experiment"),
            {"experiment":1},
        )
        # now test if opt-in was correct
        self.assertContains(response, "successfully")
        optfs = OptsFlowSpace.objects.filter(opt__user=u)
        self.assertEqual(optfs.count(),1)
        
        self.assertEqual(optfs[0].dpid,"00:00:00:00:00:00:01")
        self.assertEqual(optfs[0].ip_src_s,dotted_ip_to_int(user_ip_addr_s))
        self.assertEqual(optfs[0].ip_src_e,dotted_ip_to_int(user_ip_addr_e))

        # now change the experiments flowspace, verify that user opt
        # updated accordingly:
        args = {
            "slice_id": 1,
            "project_name": "project_name 1",
            "project_description": "project_description 1",
            "slice_name": "new slice name-1",
            "slice_description": "new slice_description",
            "controller_url": "bla:bla.bla.bla:6633",
            "owner_email": "bla@bla.com",
            "owner_password": "new password",
            "switch_slivers": [
                {
                "datapath_id": "00:00:00:00:00:00:01",
                "flowspace": [
                              {"nw_src_start":"%s"%new_ip_addr_s,"nw_src_send":"%s"%new_ip_addr_e},
                             ],
                },
                {
                "datapath_id": "00:00:00:00:00:00:02",
                "flowspace": [
                              {"nw_src_start":"%s"%new_ip_addr_s,"nw_src_send":"%s"%new_ip_addr_e},
                             ],
                },
            ]
        }
        
        # Create!
        ret = self.om_client.create_slice(
            args["slice_id"], args["project_name"], args["project_description"],
            args["slice_name"], args["slice_description"],
            args["controller_url"], args["owner_email"], args["owner_password"],
            args["switch_slivers"]
        )
        
        # now test that just one experiment exist and that is the 
        # updated version:
        
        # check the return value
        self.assertEqual(ret, {'error_msg': "", 'switches': []})
        optfs = OptsFlowSpace.objects.filter(opt__user=u)
        self.assertEqual(optfs.count(),0)
Beispiel #8
0
    def setUp(self):
        # Create a test user
        self.test_user = User.objects.create_user(
                "user", "user@user.com", "password")
        profile = UserProfile.get_or_create_profile(self.test_user)

        # Create a test admin
        self.test_admin = User.objects.create_superuser(
                "admin", "admin@user.com", "password")
        
        # Assign a flowpsace to uer
        self.user_ip_src_s = random.randint(0,0x80000000) & 0xFFFF0000
        self.user_ip_src_e = random.randint(0x80000000,0xFFFFFFFF) & 0xFFFF0000
    
        # Assign a flowpsace to experiment
        self.exp_ip_src_s = random.randint(0,0x80000000) & 0xFFFF0000
        self.exp_ip_src_e = random.randint(0x80000000,0xFFFFFFFF) & 0xFFFF0000
        
        # Choose a random field
        fields=["dl_src","dl_dst","vlan_id","tp_src","tp_dst"]
        random.shuffle(fields)
        (to_str,from_str,width,om_name,of_name) = om_ch_translate.attr_funcs[fields[0]]
        self.user_field_name = om_name
        self.user_field_s = random.randint(0,2**width-3)
        self.user_field_e = self.user_field_s + 1
        (to_str,from_str,width,om_name,of_name) = om_ch_translate.attr_funcs[fields[1]]
        self.exp_field_name = om_name
        self.exp_field_s = random.randint(0,2**width-3)
        self.exp_field_e = self.exp_field_s + 1 
              
        #save flowspace for user
        ufs = UserFlowSpace(user=self.test_user, ip_src_s=self.user_ip_src_s,
                             ip_src_e=self.user_ip_src_e,approver=self.test_admin)
        setattr(ufs,"%s_s"%self.user_field_name,self.user_field_s)
        setattr(ufs,"%s_e"%self.user_field_name,self.user_field_e)
        ufs.save()     
    
        #create an experiment and assign a flowspace to it
        exp = Experiment.objects.create(slice_id="slice_id_1", project_name="project name_1",
                                  project_desc="project description", slice_name="slice name_1",
                                  slice_desc="slice description", controller_url="controller url",
                                  owner_email="owner email", owner_password="owner password") 
        expfs = ExperimentFLowSpace.objects.create(exp=exp, dpid="00:00:00:00:00:00:01",
                            ip_src_s=self.exp_ip_src_s, 
                            ip_src_e=self.exp_ip_src_e, 
                             )
        setattr(expfs,"%s_s"%self.exp_field_name,self.exp_field_s)
        setattr(expfs,"%s_e"%self.exp_field_name,self.exp_field_e)
        expfs.save()     

        # Create dummy FV
        fv = DummyFV.objects.create()
        # Load up a fake topology in the Dummy FV
        fv.populateTopology(10, 20, use_random=USE_RANDOM)
            
        # create fake users for the Dummy FV
        username = "om"
        password = "password"
        u = User.objects.create(username=username)
        u.set_password(password)
        u.save()

        # Create the FV proxy connection
        FVServerProxy.objects.create(
            name="Flowvisor",
            username=username,
            password=password,

            url = SCHEME+"://%s:8443/dummyfv/%d/xmlrpc/" % (
                    HOST,fv.id,
            ),
        )
            
        #Login
        logged = self.client.login(username="user",password="password")
        self.assertEqual(logged,True)
Beispiel #9
0
    def test_multi_user_conflict(self):
        '''
        Create two users and one admin. two users requests two flowspaces that intersect.
        verify these:
        1) Admin gets conflict warning for both requests when in the approve page.
        2) Admin approves one of them. Still should get conflict warning for the other one.
        '''
        u1 = User.objects.create_user("user1", "user1@user.com", "password")
        profile1 = UserProfile.get_or_create_profile(u1)

        u2 = User.objects.create_user("user2", "user2@user.com", "password")
        profile2 = UserProfile.get_or_create_profile(u2)
        
        logged = self.client.login(username="user1",password="password")
        self.assertEqual(logged,True)
        response = test_get_and_post_form(
            self.client,
            reverse("user_reg_fs"),
            {"ip_addr":"192.168.1.10","mac_addr":"*"},
        )
        rufs = RequestedUserFlowSpace.objects.filter(user=u1)
        self.assertEqual(rufs.count(),2)
        self.assertContains(response, "submitted successfully")
        self.assertContains(response, "awaiting approval by")
        
        self.client.logout()
        
        logged = self.client.login(username="user2",password="password")
        self.assertEqual(logged,True)
        response = test_get_and_post_form(
            self.client,
            reverse("user_reg_fs"),
            {"ip_addr":"192.168.1.10","mac_addr":"*"},
        )
        rufs = RequestedUserFlowSpace.objects.filter(user=u2)
        self.assertEqual(rufs.count(),2)
        self.assertContains(response, "submitted successfully")
        self.assertContains(response, "awaiting approval by")
        
        self.client.logout()
        
        logged = self.client.login(username="admin",password="password")
        self.assertEqual(logged,True)
        response = test_get_and_post_form(
            self.client,
            reverse("approve_user_reg"),
            {"req_1":"none"},
        )
        self.assertContains(response,"Conflict with   (username: user1)")
        self.assertContains(response,"Conflict with   (username: user2)")
        response = test_get_and_post_form(
            self.client,
            reverse("approve_user_reg"),
            {"req_1":"accept","req_2":"accept"},
        )
        self.assertContains(response,"Conflict with   (username: user1)")
        self.assertNotContains(response, "Conflict with   (username: user2)")
        self.assertNotContains(response,"req_1")
        self.assertNotContains(response,"req_2")
        
        
Beispiel #10
0
    def test_one_user_conflict(self):
        '''
        1) User requests one flowspace. then requests a subset of that flowpsace.
        The request should be rejected.
        2) User requests one flowspace. then requests a superset of that flowpsace.
        The previous request should be deleted and replaced by new one
        3) User requests one flowspace. Admin accepts it. then requests a subset of 
        that flowpsace. request should be rejected.
        4) User requests one flowspace. Admin accepts it. then requests a superset of 
        that flowpsace. admin accepts that as well. We should just see the second 
        request in UserFlowSpace.
        '''
        u = User.objects.create_user("user", "user@user.com", "password")
        profile = UserProfile.get_or_create_profile(u)
    
        ### part 1
        logged = self.client.login(username="user",password="password")
        self.assertEqual(logged,True)
        response = test_get_and_post_form(
            self.client,
            reverse("user_reg_fs"),
            {"ip_addr":"192.168.1.10","mac_addr":"*"},
        )
        rufs = RequestedUserFlowSpace.objects.filter(user=u)
        self.assertEqual(rufs.count(),2)
        self.assertContains(response, "submitted successfully")
        self.assertContains(response, "awaiting approval by")
        
        # now request a subset of the first FS:
        response = test_get_and_post_form(
            self.client,
            reverse("user_reg_fs"),
            {"ip_addr":"192.168.1.10","mac_addr":"00:11:22:33:44:55"},
        )
        rufs = RequestedUserFlowSpace.objects.filter(user=u)
        self.assertEqual(rufs.count(),2)
        self.assertContains(response, "already owned")

        RequestedUserFlowSpace.objects.filter(user=u).delete()

        ### part 2
        response = test_get_and_post_form(
            self.client,
            reverse("user_reg_fs"),
            {"ip_addr":"193.168.1.10","mac_addr":"00:11:22:33:44:55"},
        )
        rufs = RequestedUserFlowSpace.objects.filter(user=u)
        self.assertEqual(rufs.count(),2)
        self.assertContains(response, "submitted successfully")
        self.assertContains(response, "awaiting approval by")
        
        response = test_get_and_post_form(
            self.client,
            reverse("user_reg_fs"),
            {"ip_addr":"193.168.1.10","mac_addr":"*"},
        )
        rufs = RequestedUserFlowSpace.objects.filter(user=u)
        self.assertEqual(rufs.count(),2)
        self.assertContains(response, "submitted successfully")
        self.assertContains(response, "awaiting approval by")
        
        RequestedUserFlowSpace.objects.filter(user=u).delete()
        
        #### part 3
        self.client.logout()
        logged = self.client.login(username="admin",password="password")
        self.assertEqual(logged,True)
        response = test_get_and_post_form(
            self.client,
            reverse("set_auto_approve"),
            {"script":"Approve All Requests"},
        )
        script = AdminAutoApproveScript.objects.filter(admin=self.test_admin)
        self.assertEqual(script.count(),1)
        self.assertEqual(script[0].script_name,"Approve All Requests")
        self.client.logout()
        logged = self.client.login(username="user",password="password")
        self.assertEqual(logged,True)
        
        response = test_get_and_post_form(
            self.client,
            reverse("user_reg_fs"),
            {"ip_addr":"192.168.1.10","mac_addr":"*"},
        )

        ufs = UserFlowSpace.objects.filter(user=u)
        self.assertEqual(ufs.count(),2)
        self.assertContains(response, "submitted successfully")
        self.assertContains(response, "approved by")
        
        response = test_get_and_post_form(
            self.client,
            reverse("user_reg_fs"),
            {"ip_addr":"192.168.1.10","mac_addr":"00:11:22:33:44:55"},
        )

        ufs = UserFlowSpace.objects.filter(user=u)
        self.assertEqual(ufs.count(),2)
        self.assertContains(response, "already owned")
        
        UserFlowSpace.objects.filter(user=u).delete()
        
        #### part 4
        response = test_get_and_post_form(
            self.client,
            reverse("user_reg_fs"),
            {"ip_addr":"193.168.1.10","mac_addr":"00:11:22:33:44:55"},
        )
        ufs = UserFlowSpace.objects.filter(user=u)
        self.assertEqual(ufs.count(),2)
        self.assertContains(response, "submitted successfully")
        self.assertContains(response, "approved by")
        
        response = test_get_and_post_form(
            self.client,
            reverse("user_reg_fs"),
            {"ip_addr":"193.168.1.10","mac_addr":"*"},
        )

        ufs = UserFlowSpace.objects.filter(user=u)
        self.assertEqual(ufs.count(),2)
        self.assertContains(response, "submitted successfully")
        self.assertContains(response, "approved by")
Beispiel #11
0
    def test_multi_admin(self):
        '''
        5 admins in a hierarchial fashion, and one user sending 3 requests, each
        targeted to one admin. verify that they are being sent to correct admin.
        '''
        u1 = User.objects.create_user("admin1", "admin1@admin.com", "password")
        profile1 = UserProfile.get_or_create_profile(u1)

        u2 = User.objects.create_user("admin2", "admin2@admin.com", "password")
        profile2 = UserProfile.get_or_create_profile(u2)
        
        u3 = User.objects.create_user("admin3", "admin3@admin.com", "password")
        profile3 = UserProfile.get_or_create_profile(u3)
        
        u4 = User.objects.create_user("admin4", "admin4@admin.com", "password")
        profile4 = UserProfile.get_or_create_profile(u4)
        
        profile1.is_net_admin = True
        profile1.supervisor = self.test_admin
        profile1.save()
        
        profile2.is_net_admin = True
        profile2.supervisor = self.test_admin
        profile2.save()
        
        profile3.is_net_admin = True
        profile3.supervisor = u1
        profile3.save()
        
        profile4.is_net_admin = True
        profile4.supervisor = u2
        profile4.save()
        
        AdminFlowSpace.objects.create(user=u1,
                            ip_src_s=dotted_ip_to_int("192.0.0.0"),
                            ip_src_e=dotted_ip_to_int("192.255.255.255"))
        AdminFlowSpace.objects.create(user=u1,
                            ip_dst_s=dotted_ip_to_int("192.0.0.0"),
                            ip_dst_e=dotted_ip_to_int("192.255.255.255"))
        AdminFlowSpace.objects.create(user=u2,
                            ip_src_s=dotted_ip_to_int("193.0.0.0"),
                            ip_src_e=dotted_ip_to_int("193.255.255.255"))
        AdminFlowSpace.objects.create(user=u2,
                            ip_dst_s=dotted_ip_to_int("193.0.0.0"),
                            ip_dst_e=dotted_ip_to_int("193.255.255.255"))
        AdminFlowSpace.objects.create(user=u3,
                            ip_src_s=dotted_ip_to_int("192.168.0.0"),
                            ip_src_e=dotted_ip_to_int("192.168.255.255"))
        AdminFlowSpace.objects.create(user=u3,
                            ip_dst_s=dotted_ip_to_int("192.168.0.0"),
                            ip_dst_e=dotted_ip_to_int("192.168.255.255"))
        AdminFlowSpace.objects.create(user=u4,
                            ip_src_s=dotted_ip_to_int("193.168.0.0"),
                            ip_src_e=dotted_ip_to_int("193.168.255.255"))
        AdminFlowSpace.objects.create(user=u4,
                            ip_dst_s=dotted_ip_to_int("193.168.0.0"),
                            ip_dst_e=dotted_ip_to_int("193.168.255.255"))
        
        u = User.objects.create_user("user", "user@user.com", "password")
        profile = UserProfile.get_or_create_profile(u)
        # log in as user
        logged = self.client.login(username="user",password="password")
        self.assertEqual(logged,True)
        
        # this should be assigned to admin1
        response = test_get_and_post_form(
            self.client,
            reverse("user_reg_fs"),
            {"ip_addr":"192.165.10.1","mac_addr":"*"},
        )
        self.assertContains(response, "submitted successfully")
        self.assertContains(response, "(admin1)")
                
        # this should be assigned to admin2
        response = test_get_and_post_form(
            self.client,
            reverse("user_reg_fs"),
            {"ip_addr":"193.122.10.1","mac_addr":"*"},
        )
        self.assertContains(response, "submitted successfully")
        self.assertContains(response, "(admin2)")
        
        # this should be assigned to admin3
        response = test_get_and_post_form(
            self.client,
            reverse("user_reg_fs"),
            {"ip_addr":"192.168.10.1","mac_addr":"*"},
        )
        self.assertContains(response, "submitted successfully")
        self.assertContains(response, "(admin3)")
        
        # this should be assigned to admin4
        response = test_get_and_post_form(
            self.client,
            reverse("user_reg_fs"),
            {"ip_addr":"193.168.10.1","mac_addr":"*"},
        )
        self.assertContains(response, "submitted successfully")
        self.assertContains(response, "(admin4)")
        
        rufs = RequestedUserFlowSpace.objects.filter(user=u,admin=profile1.user)
        self.assertEqual(rufs.count(),2)
        rufs = RequestedUserFlowSpace.objects.filter(user=u,admin=profile2.user)
        self.assertEqual(rufs.count(),2)
        rufs = RequestedUserFlowSpace.objects.filter(user=u,admin=profile3.user)
        self.assertEqual(rufs.count(),2)
        rufs = RequestedUserFlowSpace.objects.filter(user=u,admin=profile4.user)
        self.assertEqual(rufs.count(),2)