Add some more tests and fix a bug which sometimes blocked login of users.
This bug wasn't released yet. cc @jpnurmi
This commit is contained in:
1 parent
eb450ee885
commit
933aa6db0c
2 files changed
+40
-2
No files matched your search
+1
-1
@@ -127,7 +127,7 @@ void CClient::ReadLine(const CString& sData) {
|
|||||||
if (sCommand.Equals("PASS")) {
|
if (sCommand.Equals("PASS")) {
|
||||||
m_bGotPass = true;
|
m_bGotPass = true;
|
||||||
|
|
||||||
CString sAuthLine = Message.GetParams(0);
|
CString sAuthLine = Message.GetParam(0);
|
||||||
ParsePass(sAuthLine);
|
ParsePass(sAuthLine);
|
||||||
|
|
||||||
AuthUser();
|
AuthUser();
|
||||||
|
|||||||
+39
-1
@@ -57,6 +57,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Write(QString s = "") {
|
void Write(QString s = "") {
|
||||||
|
if (!m_device) return;
|
||||||
s += "\n";
|
s += "\n";
|
||||||
if (m_verbose) {
|
if (m_verbose) {
|
||||||
std::cout << s.toStdString() << std::flush;
|
std::cout << s.toStdString() << std::flush;
|
||||||
@@ -67,6 +68,9 @@ public:
|
|||||||
}
|
}
|
||||||
FlushIfCan(m_device);
|
FlushIfCan(m_device);
|
||||||
}
|
}
|
||||||
|
void Close() {
|
||||||
|
m_device->close();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// QTextStream doesn't flush QTcpSocket, and QIODevice doesn't have flush() at all...
|
// QTextStream doesn't flush QTcpSocket, and QIODevice doesn't have flush() at all...
|
||||||
@@ -125,7 +129,7 @@ void WriteConfig(QString path) {
|
|||||||
p.ReadUntil("Server uses SSL?");Z; p.Write();
|
p.ReadUntil("Server uses SSL?");Z; p.Write();
|
||||||
p.ReadUntil("6667");Z; p.Write();
|
p.ReadUntil("6667");Z; p.Write();
|
||||||
p.ReadUntil("password");Z; p.Write();
|
p.ReadUntil("password");Z; p.Write();
|
||||||
p.ReadUntil("channels");Z; p.Write("#znc");
|
p.ReadUntil("channels");Z; p.Write();
|
||||||
p.ReadUntil("Launch ZNC now?");Z; p.Write("no");
|
p.ReadUntil("Launch ZNC now?");Z; p.Write("no");
|
||||||
p.ShouldFinishItself();
|
p.ShouldFinishItself();
|
||||||
}
|
}
|
||||||
@@ -161,6 +165,14 @@ protected:
|
|||||||
return std::unique_ptr<Process>(new Process("./znc", QStringList() << "--debug" << "--datadir" << m_dir.path(), false));
|
return std::unique_ptr<Process>(new Process("./znc", QStringList() << "--debug" << "--datadir" << m_dir.path(), false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IO<QTcpSocket> LoginClient() {
|
||||||
|
auto client = ConnectClient();
|
||||||
|
client.Write("PASS :hunter2");
|
||||||
|
client.Write("NICK nick");
|
||||||
|
client.Write("USER user/test x x :x");
|
||||||
|
return client;
|
||||||
|
}
|
||||||
|
|
||||||
QTemporaryDir m_dir;
|
QTemporaryDir m_dir;
|
||||||
QTcpServer m_server;
|
QTcpServer m_server;
|
||||||
std::list<QTcpSocket> m_clients;
|
std::list<QTcpSocket> m_clients;
|
||||||
@@ -177,6 +189,32 @@ TEST_F(ZNCTest, Connect) {
|
|||||||
client.Write("NICK nick");
|
client.Write("NICK nick");
|
||||||
client.Write("USER user/test x x :x");
|
client.Write("USER user/test x x :x");
|
||||||
client.ReadUntil("Welcome");Z;
|
client.ReadUntil("Welcome");Z;
|
||||||
|
client.Close();
|
||||||
|
|
||||||
|
client = ConnectClient();Z;
|
||||||
|
client.Write("PASS :user:hunter2");
|
||||||
|
client.Write("NICK nick");
|
||||||
|
client.Write("USER u x x x");
|
||||||
|
client.ReadUntil("Welcome");Z;
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(ZNCTest, Channel) {
|
||||||
|
auto znc = Run();Z;
|
||||||
|
auto ircd = ConnectIRCd();Z;
|
||||||
|
|
||||||
|
auto client = LoginClient();Z;
|
||||||
|
client.ReadUntil("Welcome");Z;
|
||||||
|
client.Write("JOIN #znc");
|
||||||
|
client.Close();
|
||||||
|
|
||||||
|
ircd.Write(":server 001 nick :Hello");
|
||||||
|
ircd.ReadUntil("JOIN #znc");Z;
|
||||||
|
ircd.Write(":nick JOIN #znc nick :Real");
|
||||||
|
ircd.Write(":server 353 nick #znc :nick");
|
||||||
|
ircd.Write(":server 366 nick #znc :End of /NAMES list");
|
||||||
|
|
||||||
|
client = LoginClient();Z;
|
||||||
|
client.ReadUntil(":nick JOIN :#znc");Z;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
Reference in new issue
Block a user