202
203
webServerData.setClientId("104660106251471");
203
204
webServerData.setClientSecret("fa28f40b5a1f8c1d5628963d880636fbkjkjkj");
204
205
webServerData.setRedirectUri("http://localhost/connect/login_success.html");
206
webServerData.setScope(QStringList() << "scope1" << "scope2");
206
208
//try without params
207
209
m_testPlugin->process(webServerData, QString("web_server"));
243
245
tokens.insert( webServerData.ClientId(), QVariant::fromValue(token));
244
246
webServerData.m_data.insert(QLatin1String("Tokens"), tokens);
248
/* try with missing cached scopes */
249
m_testPlugin->process(webServerData, QString("web_server"));
251
resp = m_response.data<OAuth2PluginTokenData>();
252
QVERIFY(resp.AccessToken() != QLatin1String("tokenfromtest"));
253
QCOMPARE(m_error.type(), int(Error::MissingData));
255
/* try with incomplete cached scopes */
256
token.insert("Scopes", QStringList("scope2"));
257
tokens.insert(webServerData.ClientId(), QVariant::fromValue(token));
258
webServerData.m_data.insert(QLatin1String("Tokens"), tokens);
259
m_testPlugin->process(webServerData, QString("web_server"));
261
resp = m_response.data<OAuth2PluginTokenData>();
262
QVERIFY(resp.AccessToken() != QLatin1String("tokenfromtest"));
263
QCOMPARE(m_error.type(), int(Error::MissingData));
265
/* try with sufficient cached scopes */
266
token.insert("Scopes",
267
QStringList() << "scope1" << "scope3" << "scope2");
268
tokens.insert(webServerData.ClientId(), QVariant::fromValue(token));
269
webServerData.m_data.insert(QLatin1String("Tokens"), tokens);
246
270
m_testPlugin->process(webServerData, QString("web_server"));
248
272
resp = m_response.data<OAuth2PluginTokenData>();
264
288
data.setClientId("104660106251471");
265
289
data.setClientSecret("fa28f40b5a1f8c1d5628963d880636fbkjkjkj");
266
290
data.setRedirectUri("http://localhost/connect/login_success.html");
291
QStringList scopes = QStringList() << "scope1" << "scope2";
292
data.setScope(scopes);
268
294
QObject::connect(m_testPlugin, SIGNAL(result(const SignOn::SessionData&)),
269
295
this, SLOT(result(const SignOn::SessionData&)),Qt::QueuedConnection);
271
297
this, SLOT(pluginError(const SignOn::Error &)),Qt::QueuedConnection);
272
298
QObject::connect(m_testPlugin, SIGNAL(userActionRequired(const SignOn::UiSessionData&)),
273
299
this, SLOT(uiRequest(const SignOn::UiSessionData&)),Qt::QueuedConnection);
300
QObject::connect(m_testPlugin, SIGNAL(store(const SignOn::SessionData&)),
301
this, SLOT(store(const SignOn::SessionData&)),
302
Qt::QueuedConnection);
274
303
QTimer::singleShot(10*1000, &m_loop, SLOT(quit()));
276
305
m_testPlugin->process(data, QString("user_agent"));
302
331
OAuth2PluginTokenData *result = (OAuth2PluginTokenData*)&m_response;
303
332
QCOMPARE(result->AccessToken(), QString("testtoken."));
304
333
QCOMPARE(result->ExpiresIn(), 4776);
334
QVariantMap storedTokenData = m_stored.data<OAuth2TokenData>().Tokens();
335
QVariantMap storedClientData =
336
storedTokenData.value(data.ClientId()).toMap();
337
QVERIFY(!storedClientData.isEmpty());
338
QCOMPARE(storedClientData["Scopes"].toStringList(), scopes);
307
341
info.setUrlResponse(QString("http://www.facebook.com/connect/login_success.html#access_token=testtoken."));