1 /******************************************************************************
2 
3  This source file is part of the MoleQueue project.
4 
5  Copyright 2012 Kitware, Inc.
6 
7  This source code is released under the New BSD License, (the "License").
8 
9  Unless required by applicable law or agreed to in writing, software
10  distributed under the License is distributed on an "AS IS" BASIS,
11  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  See the License for the specific language governing permissions and
13  limitations under the License.
14 
15  ******************************************************************************/
16 
17 #include <QtTest>
18 #include <QtXmlPatterns/QXmlQuery>
19 
20 #include "queues/uit/authenticatecont.h"
21 #include "queues/uit/authenticateresponse.h"
22 #include "referencestring.h"
23 #include "xmlutils.h"
24 
25 class AuthenticateContTest : public QObject
26 {
27   Q_OBJECT
28 private slots:
29   void testToXmlNoReply();
30   void testToXmlWithReply();
31 };
32 
testToXmlNoReply()33 void AuthenticateContTest::testToXmlNoReply()
34 {
35   QList<MoleQueue::Uit::Prompt> prompts;
36   prompts << MoleQueue::Uit::Prompt(0, "prompt1");
37   prompts << MoleQueue::Uit::Prompt(1, "prompt2");
38 
39   QString id = "sessionId";
40 
41   MoleQueue::Uit::AuthenticateCont authCont(id, prompts);
42 
43   ReferenceString expected(
44     "authenticatecont-ref/authenticatecont-no-reply.xml");
45   QCOMPARE(authCont.toXml(), XmlUtils::stripWhitespace(expected));
46 
47 }
48 
testToXmlWithReply()49 void AuthenticateContTest::testToXmlWithReply()
50 {
51   QList<MoleQueue::Uit::Prompt> prompts;
52   MoleQueue::Uit::Prompt prompt1(0, "prompt1");
53   prompt1.setUserResponse("reply1");
54   MoleQueue::Uit::Prompt prompt2(1, "prompt2");
55   prompt2.setUserResponse("reply2");
56 
57   prompts << prompt1 << prompt2;
58 
59   QString id = "sessionId";
60 
61   MoleQueue::Uit::AuthenticateCont authCont(id, prompts);
62 
63   ReferenceString expected(
64     "authenticatecont-ref/authenticatecont-reply.xml");
65   QCOMPARE(authCont.toXml(), XmlUtils::stripWhitespace(expected));
66 
67 }
68 
69 QTEST_MAIN(AuthenticateContTest)
70 
71 #include "authenticateconttest.moc"
72