# Panther is a scalable, powerful, cloud-native SIEM written in Golang/React.
# Copyright (C) 2020 Panther Labs Inc
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

from unittest import mock, TestCase
from boto3 import Session
from ...src.app.remediations.aws_rds_disable_instance_public_access import AwsRdsDisableInstancePublicAccess


class TestAwsRdsDisableInstancePublicAccess(TestCase):

    @mock.patch.object(Session, 'client')
    def test_fix(self, mock_session: mock.MagicMock) -> None:
        mock_client = mock.Mock()
        mock_session.return_value = mock_client
        resource = {'Id': 'TestDBInstanceIdentifier'}
        AwsRdsDisableInstancePublicAccess()._fix(Session, resource, {})
        mock_session.assert_called_once_with('rds')
        mock_client.modify_db_instance.assert_called_once_with(DBInstanceIdentifier='TestDBInstanceIdentifier', PubliclyAccessible=False)
