Ejemplo n.º 1
0
def test_current_element_naming_style(policy_clear):
    """
    Ensure that current naming style works properly.
    """
    computer_policy = {
        "Point and Print Restrictions": {
            "Users can only point and print to these servers": True,
            "Enter fully qualified server names separated by semicolons": (
                "fakeserver1;fakeserver2"
            ),
            "Users can only point and print to machines in their forest": True,
            "When installing drivers for a new connection": (
                "Show warning and elevation prompt"
            ),
            "When updating drivers for an existing connection": "Show warning only",
        }
    }
    with patch.dict(win_lgpo.__opts__, {"test": False}):
        result = win_lgpo.set_(name="test_state", computer_policy=computer_policy)
        result = win_lgpo._convert_to_unicode(result)
    expected = {
        "Point and Print Restrictions": {
            "Enter fully qualified server names separated by semicolons": (
                "fakeserver1;fakeserver2"
            ),
            "When installing drivers for a new connection": (
                "Show warning and elevation prompt"
            ),
            "Users can only point and print to machines in their forest": True,
            "Users can only point and print to these servers": True,
            "When updating drivers for an existing connection": "Show warning only",
        }
    }
    assert result["changes"]["new"]["Computer Configuration"] == expected
Ejemplo n.º 2
0
 def test_current_element_naming_style(self):
     computer_policy = {
         "Point and Print Restrictions": {
             "Users can only point and print to these servers": True,
             "Enter fully qualified server names separated by "
             "semicolons": "fakeserver1;fakeserver2",
             "Users can only point and print to machines in their " "forest": True,
             "When installing drivers for a new connection": "Show warning and elevation prompt",
             "When updating drivers for an existing connection": "Show warning only",
         }
     }
     with patch.dict(win_lgpo.__opts__, {"test": False}):
         result = win_lgpo.set_(name="test_state", computer_policy=computer_policy)
         result = win_lgpo._convert_to_unicode(result)
     expected = {
         "Point and Print Restrictions": {
             "Enter fully qualified server names separated by "
             "semicolons": "fakeserver1;fakeserver2",
             "When installing drivers for a new connection": "Show warning and elevation prompt",
             "Users can only point and print to machines in " "their forest": True,
             "Users can only point and print to these servers": True,
             "When updating drivers for an existing connection": "Show warning only",
         }
     }
     self.assertDictEqual(
         result["changes"]["new"]["Computer Configuration"], expected
     )
Ejemplo n.º 3
0
    def test_old_element_naming_style(self):
        computer_policy = {
            "Point and Print Restrictions": {
                "Users can only point and print to these servers":
                True,
                "Enter fully qualified server names separated by "
                "semicolons":
                "fakeserver1;fakeserver2",
                "Users can only point and print to machines in their "
                "forest":
                True,
                # Here's the old one
                "Security Prompts: When installing drivers for a new connection":
                "Show warning and elevation prompt",
                "When updating drivers for an existing connection":
                "Show warning only",
            }
        }

        with patch.dict(win_lgpo.__opts__, {"test": False}):
            result = win_lgpo.set_(name="test_state",
                                   computer_policy=computer_policy)
            if six.PY2:
                result = win_lgpo._convert_to_unicode(result)
        expected = {
            "Point and Print Restrictions": {
                "Enter fully qualified server names separated by "
                "semicolons":
                "fakeserver1;fakeserver2",
                "When installing drivers for a new connection":
                "Show warning and elevation prompt",
                "Users can only point and print to machines in "
                "their forest":
                True,
                "Users can only point and print to these servers":
                True,
                "When updating drivers for an existing connection":
                "Show warning only",
            }
        }
        self.assertDictEqual(
            result["changes"]["new"]["Computer Configuration"], expected)
        expected = (
            "The LGPO module changed the way it gets policy element names.\n"
            '"Security Prompts: When installing drivers for a new connection" is no longer valid.\n'
            'Please use "When installing drivers for a new connection" instead.\n'
            "The following policies changed:\n"
            "Point and Print Restrictions")
        self.assertEqual(result["comment"], expected)
Ejemplo n.º 4
0
    def test_old_element_naming_style(self):
        computer_policy = {
            'Point and Print Restrictions': {
                'Users can only point and print to these servers':
                True,
                'Enter fully qualified server names separated by '
                'semicolons':
                'fakeserver1;fakeserver2',
                'Users can only point and print to machines in their '
                'forest':
                True,
                # Here's the old one
                'Security Prompts: When installing drivers for a new connection':
                'Show warning and elevation prompt',
                'When updating drivers for an existing connection':
                'Show warning only',
            }
        }

        with patch.dict(win_lgpo.__opts__, {'test': False}):
            result = win_lgpo.set_(name='test_state',
                                   computer_policy=computer_policy)
            if six.PY2:
                result = win_lgpo._convert_to_unicode(result)
        expected = {
            'Point and Print Restrictions': {
                'Enter fully qualified server names separated by '
                'semicolons':
                'fakeserver1;fakeserver2',
                'When installing drivers for a new connection':
                'Show warning and elevation prompt',
                'Users can only point and print to machines in '
                'their forest':
                True,
                'Users can only point and print to these servers':
                True,
                'When updating drivers for an existing connection':
                'Show warning only'
            }
        }
        self.assertDictEqual(
            result['changes']['new']['Computer Configuration'], expected)
        expected = 'The LGPO module changed the way it gets policy element names.\n' \
                   '"Security Prompts: When installing drivers for a new connection" is no longer valid.\n' \
                   'Please use "When installing drivers for a new connection" instead.\n' \
                   'The following policies changed:\n' \
                   'Point and Print Restrictions'
        self.assertEqual(result['comment'], expected)
Ejemplo n.º 5
0
 def test_current_element_naming_style(self):
     computer_policy = {
         'Point and Print Restrictions': {
             'Users can only point and print to these servers':
             True,
             'Enter fully qualified server names separated by '
             'semicolons':
             'fakeserver1;fakeserver2',
             'Users can only point and print to machines in their '
             'forest':
             True,
             'When installing drivers for a new connection':
             'Show warning and elevation prompt',
             'When updating drivers for an existing connection':
             'Show warning only',
         }
     }
     with patch.dict(win_lgpo.__opts__, {'test': False}):
         result = win_lgpo.set_(name='test_state',
                                computer_policy=computer_policy)
         result = win_lgpo._convert_to_unicode(result)
     expected = {
         'Point and Print Restrictions': {
             'Enter fully qualified server names separated by '
             'semicolons':
             'fakeserver1;fakeserver2',
             'When installing drivers for a new connection':
             'Show warning and elevation prompt',
             'Users can only point and print to machines in '
             'their forest':
             True,
             'Users can only point and print to these servers':
             True,
             'When updating drivers for an existing connection':
             'Show warning only'
         }
     }
     self.assertDictEqual(
         result['changes']['new']['Computer Configuration'], expected)