# -*- coding: UTF-8 -*-
from pyeole.process import system_out
from creole.client import CreoleClient, NotFoundError

client = CreoleClient()
try:
    # ScribeAD
    ad_public_address = client.get_creole('ad_public_address')
    ad_realm = client.get_creole('ad_domain')
except NotFoundError:
    # AmonEcole
    ad_public_address = client.get_creole('adresse_ip_domaine_link')
    ad_realm = client.get_creole('ad_realm')

def test_reverse_lookup():
    """
    Vérifie le fonctionnement de la résolution inverse (#30475)
    """
    add = ad_public_address
    result = system_out(['dig', '+short', '-x', ad_public_address])[1].rstrip()
    expected = "addc.{}.".format(ad_realm.lower())
    assert result == expected
