def test_fill_secret_with_prefix(caplog):
    secrerts = interaction.Interaction(MagicMock())
    secrerts._replace_placeholder_variables = MagicMock(return_value="123")
    secrerts.fill_secret("selector", "$password")
    assert caplog.text == ""
    secrerts.fill_secret("selector", "%password")
    assert caplog.text == ""
示例#2
0
def test_type_secret_in_plain_text(caplog):
    ctx = MagicMock()
    ctx.presenter_mode = False
    secrets = interaction.Interaction(ctx)
    secrets._type_text = MagicMock(return_value=Response())
    secrets.type_secret("selector", "password")
    assert caplog.text == WARN_MESSAGE
示例#3
0
def test_fill_secret_with_prefix(caplog):
    ctx = MagicMock()
    ctx.presenter_mode = False
    secrets = interaction.Interaction(ctx)
    secrets._fill_text = MagicMock(return_value=Response())
    secrets._replace_placeholder_variables = MagicMock(return_value="123")
    secrets.fill_secret("selector", "$password")
    assert caplog.text == ""
    secrets.fill_secret("selector", "%password")
    assert caplog.text == ""
示例#4
0
def test_type_secret_reformat_error():
    ctx = MagicMock()
    secrets = interaction.Interaction(ctx)

    def raiser(*args, **kwargs):
        raise Exception("Failure typing: PWD")

    secrets._type_text = raiser
    secrets.resolve_secret = lambda *args: "PWD"

    with pytest.raises(Exception) as excinfo:
        secrets.type_secret("selector", "$password")

    assert "Failure typing: ***" == str(excinfo.value)
def test_type_secret_in_plain_text(caplog):
    secrerts = interaction.Interaction(MagicMock())
    secrerts.type_secret("selector", "password")
    assert caplog.text == WARN_MESSAGE