示例#1
0
void
rooms_query(void **state)
{
    stbbr_for_id("confreq",
        "<iq id='confreq' type='result' to='stabber@localhost/profanity' from='conference.localhost'>"
            "<query xmlns='http://jabber.org/protocol/disco#items'>"
                "<item jid='*****@*****.**' name='A chat room'/>"
                "<item jid='*****@*****.**' name='Another chat room'/>"
            "</query>"
        "</iq>"
    );

    prof_connect();

    prof_input("/rooms conference.localhost");

    assert_true(prof_output_exact("[email protected], (A chat room)"));
    assert_true(prof_output_exact("[email protected], (Another chat room)"));

    assert_true(stbbr_last_received(
        "<iq id='confreq' to='conference.localhost' type='get'>"
            "<query xmlns='http://jabber.org/protocol/disco#items'/>"
        "</iq>"
    ));
}
示例#2
0
// Typical use case for gateways that don't support resources
void
display_software_version_result_when_from_domainpart(void **state)
{
    prof_connect();
    stbbr_send(
        "<presence to=\"stabber@localhost\" from=\"buddy1@localhost\">"
            "<priority>10</priority>"
            "<status>I'm here</status>"
        "</presence>"
    );
    prof_output_exact("Buddy1 is online, \"I'm here\"");

    stbbr_for_query("jabber:iq:version",
        "<iq id=\"*\" type=\"result\" lang=\"en\" to=\"stabber@localhost/profanity\" from=\"localhost\">"
            "<query xmlns=\"jabber:iq:version\">"
                "<name>Some Gateway</name>"
                "<version>1.0</version>"
            "</query>"
        "</iq>"
    );
    prof_input("/software buddy1@localhost/__prof_default");

//    assert_true(prof_output_exact("buddy1@localhost/__prof_default:"));
//    assert_true(prof_output_exact("Name    : Some Gateway"));
    assert_true(prof_output_exact("Version : 1.0"));
}
示例#3
0
void
display_software_version_result(void **state)
{
    prof_connect();
    stbbr_send(
        "<presence to=\"stabber@localhost\" from=\"buddy1@localhost/mobile\">"
            "<priority>10</priority>"
            "<status>I'm here</status>"
        "</presence>"
    );
    prof_output_exact("Buddy1 (mobile) is online, \"I'm here\"");

    stbbr_for_query("jabber:iq:version",
        "<iq id=\"*\" type=\"result\" lang=\"en\" to=\"stabber@localhost/profanity\" from=\"buddy1@localhost/mobile\">"
            "<query xmlns=\"jabber:iq:version\">"
                "<name>Profanity</name>"
                "<version>0.4.7dev.master.2cb2f83</version>"
            "</query>"
        "</iq>"
    );
    prof_input("/software buddy1@localhost/mobile");

//    assert_true(prof_output_exact("buddy1@localhost/mobile:"));
//    assert_true(prof_output_exact("Name    : Profanity"));
    assert_true(prof_output_exact("Version : 0.4.7dev.master.2cb2f83"));
}
示例#4
0
void
ping_multiple(void **state)
{
    stbbr_for_id("prof_ping_2",
        "<iq id='prof_ping_2' type='result' to='stabber@localhost/profanity'/>"
    );
    stbbr_for_id("prof_ping_3",
        "<iq id='prof_ping_3' type='result' to='stabber@localhost/profanity'/>"
    );

    prof_connect();

    prof_input("/ping");
    assert_true(stbbr_received(
        "<iq id='prof_ping_2' type='get'>"
            "<ping xmlns='urn:xmpp:ping'/>"
        "</iq>"
    ));
    assert_true(prof_output_exact("Ping response from server"));

    prof_input("/ping");
    assert_true(stbbr_received(
        "<iq id='prof_ping_3' type='get'>"
            "<ping xmlns='urn:xmpp:ping'/>"
        "</iq>"
    ));
    assert_true(prof_output_exact("Ping response from server"));
}
示例#5
0
void
receive_self_carbon(void **state)
{
    prof_input("/carbons on");

    prof_connect();
    assert_true(stbbr_received(
        "<iq id='*' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>"
    ));

    stbbr_send(
        "<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
            "<priority>10</priority>"
            "<status>On my mobile</status>"
        "</presence>"
    );
    assert_true(prof_output_exact("Buddy1 (mobile) is online, \"On my mobile\""));
    prof_input("/msg Buddy1");
    assert_true(prof_output_exact("unencrypted"));

    stbbr_send(
        "<message type='chat' to='stabber@localhost/profanity' from='stabber@localhost'>"
            "<sent xmlns='urn:xmpp:carbons:2'>"
                "<forwarded xmlns='urn:xmpp:forward:0'>"
                    "<message id='59' xmlns='jabber:client' type='chat' to='buddy1@localhost/mobile' lang='en' from='stabber@localhost/profanity'>"
                        "<body>self sent carbon</body>"
                    "</message>"
                "</forwarded>"
            "</sent>"
        "</message>"
    );

    assert_true(prof_output_regex("me: .+self sent carbon"));
}
示例#6
0
void
sends_message_to_fulljid_when_received_from_fulljid(void **state)
{
    prof_connect();

    stbbr_send(
        "<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
            "<priority>10</priority>"
        "</presence>"
    );
    assert_true(prof_output_exact("Buddy1 (mobile) is online"));

    stbbr_send(
        "<message id='message1' to='stabber@localhost' from='buddy1@localhost/mobile' type='chat'>"
            "<body>First message</body>"
        "</message>"
    );
    assert_true(prof_output_exact("<< chat message: Buddy1/mobile (win 2)"));

    prof_input("/msg buddy1@localhost Hi there");

    assert_true(stbbr_received(
        "<message id='*' to='buddy1@localhost/mobile' type='chat'>"
            "<body>Hi there</body>"
        "</message>"
    ));
}
示例#7
0
void
receive_private_carbon(void **state)
{
    prof_input("/carbons on");

    prof_connect();
    assert_true(stbbr_received(
        "<iq id='*' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>"
    ));

    stbbr_send(
        "<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
            "<priority>10</priority>"
            "<status>On my mobile</status>"
        "</presence>"
    );
    assert_true(prof_output_exact("Buddy1 (mobile) is online, \"On my mobile\""));
    prof_input("/msg Buddy1");
    assert_true(prof_output_exact("unencrypted"));

    stbbr_send(
        "<message type='chat' to='stabber@localhost/profanity' from='buddy1@localhost/mobile'>"
            "<body>Private carbon</body>"
            "<private xmlns='urn:xmpp:carbons:2'/>"
        "</message>"
    );

    assert_true(prof_output_regex("Buddy1/mobile: .+Private carbon"));
}
示例#8
0
void
disconnect_ends_session(void **state)
{
    prof_connect();

    prof_input("/disconnect");
    assert_true(prof_output_exact("stabber@localhost logged out successfully."));

    prof_input("/roster");
    assert_true(prof_output_exact("You are not currently connected."));
}
示例#9
0
void
new_session_when_message_received_from_different_fulljid(void **state)
{
    prof_connect();

    stbbr_send(
        "<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
            "<priority>10</priority>"
        "</presence>"
    );
    assert_true(prof_output_exact("Buddy1 (mobile) is online"));

    stbbr_send(
        "<presence to='stabber@localhost' from='buddy1@localhost/laptop'>"
            "<priority>8</priority>"
            "<show>away</show>"
        "</presence>"
    );
    assert_true(prof_output_exact("Buddy1 (laptop) is away"));

    stbbr_send(
        "<message id='message1' to='stabber@localhost' from='buddy1@localhost/mobile' type='chat'>"
            "<body>From first resource</body>"
        "</message>"
    );
    assert_true(prof_output_exact("<< chat message: Buddy1/mobile (win 2)"));

    prof_input("/msg buddy1@localhost Outgoing 1");
    assert_true(stbbr_received(
        "<message id='*' to='buddy1@localhost/mobile' type='chat'>"
            "<body>Outgoing 1</body>"
        "</message>"
    ));

    stbbr_send(
        "<message id='message1' to='stabber@localhost' from='buddy1@localhost/laptop' type='chat'>"
            "<body>From second resource</body>"
        "</message>"
    );
    assert_true(prof_output_regex("Buddy1/laptop:.+From second resource"));

    prof_input("/msg buddy1@localhost Outgoing 2");
    assert_true(stbbr_received(
        "<message id='*' to='buddy1@localhost/laptop' type='chat'>"
            "<body>Outgoing 2</body>"
        "</message>"
    ));
}
示例#10
0
void
show_message_in_chat_window_when_no_resource(void **state)
{
    prof_connect();
    stbbr_send(
        "<presence to=\"stabber@localhost\" from=\"buddy1@localhost/mobile\">"
            "<priority>10</priority>"
            "<status>I'm here</status>"
        "</presence>"
    );
    prof_output_exact("Buddy1 (mobile) is online, \"I'm here\"");

    prof_input("/msg Buddy1");
    prof_input("/software");

    assert_true(prof_output_exact("Unknown resource for /software command."));
}
示例#11
0
void
resets_to_barejid_after_presence_received(void **state)
{
    prof_connect();

    stbbr_send(
        "<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
            "<priority>10</priority>"
        "</presence>"
    );
    assert_true(prof_output_exact("Buddy1 (mobile) is online"));

    stbbr_send(
        "<message id='message1' to='stabber@localhost' from='buddy1@localhost/mobile' type='chat'>"
            "<body>First message</body>"
        "</message>"
    );
    assert_true(prof_output_exact("<< chat message: Buddy1/mobile (win 2)"));

    prof_input("/msg buddy1@localhost Outgoing 1");
    assert_true(stbbr_received(
        "<message id='*' to='buddy1@localhost/mobile' type='chat'>"
            "<body>Outgoing 1</body>"
        "</message>"
    ));

    stbbr_send(
        "<presence to='stabber@localhost' from='buddy1@localhost/laptop'>"
            "<priority>5</priority>"
            "<show>dnd</show>"
        "</presence>"
    );
    assert_true(prof_output_exact("Buddy1 (laptop) is dnd"));

    prof_input("/msg buddy1@localhost Outgoing 2");
    assert_true(stbbr_received(
        "<message id='*' to='buddy1@localhost' type='chat'>"
            "<body>Outgoing 2</body>"
        "</message>"
    ));
}
示例#12
0
void
shows_message_when_software_version_error(void **state)
{
    prof_connect();
    stbbr_send(
        "<presence to=\"stabber@localhost\" from=\"buddy1@localhost/mobile\">"
            "<priority>10</priority>"
            "<status>I'm here</status>"
        "</presence>"
    );
    prof_output_exact("Buddy1 (mobile) is online, \"I'm here\"");

    stbbr_for_query("jabber:iq:version",
        "<iq id=\"*\" lang=\"en\" type=\"error\" to=\"stabber@localhost/profanity\" from=\"buddy1@localhost/laptop\">"
            "<query xmlns=\"jabber:iq:version\"/>"
            "<error code=\"503\" type=\"cancel\">"
                "<service-unavailable xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\"/>"
            "</error>"
        "</iq>"
    );
    prof_input("/software buddy1@localhost/laptop");

    assert_true(prof_output_exact("Could not get software version: service-unavailable"));
}
示例#13
0
void
send_software_version_request(void **state)
{
    prof_connect();
    stbbr_send(
        "<presence to=\"stabber@localhost\" from=\"buddy1@localhost/mobile\">"
            "<priority>10</priority>"
            "<status>I'm here</status>"
        "</presence>"
    );
    prof_output_exact("Buddy1 (mobile) is online, \"I'm here\"");
    prof_input("/software buddy1@localhost/mobile");

    stbbr_received(
        "<iq id=\"*\" to=\"buddy1@localhost/mobile\" type=\"get\">"
            "<query xmlns=\"jabber:iq:version\"/>"
        "</iq>"
    );
}
示例#14
0
void
sends_message_to_barejid_when_contact_online(void **state)
{
    prof_connect();

    stbbr_send(
        "<presence to='stabber@localhost/profanity' from='buddy1@localhost/mobile'>"
            "<priority>10</priority>"
        "</presence>"
    );
    assert_true(prof_output_exact("Buddy1 (mobile) is online"));

    prof_input("/msg buddy1@localhost Hi there");

    assert_true(stbbr_received(
        "<message id='*' to='buddy1@localhost' type='chat'>"
            "<body>Hi there</body>"
        "</message>"
    ));
}
示例#15
0
void
init_prof_test(void **state)
{
    if (stbbr_start(STBBR_LOGDEBUG ,5230, 0) != 0) {
        assert_true(FALSE);
        return;
    }

    config_orig = getenv("XDG_CONFIG_HOME");
    data_orig = getenv("XDG_DATA_HOME");

    setenv("XDG_CONFIG_HOME", XDG_CONFIG_HOME, 1);
    setenv("XDG_DATA_HOME", XDG_DATA_HOME, 1);

    _cleanup_dirs();

    _create_config_dir();
    _create_data_dir();
    _create_chatlogs_dir();
    _create_logs_dir();

    prof_start();
    assert_true(prof_output_exact("Profanity"));

    // set UI options to make expect assertions faster and more reliable
    prof_input("/inpblock timeout 5");
    assert_true(prof_output_exact("Input blocking set to 5 milliseconds"));
    prof_input("/inpblock dynamic off");
    assert_true(prof_output_exact("Dynamic input blocking disabled"));
    prof_input("/notify message off");
    assert_true(prof_output_exact("Message notifications disabled"));
    prof_input("/wrap off");
    assert_true(prof_output_exact("Word wrap disabled"));
    prof_input("/roster hide");
    assert_true(prof_output_exact("Roster disabled"));
    prof_input("/time off");
}