Beispiel #1
0
 def test_access_replace_wildcard(self):
     """Test that a group by account wildcard only has access to the proper accounts."""
     fake_uri = "group_by[account]=*&" "group_by[region]=*"
     test_access = {
         "aws.account": {
             "read": ["account1", "account2"]
         },
         "aws.organizational_unit": {
             "read": ["*"]
         }
     }
     fake_request = Mock(
         spec=HttpRequest,
         user=Mock(access=test_access,
                   customer=Mock(schema_name="acct10001")),
         GET=Mock(urlencode=Mock(return_value=fake_uri)),
     )
     fake_view = Mock(
         spec=ReportView,
         provider=self.FAKE.word(),
         query_handler=Mock(provider=Provider.PROVIDER_AWS),
         report=self.FAKE.word(),
         serializer=Mock,
         tag_handler=[],
     )
     params = QueryParameters(fake_request, fake_view)
     self.assertEqual(params.get_access("account"),
                      ["account1", "account2"])
     self.assertEqual(params.get_group_by("region"), "*")
Beispiel #2
0
 def test_access_add_account_filter(self):
     """Test that if no group_by or filter is present a filter of accounts is added."""
     fake_uri = "filter[region]=*"
     test_access = {
         "aws.account": {
             "read": ["account1", "account2"]
         },
         "aws.organizational_unit": {
             "read": ["*"]
         }
     }
     fake_request = Mock(
         spec=HttpRequest,
         user=Mock(access=test_access,
                   customer=Mock(schema_name="acct10001")),
         GET=Mock(urlencode=Mock(return_value=fake_uri)),
     )
     fake_view = Mock(
         spec=ReportView,
         provider=self.FAKE.word(),
         query_handler=Mock(provider=Provider.PROVIDER_AWS),
         report=self.FAKE.word(),
         serializer=Mock,
         tag_handler=[],
     )
     params = QueryParameters(fake_request, fake_view)
     self.assertEqual(params.get_access("account"),
                      ["account1", "account2"])
     self.assertEqual(params.get_filter("region"), "*")
Beispiel #3
0
 def test_update_query_parameters_add_subscription_guid_filter_obj(self):
     """Test that if no group_by or filter is present, access is the subscription_guids available."""
     guid1 = uuid4()
     guid2 = uuid4()
     test_access = {"azure.subscription_guid": {"read": [guid1, guid2]}}
     fake_request = Mock(
         spec=HttpRequest,
         user=Mock(access=test_access, customer=Mock(schema_name="acct10001")),
         GET=Mock(urlencode=Mock(return_value="")),
     )
     fake_view = Mock(
         spec=ReportView,
         provider=self.FAKE.word(),
         query_handler=Mock(provider=Provider.PROVIDER_AZURE),
         report=self.FAKE.word(),
         serializer=Mock,
         tag_handler=[],
     )
     params = QueryParameters(fake_request, fake_view)
     self.assertEqual(params.get_access("subscription_guid"), [guid1, guid2])