Esempio n. 1
0
 def test_check_wildcard_access_with_restrictions(self):
     """Test check restrictions returns True when 1 provider is restricted."""
     self.test_read_access = {
         "aws.account": {
             "read": ["999999999"]
         },
         "azure.subscription_guid": {
             "read": ["*"]
         }
     }
     fake_request = Mock(
         spec=HttpRequest,
         user=Mock(access=self.test_read_access,
                   customer=Mock(schema_name="acct10001")),
         GET=Mock(urlencode=Mock(return_value="")),
     )
     fake_view = Mock(
         spec=ReportView,
         provider=Provider.OCP_ALL,
         query_handler=Mock(provider=Provider.OCP_ALL),
         report=self.FAKE.word(),
         serializer=Mock,
         tag_handler=[],
     )
     with patch("reporting.models.OCPAllCostLineItemDailySummary.objects",
                return_value=[]):
         params = QueryParameters(fake_request, fake_view)
         access_list = params._get_providers(Provider.OCP_ALL.lower())
         result = params._check_restrictions(access_list)
     self.assertTrue(result)
Esempio n. 2
0
 def test_check_wildcard_access_with_ocp_restrictions(self):
     """Test check restrictions returns False when non-ocp have wildcard, but ocp is restricted."""
     self.test_read_access = {
         "aws.account": {
             "read": ["*"]
         },
         "aws.organizational_unit": {
             "read": ["*"]
         },
         "azure.subscription_guid": {
             "read": ["*"]
         },
         "openshift.cluster": {
             "read": ["my-ocp-cluster"]
         },
     }
     fake_request = Mock(
         spec=HttpRequest,
         user=Mock(access=self.test_read_access,
                   customer=Mock(schema_name="acct10001")),
         GET=Mock(urlencode=Mock(return_value="")),
     )
     fake_view = Mock(
         spec=ReportView,
         provider=Provider.OCP_ALL,
         query_handler=Mock(provider=Provider.OCP_ALL),
         report=self.FAKE.word(),
         serializer=Mock,
         tag_handler=[],
     )
     params = QueryParameters(fake_request, fake_view)
     access_list = params._get_providers(Provider.OCP_ALL.lower())
     result = params._check_restrictions(access_list)
     self.assertFalse(result)