online-accounts-api-0.1+16.04.20160212/ 0000755 0000156 0000165 00000000000 12657307121 017564 5 ustar pbuser pbgroup 0000000 0000000 online-accounts-api-0.1+16.04.20160212/doc/ 0000755 0000156 0000165 00000000000 12657307121 020331 5 ustar pbuser pbgroup 0000000 0000000 online-accounts-api-0.1+16.04.20160212/doc/ubuntu-onlineaccounts2.qdocconf 0000644 0000156 0000165 00000001303 12657306726 026504 0 ustar pbuser pbgroup 0000000 0000000 project = UbuntuOnlineAccounts2
description = Ubuntu.OnlineAccounts 2.0 module documentation
sourcedirs = ./ ../src/lib/Ubuntu/OnlineAccounts.2/
sources.fileextensions = "*.qdoc *.cpp"
outputdir = html
outputformats = HTML
version = 0.2
syntaxhightlighting = true
sourceencoding = UTF-8
outputencoding = UTF-8
HTML.nonavigationbar = "true"
HTML.stylesheets = \
css/base.css \
css/qtquick.css \
css/reset.css \
css/scratch.css
HTML.headerstyles = \
"\n" \
"\n" \
"\n"
online-accounts-api-0.1+16.04.20160212/doc/css/ 0000755 0000156 0000165 00000000000 12657307121 021121 5 ustar pbuser pbgroup 0000000 0000000 online-accounts-api-0.1+16.04.20160212/doc/css/base.css 0000644 0000156 0000165 00000027076 12657306726 022573 0 ustar pbuser pbgroup 0000000 0000000 /**
* Ubuntu Developer base stylesheet
*
* A base stylesheet containing site-wide styles
*
* @project Ubuntu Developer
* @version 1.0
* @author Canonical Web Team: Steve Edwards
* @copyright 2011 Canonical Ltd.
*/
/**
* @section Global
*/
body {
font-family: 'Ubuntu', 'Ubuntu Beta', UbuntuBeta, Ubuntu, 'Bitstream Vera Sans', 'DejaVu Sans', Tahoma, sans-serif;
font-size: 13px;
line-height: 1.4;
color: #333;
}
a {
color: #dd4814;
text-decoration: none;
outline: 0;
}
p, dl {
margin-bottom: 10px;
}
strong {
font-weight: bold;
}
em {
font-style: italic;
}
code{
padding: 10px;
font-family: 'Ubuntu Mono', 'Consolas', 'Monaco', 'DejaVu Sans Mono', Courier, monospace;
background-color: #fdf6f2;
display: inline-block;
margin-bottom: 10px;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
}
h1 {
font-size: 36px;
line-height: 1.1;
margin-bottom: 20px;
}
article h1,
h2 {
font-size: 24px;
line-height: 1.2;
margin-bottom: 14px;
}
h3 {
font-size: 16px;
line-height: 1.3;
margin-bottom: 8px;
}
h4 {
font-weight: bold;
}
time {
color:#999;
}
/**
* @section Structure
*/
.header-login,
.header-navigation div,
.header-content div {
margin: 0 auto;
width: 940px;
}
.header-content h1{
background-color:#ffffff;
display:inline-block;
}
.header-content h2{
background-color:#ffffff;
display:table;
}
.header-login ul {
margin: 4px 0;
float: right;
}
.header-login li {
margin-right: 10px;
float: left;
}
.header-login a {
color: #333;
}
.header-navigation {
border-top: 2px solid #dd4814;
border-bottom: 2px solid #dd4814;
background-color: #fff;
height: 54px;
clear: right;
overflow: hidden;
}
.header-navigation nav ul {
border-right: 1px solid #dd4814;
float: right;
}
.header-navigation nav li {
border-left: 1px solid #dd4814;
float: left;
height: 54px;
}
.header-navigation nav a {
padding: 18px 14px 0;
font-size: 14px;
display: block;
height: 36px;
}
.header-navigation nav a:hover {
background-color: #fcece7;
}
.header-navigation nav .current_page_item a,
.header-navigation nav .current_page_parent a,
.header-navigation nav .current_page_ancestor a {
background-color: #dd4814;
color: #fff;
}
.header-navigation input {
margin: 12px 10px 0 10px;
padding: 5px;
border-top: 1px solid #a1a1a1;
border-right: 1px solid #e0e0e0;
border-bottom: 1px solid #fff;
border-left: 1px solid #e0e0e0;
width: 90px;
font-style: italic;
color: #ccc;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
-moz-box-shadow: inset 0 1px 1px #e0e0e0;
-webkit-box-shadow: inset 0 1px 1px #e0e0e0;
box-shadow: inset 0 1px 1px #e0e0e0;
}
.header-navigation h2 {
margin: 18px 0 0 6px;
text-transform: lowercase;
font-size: 22px;
color: #dd4814;
float: left;
}
.header-navigation .logo-ubuntu {
margin-top: 12px;
float: left;
}
.header-content .header-navigation-secondary {
margin-bottom: 40px;
padding: 0;
position: relative;
z-index: 2;
}
.header-navigation-secondary div {
padding: 0;
border: 2px solid #dd4814;
-moz-border-radius: 0px 0px 4px 4px;
-webkit-border-radius: 0px 0px 4px 4px;
border-radius: 0px 0px 4px 4px;
background: #fff;
border-top: 0px;
width: 936px;
}
.header-navigation-secondary nav li {
float: left;
}
.header-navigation-secondary nav li a {
color: #333;
display: block;
height: 25px;
padding: 8px 8px 0;
}
.header-navigation-secondary nav li:hover,
.header-navigation-secondary nav .current_page_item a {
background: url("../img/sec-nav-hover.gif");
}
.header-content {
padding-bottom: 30px;
border-bottom: 1px solid #e0e0e0;
-moz-box-shadow: 0 1px 3px #e0e0e0;
-webkit-box-shadow: 0 1px 3px #e0e0e0;
box-shadow: 0 1px 3px #e0e0e0;
margin-bottom: 3px;
position: relative;
overflow: hidden;
}
footer {
padding: 10px 10px 40px 10px;
position: relative;
-moz-border-radius: 0 0 4px 4px;
-webkit-border-radius: 0 0 4px 4px;
border-radius: 0 0 4px 4px;
font-size: 12px;
background: url("../img/background-footer.png") repeat scroll 0 0 #f7f6f5;
}
footer div {
margin: 0 auto;
padding: 0 10px;
width: 940px;
}
footer a {
color: #000;
}
footer nav ul {
margin: 10px 17px 30px 0;
width: 172px;
display: inline-block;
vertical-align: top;
height: auto;
zoom: 1;
*display: inline;
}
footer nav ul.last {
margin-right: 0;
}
footer nav li {
margin-bottom: 8px;
}
footer nav li:first-child {
font-weight: bold;
}
footer p {
margin-bottom: 0;
}
#content {
padding-top: 35px;
}
.arrow-nav {
display: none;
position: absolute;
top: -1px;
z-index: 3;
}
.shadow {
margin: 30px 0 3px 0;
border-bottom: 1px solid #e0e0e0;
-moz-box-shadow: 0 2px 3px #e0e0e0;
-webkit-box-shadow: 0 2px 3px #e0e0e0;
box-shadow: 0 2px 3px #e0e0e0;
height: 3px;
}
/**
* @section Site-wide
*/
#content h2{
font-size:24px;
}
.box-orange {
padding: 10px;
border: 3px solid #dd4814;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
}
.box-orange .link-action-small {
float: right;
margin: 0 0 0 20px;
}
.link-bug {
margin-left: 10px;
color: #999;
}
.link-action {
float: left;
margin-bottom: 20px;
padding: 8px 12px;
display: block;
background-color: #dd4814;
color: #fff;
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
border-radius: 20px;
font-size: 16px;
line-height: 1.3;
border-top: 3px solid #e6633a;
border-bottom: 3px solid #c03d14;
}
.link-action2 {
float: left;
display: block;
color: #fff;
font-size: 16px;
line-height: 1.3;
}
.link-action2 span{
display:block;
float:left;
}
.link-action2 .cta-left{
background:url(../img/button-cta-left.png) no-repeat;
width:22px;
height:48px;
}
.link-action2 .cta-center{
background:url(../img/button-cta-slice.png) repeat-x;
line-height:45px;
height:48px;
}
.link-action2 .cta-right{
background:url(../img/button-cta-right.png) no-repeat;
width:22px;
height:48px;
}
.link-action-small {
float: left;
display: block;
color: #fff;
font-size: 16px;
}
.link-action-small span{
display:block;
float:left;
height:42px;
}
.link-action-small .cta-left{
background:url(../img/button-cta-left-small.png) no-repeat;
width:19px;
}
.link-action-small .cta-center{
background:url(../img/button-cta-slice-small.png) repeat-x;
line-height:42px;
}
.link-action-small .cta-right{
background:url(../img/button-cta-right-small.png) no-repeat;
width:19px;
}
.link-action:active {
position: relative;
top: 1px;
}
.link-action2:active {
position: relative;
top: 1px;
}
.link-action-small:active {
position: relative;
top: 1px;
}
.list-bullets li {
margin-bottom: 10px;
list-style: disc;
list-style-position: inside;
}
.box {
margin-bottom: 30px;
padding: 15px;
border: 1px solid #aea79f;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
}
.box-padded {
margin-bottom: 30px;
padding: 5px;
border: 2px solid #aea79f;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
background: url("../img/pattern-featured.gif") repeat scroll 0 0 #ebe9e7;
overflow: hidden;
}
.box-padded h3 {
margin: 5px 0 10px 5px;
}
.box-padded div {
padding: 10px;
border: 1px solid #aea79f;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
background-color: #fff;
overflow: hidden;
}
.box-padded li {
padding: 0 10px;
float: left;
width: 211px;
border-right: 1px dotted #aea79f;
}
.box-padded li.first {
padding: 0;
margin-bottom: 0;
}
.box-padded li.last {
border: 0;
width: 217px;
}
.box-padded img {
margin: 0 10px 50px 0;
float: left;
-moz-border-radius: 8px;
-webkit-border-radius: 8px;
border-radius: 8px;
}
.box-clear {
margin-bottom: 40px;
}
.box-clear .grid-4.first {
margin-right: 15px;
padding-right: 15px;
}
.box-clear .grid-4 {
margin-left: 0;
margin-right: 10px;
padding-right: 10px;
width: 298px;
}
.box-clear time {
display: block;
border-bottom: 1px dotted #aea79f;
padding-bottom: 10px;
margin-bottom: 10px;
}
.box-clear div.first {
border-right: 1px dotted #aea79f;
}
.box-clear a {
display: block;
}
.box-clear .rss {
background: url("../img/rss.jpg") no-repeat scroll 0 center;
padding-left: 20px;
}
.box-clear .location {
display: block;
margin-bottom: 1px;
}
.box-clear .last {
margin: 0;
padding-right: 0;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
width: 293px;
}
/* Widgets */
.ui-state-focus {
outline: none;
}
.ui-accordion {
border-bottom: 1px dotted #aea79f;
}
.ui-accordion a {
display: block;
}
.ui-accordion h3 {
margin-bottom: 0;
border-top: 1px dotted #aea79f;
position: relative;
font-size: 13px;
font-weight: bold;
}
.ui-accordion h3 a {
padding: 10px 0;
color: #333;
}
.ui-accordion h4 {
margin-bottom: 5px;
}
.ui-accordion div fieldset {
padding-bottom: 5px;
}
.ui-accordion div li,
.ui-accordion div input {
margin-bottom: 10px;
}
.ui-accordion .ui-icon {
position: absolute;
top: 15px;
right: 0;
display: block;
width: 8px;
height: 8px;
background: url("../img/icon-accordion-inactive.png") 0 0 no-repeat transparent;
}
.ui-accordion .ui-state-active .ui-icon {
background-image: url("../img/icon-accordion-active.png");
}
.ui-accordion .current_page_item a {
color: #333;
}
.container-tweet {
-moz-border-radius: 4px 4px 4px 4px;
-webkit-border-radius: 4px 4px 4px 4px;
border-radius: 4px 4px 4px 4px;
padding: 10px 10px 10px;
background-color: #f7f7f7;
}
.container-tweet .tweet-follow {
margin-top: 10px;
margin-bottom: -10px;
padding-left: 55px;
padding-bottom: 6px;
background: url("../img/tweet-follow.png") 0 5px no-repeat;
display: block;
}
.container-tweet .tweet-follow span {
font-size: 16px;
font-weight: bold;
line-height: 1.2;
display: block;
}
.tweet a {
display: inline;
}
.tweet .tweet_text {
padding: 10px;
background-color: #fff;
-moz-border-radius: 4px 4px 4px 4px;
-webkit-border-radius: 4px 4px 4px 4px;
border-radius: 4px 4px 4px 4px;
border: 1px solid #dd4814;
font-size: 16px;
display: block;
clear: both;
}
.tweet.tweet-small .tweet_text {
font-size: inherit;
}
.tweet .tweet_text a {
color: #333;
}
.tweet .tweet_time,
.tweet .tweet_user_and_time {
padding: 15px 0 10px 0;
position: relative;
top: -2px;
background: url("../img/tweet-arrow.png") no-repeat;
display: block;
}
.tweet .tweet_odd .tweet_time,
.tweet .tweet_odd .tweet_user_and_time {
background-position: right 0;
float: right;
}
.tweet .tweet_even .tweet_time,
.tweet .tweet_even .tweet_user_and_time {
background-position: left 0;
float: left;
}
/* Search */
#content .list-search li {
list-style-type:none;
border:0px;
margin-bottom: 15px;
padding-top: 15px;
}
/* Blog */
.blog-article #nav-single {
margin-top: 30px;
margin-bottom: 30px;
}
.blog-article #nav-single .nav-next {
float: right;
}
.blog-article article header .entry-meta {
margin-bottom: 20px;
}
.blog-article article .entry-meta {
color: #999;
}
.blog-article #respond form input[type="submit"] {
float: left;
cursor: pointer;
margin-bottom: 20px;
padding: 8px 12px;
display: block;
background-color: #dd4814;
color: #fff;
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
border-radius: 20px;
font-size: 16px;
line-height: 1.3;
border-top: 3px solid #e6633a;
border-left: 3px solid #e6633a;
border-right: 3px solid #e6633a;
border-bottom: 3px solid #c03d14;
}
.blog-article #respond form input[type="submit"]:active {
position: relative;
top: 1px;
}
.alignnone{
float:left;
margin:10px 20px 10px 0;
}
.alignleft{
float:left;
margin:10px 20px 10px 0;
}
.alignright{
float:right;
margin:10px 0 10px 20px;
}
.aligncenter{
float:left;
margin:10px 20px 10px 0;
}
.entry-content h2, .entry-content h3{
margin-top:20px;
}
.entry-content ul li{
list-style-type: circle;
margin-left:16px;
}
.entry-content hr{
border:none;
border-top: 1px dotted #AEA79F;
}
online-accounts-api-0.1+16.04.20160212/doc/css/scratch.css 0000644 0000156 0000165 00000003506 12657306726 023300 0 ustar pbuser pbgroup 0000000 0000000 /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
body {
margin: 0;
}
div.toc ul {
padding: 0;
}
div.toc li {
margin-bottom: 3px;
}
h1.title {
font-size: 36px;
line-height: 1.1;
font-weight: normal;
}
h0, h2 {
font-size: 24px;
line-height: 1.2;
margin: 14px 0;
font-weight: normal;
display: block;
}
a:hover {
color: #dd4814;
text-decoration: underline;
outline: 0;
}
table, pre {
border-radius: 0;
white-space: pre-wrap;
}
.annotated td {
padding: 0.8em 1em 0.3em;
}
.wrapper {
width: 940px;
margin: 0 auto;
}
.main-content {
width: 668px;
position: relative;
left: 270px;
}
.title {
margin-left: -270px;
margin-top: 30px;
margin-bottom: 50px;
}
.toc {
margin-left: -270px;
font-size: 100%;
margin-bottom: 40px;
padding: 0;
z-index: 2;
position: absolute;
top: 100px;
width: 250px;
}
.breadcrumb {
position: relative;
left: -270px;
top: 30px;
width: auto;
padding-bottom: 30px;
margin-bottom: 30px;
float:left;
}
.breadcrumb li {
float: left;
margin-right: 8px;
}
.breadcrumb a:link,
.breadcrumb a:visited {
color: #AEA79F;
}
.breadcrumb a:after {
content: '\0000a0\0000a0 >';
}
.title {
margin-top: 50px;
clear:both;
}
.breadcrumb + .toc {
top: 170px;
}
.breadcrumb p {
display: inline;
}
online-accounts-api-0.1+16.04.20160212/doc/css/custom.css 0000644 0000156 0000165 00000000164 12657306726 023160 0 ustar pbuser pbgroup 0000000 0000000 li#buildversion {
display: none;
}
div.toc {
display: none;
}
span.type a:visited {
color: #dd4814;
}
online-accounts-api-0.1+16.04.20160212/doc/css/breadcrumbs.js 0000644 0000156 0000165 00000001416 12657306726 023764 0 ustar pbuser pbgroup 0000000 0000000 /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
$(document).ready(function(){
var ul = $("ul.breadcrumb");
var li = ul.children("li:has(a)").remove();
ul.prepend(li);
});
online-accounts-api-0.1+16.04.20160212/doc/css/reset.css 0000644 0000156 0000165 00000001533 12657306726 022771 0 ustar pbuser pbgroup 0000000 0000000 /*
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.com/yui/license.html
version: 3.3.0
build: 3167
*/
html{color:#000;background:#FFF;}body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}li{list-style:none;}caption,th{text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}q:before,q:after{content:'';}abbr,acronym{border:0;font-variant:normal;}sup{vertical-align:text-top;}sub{vertical-align:text-bottom;}input,textarea,select{font-family:inherit;font-size:inherit;font-weight:inherit;}input,textarea,select{*font-size:100%;}legend{color:#000;} online-accounts-api-0.1+16.04.20160212/doc/css/qtquick.css 0000644 0000156 0000165 00000033160 12657306726 023331 0 ustar pbuser pbgroup 0000000 0000000 /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
@media screen
{
/* basic elements */
html
{
color: #000000;
background: #FFFFFF;
}
table
{
border-collapse: collapse;
border-spacing: 0;
}
fieldset, img
{
border: 0;
max-width:100%;
}
address, caption, cite, code, dfn, em, strong, th, var, optgroup
{
font-style: inherit;
font-weight: inherit;
}
del, ins
{
text-decoration: none;
}
ol li
{
list-style: decimal;
}
ul li
{
list-style: none;
}
caption, th
{
text-align: left;
}
h1.title
{
font-weight: bold;
font-size: 150%;
}
h0
{
font-weight: bold;
font-size: 130%;
}
h1, h2, h3, h4, h5, h6
{
font-size: 100%;
}
q:before, q:after
{
content: '';
}
abbr, acronym
{
border: 0;
font-variant: normal;
}
sup, sub
{
vertical-align: baseline;
}
tt, .qmlreadonly span, .qmldefault span
{
word-spacing:0.5em;
}
legend
{
color: #000000;
}
strong
{
font-weight: bold;
}
em
{
font-style: italic;
}
body
{
margin: 0 1.5em 0 1.5em;
font-family: ubuntu;
line-height: normal
}
a
{
color: #00732F;
text-decoration: none;
}
hr
{
background-color: #E6E6E6;
border: 1px solid #E6E6E6;
height: 1px;
width: 100%;
text-align: left;
margin: 1.5em 0 1.5em 0;
}
pre
{
border: 1px solid #DDDDDD;
-moz-border-radius: 0.7em 0.7em 0.7em 0.7em;
-webkit-border-radius: 0.7em 0.7em 0.7em 0.7em;
border-radius: 0.7em 0.7em 0.7em 0.7em;
padding: 1em 1em 1em 1em;
overflow-x: auto;
}
table, pre
{
-moz-border-radius: 0.7em 0.7em 0.7em 0.7em;
-webkit-border-radius: 0.7em 0.7em 0.7em 0.7em;
border-radius: 0.7em 0.7em 0.7em 0.7em;
background-color: #F6F6F6;
border: 1px solid #E6E6E6;
border-collapse: separate;
margin-bottom: 2.5em;
}
pre {
font-size: 90%;
display: block;
overflow:hidden;
}
thead
{
margin-top: 0.5em;
font-weight: bold
}
th
{
padding: 0.5em 1.5em 0.5em 1em;
background-color: #E1E1E1;
border-left: 1px solid #E6E6E6;
}
td
{
padding: 0.25em 1.5em 0.25em 1em;
}
td.rightAlign
{
padding: 0.25em 0.5em 0.25em 1em;
}
table tr.odd
{
border-left: 1px solid #E6E6E6;
background-color: #F6F6F6;
color: black;
}
table tr.even
{
border-left: 1px solid #E6E6E6;
background-color: #ffffff;
color: #202020;
}
div.float-left
{
float: left; margin-right: 2em
}
div.float-right
{
float: right; margin-left: 2em
}
span.comment
{
color: #008B00;
}
span.string, span.char
{
color: #000084;
}
span.number
{
color: #a46200;
}
span.operator
{
color: #202020;
}
span.keyword
{
color: #840000;
}
span.name
{
color: black
}
span.type
{
font-weight: bold
}
span.type a:visited
{
color: #0F5300;
}
span.preprocessor
{
color: #404040
}
/* end basic elements */
/* font style elements */
.heading
{
font-weight: bold;
font-size: 125%;
}
.subtitle
{
font-size: 110%
}
.small-subtitle
{
font-size: 100%
}
.red
{
color:red;
}
/* end font style elements */
/* global settings*/
.header, .footer
{
display: block;
clear: both;
overflow: hidden;
}
/* end global settings*/
/* header elements */
.header .qtref
{
color: #00732F;
font-weight: bold;
font-size: 130%;
}
.header .content
{
margin-left: 5px;
margin-top: 5px;
margin-bottom: 0.5em;
}
.header .breadcrumb
{
font-size: 90%;
padding: 0.5em 0 0.5em 1em;
margin: 0;
background-color: #fafafa;
height: 1.35em;
border-bottom: 1px solid #d1d1d1;
}
.header .breadcrumb ul
{
margin: 0;
padding: 0;
}
.header .content
{
word-wrap: break-word;
}
.header .breadcrumb ul li
{
float: left;
background: url(../images/breadcrumb.png) no-repeat 0 3px;
padding-left: 1.5em;
margin-left: 1.5em;
}
.header .breadcrumb ul li.last
{
font-weight: normal;
}
.header .breadcrumb ul li a
{
color: #00732F;
}
.header .breadcrumb ul li.first
{
background-image: none;
padding-left: 0;
margin-left: 0;
}
.header .content ol li {
background: none;
margin-bottom: 1.0em;
margin-left: 1.2em;
padding-left: 0
}
.header .content li
{
background: url(../images/bullet_sq.png) no-repeat 0 5px;
margin-bottom: 1em;
padding-left: 1.2em;
}
/* end header elements */
/* content elements */
.content h1
{
font-weight: bold;
font-size: 130%
}
.content h2
{
font-weight: bold;
font-size: 120%;
width: 100%;
}
.content h3
{
font-weight: bold;
font-size: 110%;
width: 100%;
}
.content table p
{
margin: 0
}
.content ul
{
padding-left: 2.5em;
}
.content li
{
padding-top: 0.25em;
padding-bottom: 0.25em;
}
.content ul img {
vertical-align: middle;
}
.content a:visited
{
color: #4c0033;
text-decoration: none;
}
.content a:visited:hover
{
color: #4c0033;
text-decoration: underline;
}
a:hover
{
color: #4c0033;
text-decoration: underline;
}
descr p a
{
text-decoration: underline;
}
.descr p a:visited
{
text-decoration: underline;
}
.alphaChar{
width:95%;
background-color:#F6F6F6;
border:1px solid #E6E6E6;
-moz-border-radius: 7px 7px 7px 7px;
border-radius: 7px 7px 7px 7px;
-webkit-border-radius: 7px 7px 7px 7px;
font-size:12pt;
padding-left:10px;
margin-top:10px;
margin-bottom:10px;
}
.flowList{
/*vertical-align:top;*/
/*margin:20px auto;*/
column-count:3;
-webkit-column-count:3;
-moz-column-count:3;
/*
column-width:100%;
-webkit-column-width:200px;
-col-column-width:200px;
*/
column-gap:41px;
-webkit-column-gap:41px;
-moz-column-gap:41px;
column-rule: 1px dashed #ccc;
-webkit-column-rule: 1px dashed #ccc;
-moz-column-rule: 1px dashed #ccc;
}
.flowList dl{
}
.flowList dd{
/*display:inline-block;*/
margin-left:10px;
min-width:250px;
line-height: 1.5;
min-width:100%;
min-height:15px;
}
.flowList dd a{
}
.mainContent
{
padding-left:5px;
}
.content .flowList p{
padding:0px;
}
.content .alignedsummary
{
margin: 15px;
}
.qmltype
{
text-align: center;
font-size: 120%;
}
.qmlreadonly
{
padding-left: 5px;
float: right;
color: #254117;
}
.qmldefault
{
padding-left: 5px;
float: right;
color: red;
}
.qmldoc
{
}
.generic .alphaChar{
margin-top:5px;
}
.generic .odd .alphaChar{
background-color: #F6F6F6;
}
.generic .even .alphaChar{
background-color: #FFFFFF;
}
.memItemRight{
padding: 0.25em 1.5em 0.25em 0;
}
.highlightedCode
{
margin: 1.0em;
}
.annotated td {
padding: 0.25em 0.5em 0.25em 0.5em;
}
.toc
{
font-size: 80%
}
.header .content .toc ul
{
padding-left: 0px;
}
.content .toc h3 {
border-bottom: 0px;
margin-top: 0px;
}
.content .toc h3 a:hover {
color: #00732F;
text-decoration: none;
}
.content .toc .level2
{
margin-left: 1.5em;
}
.content .toc .level3
{
margin-left: 3.0em;
}
.content ul li
{
background: url(../images/bullet_sq.png) no-repeat 0 0.7em;
padding-left: 1em
}
.content .toc li
{
background: url(../images/bullet_dn.png) no-repeat 0 5px;
padding-left: 1em
}
.relpage
{
-moz-border-radius: 7px 7px 7px 7px;
-webkit-border-radius: 7px 7px 7px 7px;
border-radius: 7px 7px 7px 7px;
border: 1px solid #DDDDDD;
padding: 25px 25px;
clear: both;
}
.relpage ul
{
float: none;
padding: 1.5em;
}
h3.fn, span.fn
{
-moz-border-radius:7px 7px 7px 7px;
-webkit-border-radius:7px 7px 7px 7px;
border-radius:7px 7px 7px 7px;
background-color: #F6F6F6;
border-width: 1px;
border-style: solid;
border-color: #E6E6E6;
font-weight: bold;
word-spacing:3px;
padding:3px 5px;
}
.functionIndex {
font-size:12pt;
word-spacing:10px;
margin-bottom:10px;
background-color: #F6F6F6;
border-width: 1px;
border-style: solid;
border-color: #E6E6E6;
-moz-border-radius: 7px 7px 7px 7px;
-webkit-border-radius: 7px 7px 7px 7px;
border-radius: 7px 7px 7px 7px;
width:100%;
}
.centerAlign
{
text-align:center;
}
.rightAlign
{
text-align:right;
}
.leftAlign
{
text-align:left;
}
.topAlign{
vertical-align:top
}
.functionIndex a{
display:inline-block;
}
/* end content elements */
/* footer elements */
.footer
{
color: #393735;
font-size: 0.75em;
text-align: center;
padding-top: 1.5em;
padding-bottom: 1em;
background-color: #E6E7E8;
margin: 0;
}
.footer p
{
margin: 0.25em
}
.small
{
font-size: 0.5em;
}
/* end footer elements */
.item {
float: left;
position: relative;
width: 100%;
overflow: hidden;
}
.item .primary {
margin-right: 220px;
position: relative;
}
.item hr {
margin-left: -220px;
}
.item .secondary {
float: right;
width: 200px;
position: relative;
}
.item .cols {
clear: both;
display: block;
}
.item .cols .col {
float: left;
margin-left: 1.5%;
}
.item .cols .col.first {
margin-left: 0;
}
.item .cols.two .col {
width: 45%;
}
.item .box {
margin: 0 0 10px 0;
}
.item .box h3 {
margin: 0 0 10px 0;
}
.cols.unclear {
clear:none;
}
}
/* end of screen media */
/* start of print media */
@media print
{
input, textarea, .header, .footer, .toolbar, .feedback, .wrapper .hd, .wrapper .bd .sidebar, .wrapper .ft, #feedbackBox, #blurpage, .toc, .breadcrumb, .toolbar, .floatingResult
{
display: none;
background: none;
}
.content
{
background: none;
display: block;
width: 100%; margin: 0; float: none;
}
}
/* end of print media */
/* modify the TOC layouts */
div.toc ul {
padding-left: 20px;
}
div.toc li {
padding-left: 4px;
}
/* Remove the border around images*/
a img
{
border:none;
}
/*Add styling to the front pages*/
.threecolumn_area
{
padding-top: 20px;
padding-bottom: 20px;
}
.threecolumn_piece
{
display: inline-block;
margin-left: 78px;
margin-top: 8px;
padding: 0;
vertical-align: top;
width: 25.5%;
}
div.threecolumn_piece ul {
list-style-type: none;
padding-left: 0px;
margin-top: 2px;
}
div.threecolumn_piece p {
margin-bottom: 7px;
color: #5C626E;
text-decoration: none;
font-weight: bold;
}
div.threecolumn_piece li {
padding-left: 0px;
margin-bottom: 5px;
}
div.threecolumn_piece a {
font-weight: normal;
}
/* Add style to guide page*/
.fourcolumn_area
{
padding-top: 20px;
padding-bottom: 20px;
}
.fourcolumn_piece
{
display: inline-block;
margin-left: 35px;
margin-top: 8px;
padding: 0;
vertical-align: top;
width: 21.3%;
}
div.fourcolumn_piece ul {
list-style-type: none;
padding-left: 0px;
margin-top: 2px;
}
div.fourcolumn_piece p {
margin-bottom: 7px;
color: #40444D;
text-decoration: none;
font-weight: bold;
}
div.fourcolumn_piece li {
padding-left: 0px;
margin-bottom: 5px;
}
div.fourcolumn_piece a {
font-weight: normal;
}
online-accounts-api-0.1+16.04.20160212/doc/CMakeLists.txt 0000644 0000156 0000165 00000001067 12657306726 023107 0 ustar pbuser pbgroup 0000000 0000000 project(OnlineAccountsQML-doc)
find_program(QDOC_EXECUTABLE qdoc)
if(QDOC_EXECUTABLE STREQUAL "QDOC_EXECUTABLE-NOTFOUND")
message(WARNING "qdoc not found, documentation cannot be built")
else()
add_custom_target(doc ALL
COMMAND ${QDOC_EXECUTABLE}
-outputdir ${CMAKE_CURRENT_BINARY_DIR}/html
${CMAKE_CURRENT_SOURCE_DIR}/ubuntu-onlineaccounts2.qdocconf)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html
DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/ubuntu-onlineaccounts2)
endif()
online-accounts-api-0.1+16.04.20160212/cmake/ 0000755 0000156 0000165 00000000000 12657307121 020644 5 ustar pbuser pbgroup 0000000 0000000 online-accounts-api-0.1+16.04.20160212/cmake/EnableCoverageReport.cmake 0000644 0000156 0000165 00000016414 12657306726 025724 0 ustar pbuser pbgroup 0000000 0000000 # - Creates a special coverage build type and target on GCC.
#
# Defines a function ENABLE_COVERAGE_REPORT which generates the coverage target
# for selected targets. Optional arguments to this function are used to filter
# unwanted results using globbing expressions. Moreover targets with tests for
# the source code can be specified to trigger regenerating the report if the
# test has changed
#
# ENABLE_COVERAGE_REPORT(TARGETS target... [FILTER filter...] [TESTS test targets...])
#
# To generate a coverage report first build the project with
# CMAKE_BUILD_TYPE=coverage, then call make test and afterwards make coverage.
#
# The coverage report is based on gcov. Depending on the availability of lcov
# a HTML report will be generated and/or an XML report of gcovr is found.
# The generated coverage target executes all found solutions. Special targets
# exist to create e.g. only the xml report: coverage-xml.
#
# Copyright (C) 2010 by Johannes Wienke
#
# This program is free software; you can redistribute it
# and/or modify it under the terms of the GNU General
# Public License as published by the Free Software Foundation;
# either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
INCLUDE(ParseArguments)
FIND_PACKAGE(Lcov)
FIND_PACKAGE(gcovr)
FUNCTION(ENABLE_COVERAGE_REPORT)
# argument parsing
PARSE_ARGUMENTS(ARG "FILTER;TARGETS;TESTS" "" ${ARGN})
SET(COVERAGE_RAW_FILE "${CMAKE_BINARY_DIR}/coverage.raw.info")
SET(COVERAGE_FILTERED_FILE "${CMAKE_BINARY_DIR}/coverage.info")
SET(COVERAGE_REPORT_DIR "${CMAKE_BINARY_DIR}/coveragereport")
SET(COVERAGE_XML_FILE "${CMAKE_BINARY_DIR}/coverage.xml")
SET(COVERAGE_XML_COMMAND_FILE "${CMAKE_BINARY_DIR}/coverage-xml.cmake")
# decide if there is any tool to create coverage data
SET(TOOL_FOUND FALSE)
IF(LCOV_FOUND OR GCOVR_FOUND)
SET(TOOL_FOUND TRUE)
ENDIF()
IF(NOT TOOL_FOUND)
MESSAGE(STATUS "Cannot enable coverage targets because neither lcov nor gcovr are found.")
ENDIF()
STRING(TOLOWER "${CMAKE_BUILD_TYPE}" COVERAGE_BUILD_TYPE)
IF(CMAKE_COMPILER_IS_GNUCXX AND TOOL_FOUND AND "${COVERAGE_BUILD_TYPE}" MATCHES "coverage")
MESSAGE(STATUS "Coverage support enabled for targets: ${ARG_TARGETS}")
# create coverage build type
SET(CMAKE_CXX_FLAGS_COVERAGE ${CMAKE_CXX_FLAGS_DEBUG} PARENT_SCOPE)
SET(CMAKE_C_FLAGS_COVERAGE ${CMAKE_C_FLAGS_DEBUG} PARENT_SCOPE)
SET(CMAKE_CONFIGURATION_TYPES ${CMAKE_CONFIGURATION_TYPES} coverage PARENT_SCOPE)
# instrument targets
SET_TARGET_PROPERTIES(${ARG_TARGETS} PROPERTIES COMPILE_FLAGS --coverage
LINK_FLAGS --coverage)
# html report
IF (LCOV_FOUND)
MESSAGE(STATUS "Enabling HTML coverage report")
# set up coverage target
ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_RAW_FILE}
COMMAND ${LCOV_EXECUTABLE} -c -d ${CMAKE_BINARY_DIR} -o ${COVERAGE_RAW_FILE}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Collecting coverage data"
DEPENDS ${ARG_TARGETS} ${ARG_TESTS}
VERBATIM)
# filter unwanted stuff
LIST(LENGTH ARG_FILTER FILTER_LENGTH)
IF(${FILTER_LENGTH} GREATER 0)
SET(FILTER COMMAND ${LCOV_EXECUTABLE})
FOREACH(F ${ARG_FILTER})
SET(FILTER ${FILTER} -r ${COVERAGE_FILTERED_FILE} ${F})
ENDFOREACH()
SET(FILTER ${FILTER} -o ${COVERAGE_FILTERED_FILE})
ELSE()
SET(FILTER "")
ENDIF()
ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_FILTERED_FILE}
COMMAND ${LCOV_EXECUTABLE} -e ${COVERAGE_RAW_FILE} "${CMAKE_SOURCE_DIR}*" -o ${COVERAGE_FILTERED_FILE}
${FILTER}
DEPENDS ${COVERAGE_RAW_FILE}
COMMENT "Filtering recorded coverage data for project-relevant entries"
VERBATIM)
ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_REPORT_DIR}
COMMAND ${CMAKE_COMMAND} -E make_directory ${COVERAGE_REPORT_DIR}
COMMAND ${GENHTML_EXECUTABLE} --legend --show-details -t "${PROJECT_NAME} test coverage" -o ${COVERAGE_REPORT_DIR} ${COVERAGE_FILTERED_FILE}
DEPENDS ${COVERAGE_FILTERED_FILE}
COMMENT "Generating HTML coverage report in ${COVERAGE_REPORT_DIR}"
VERBATIM)
ADD_CUSTOM_TARGET(coverage-html
DEPENDS ${COVERAGE_REPORT_DIR})
ENDIF()
# xml coverage report
IF(GCOVR_FOUND)
MESSAGE(STATUS "Enabling XML coverage report")
# filter unwanted stuff
SET(GCOV_FILTER "")
LIST(LENGTH ARG_FILTER FILTER_LENGTH)
IF(${FILTER_LENGTH} GREATER 0)
FOREACH(F ${ARG_FILTER})
SET(GCOV_FILTER "${GCOV_FILTER} -e \"${F}\"")
ENDFOREACH()
ENDIF()
# gcovr cannot write directly to a file so the execution needs to
# be wrapped in a cmake file that generates the file output
FILE(WRITE ${COVERAGE_XML_COMMAND_FILE}
"SET(ENV{LANG} en)\n")
FILE(APPEND ${COVERAGE_XML_COMMAND_FILE}
"EXECUTE_PROCESS(COMMAND \"${GCOVR_EXECUTABLE}\" -x -r \"${CMAKE_SOURCE_DIR}\" ${GCOV_FILTER} OUTPUT_FILE \"${COVERAGE_XML_FILE}\" WORKING_DIRECTORY \"${CMAKE_BINARY_DIR}\")\n")
ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_XML_FILE}
COMMAND ${CMAKE_COMMAND} ARGS -P ${COVERAGE_XML_COMMAND_FILE}
COMMENT "Generating coverage XML report"
VERBATIM)
ADD_CUSTOM_TARGET(coverage-xml
DEPENDS ${COVERAGE_XML_FILE})
ENDIF()
# provide a global coverage target executing both steps if available
SET(GLOBAL_DEPENDS "")
IF(LCOV_FOUND)
LIST(APPEND GLOBAL_DEPENDS ${COVERAGE_REPORT_DIR})
ENDIF()
IF(GCOVR_FOUND)
LIST(APPEND GLOBAL_DEPENDS ${COVERAGE_XML_FILE})
ENDIF()
IF(LCOV_FOUND OR GCOVR_FOUND)
ADD_CUSTOM_TARGET(coverage
DEPENDS ${GLOBAL_DEPENDS})
ENDIF()
ENDIF()
# This gets rid of any stale .gcda files. Run this if a running a binary causes lots of messages about
# about a "merge mismatch for summaries".
ADD_CUSTOM_TARGET(clean-coverage COMMAND find ${CMAKE_BINARY_DIR} -name '*.gcda' | xargs rm -f)
ENDFUNCTION()
online-accounts-api-0.1+16.04.20160212/cmake/Findgcovr.cmake 0000644 0000156 0000165 00000001702 12657306726 023601 0 ustar pbuser pbgroup 0000000 0000000 # - Find gcovr scrip
# Will define:
#
# GCOVR_EXECUTABLE - the gcovr script
#
# Uses:
#
# GCOVR_ROOT - root to search for the script
#
# Copyright (C) 2011 by Johannes Wienke
#
# This program is free software; you can redistribute it
# and/or modify it under the terms of the GNU General
# Public License as published by the Free Software Foundation;
# either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
INCLUDE(FindPackageHandleStandardArgs)
FIND_PROGRAM(GCOVR_EXECUTABLE gcovr HINTS ${GCOVR_ROOT} "${GCOVR_ROOT}/bin")
FIND_PACKAGE_HANDLE_STANDARD_ARGS(gcovr DEFAULT_MSG GCOVR_EXECUTABLE)
# only visible in advanced view
MARK_AS_ADVANCED(GCOVR_EXECUTABLE)
online-accounts-api-0.1+16.04.20160212/cmake/ParseArguments.cmake 0000644 0000156 0000165 00000003406 12657306726 024623 0 ustar pbuser pbgroup 0000000 0000000 # Parse arguments passed to a function into several lists separated by
# upper-case identifiers and options that do not have an associated list e.g.:
#
# SET(arguments
# hello OPTION3 world
# LIST3 foo bar
# OPTION2
# LIST1 fuz baz
# )
# PARSE_ARGUMENTS(ARG "LIST1;LIST2;LIST3" "OPTION1;OPTION2;OPTION3" ${arguments})
#
# results in 7 distinct variables:
# * ARG_DEFAULT_ARGS: hello;world
# * ARG_LIST1: fuz;baz
# * ARG_LIST2:
# * ARG_LIST3: foo;bar
# * ARG_OPTION1: FALSE
# * ARG_OPTION2: TRUE
# * ARG_OPTION3: TRUE
#
# taken from http://www.cmake.org/Wiki/CMakeMacroParseArguments
MACRO(PARSE_ARGUMENTS prefix arg_names option_names)
SET(DEFAULT_ARGS)
FOREACH(arg_name ${arg_names})
SET(${prefix}_${arg_name})
ENDFOREACH(arg_name)
FOREACH(option ${option_names})
SET(${prefix}_${option} FALSE)
ENDFOREACH(option)
SET(current_arg_name DEFAULT_ARGS)
SET(current_arg_list)
FOREACH(arg ${ARGN})
SET(larg_names ${arg_names})
LIST(FIND larg_names "${arg}" is_arg_name)
IF (is_arg_name GREATER -1)
SET(${prefix}_${current_arg_name} ${current_arg_list})
SET(current_arg_name ${arg})
SET(current_arg_list)
ELSE (is_arg_name GREATER -1)
SET(loption_names ${option_names})
LIST(FIND loption_names "${arg}" is_option)
IF (is_option GREATER -1)
SET(${prefix}_${arg} TRUE)
ELSE (is_option GREATER -1)
SET(current_arg_list ${current_arg_list} ${arg})
ENDIF (is_option GREATER -1)
ENDIF (is_arg_name GREATER -1)
ENDFOREACH(arg)
SET(${prefix}_${current_arg_name} ${current_arg_list})
ENDMACRO(PARSE_ARGUMENTS)
online-accounts-api-0.1+16.04.20160212/cmake/FindLcov.cmake 0000644 0000156 0000165 00000001720 12657306726 023364 0 ustar pbuser pbgroup 0000000 0000000 # - Find lcov
# Will define:
#
# LCOV_EXECUTABLE - the lcov binary
# GENHTML_EXECUTABLE - the genhtml executable
#
# Copyright (C) 2010 by Johannes Wienke
#
# This program is free software; you can redistribute it
# and/or modify it under the terms of the GNU General
# Public License as published by the Free Software Foundation;
# either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
INCLUDE(FindPackageHandleStandardArgs)
FIND_PROGRAM(LCOV_EXECUTABLE lcov)
FIND_PROGRAM(GENHTML_EXECUTABLE genhtml)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lcov DEFAULT_MSG LCOV_EXECUTABLE GENHTML_EXECUTABLE)
# only visible in advanced view
MARK_AS_ADVANCED(LCOV_EXECUTABLE GENHTML_EXECUTABLE)
online-accounts-api-0.1+16.04.20160212/tests/ 0000755 0000156 0000165 00000000000 12657307121 020726 5 ustar pbuser pbgroup 0000000 0000000 online-accounts-api-0.1+16.04.20160212/tests/daemon/ 0000755 0000156 0000165 00000000000 12657307121 022171 5 ustar pbuser pbgroup 0000000 0000000 online-accounts-api-0.1+16.04.20160212/tests/daemon/functional_tests/ 0000755 0000156 0000165 00000000000 12657307121 025555 5 ustar pbuser pbgroup 0000000 0000000 online-accounts-api-0.1+16.04.20160212/tests/daemon/functional_tests/fake_online_accounts_service.h 0000644 0000156 0000165 00000003404 12657306726 033632 0 ustar pbuser pbgroup 0000000 0000000 /*
* This file is part of libOnlineAccounts
*
* Copyright (C) 2015 Canonical Ltd.
*
* Contact: Alberto Mardegan
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef OAD_FAKE_ONLINE_ACCOUNTS_SERVICE_H
#define OAD_FAKE_ONLINE_ACCOUNTS_SERVICE_H
#include
#include
#include
class FakeOnlineAccountsService
{
public:
FakeOnlineAccountsService(QtDBusMock::DBusMock *mock): m_mock(mock) {
m_mock->registerTemplate("com.ubuntu.OnlineAccountsUi",
ONLINE_ACCOUNTS_SERVICE_MOCK_TEMPLATE,
QDBusConnection::SessionBus);
}
void setRequestAccessReply(const QVariantMap &reply) {
mocked().call("SetRequestAccessReply", reply);
}
private:
OrgFreedesktopDBusMockInterface &mocked() {
return m_mock->mockInterface("com.ubuntu.OnlineAccountsUi",
"/",
"com.ubuntu.OnlineAccountsUi",
QDBusConnection::SessionBus);
}
private:
QtDBusMock::DBusMock *m_mock;
};
#endif // OAD_FAKE_ONLINE_ACCOUNTS_SERVICE_H
online-accounts-api-0.1+16.04.20160212/tests/daemon/functional_tests/dbus_apparmor.py 0000644 0000156 0000165 00000002212 12657306726 030774 0 ustar pbuser pbgroup 0000000 0000000 '''D-Bus mock template for GetConnectionAppArmorSecurityContext
'''
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your option) any
# later version. See http://www.gnu.org/copyleft/lgpl.html for the full text
# of the license.
__author__ = 'Alberto Mardegan'
__email__ = 'alberto.mardegan@canonical.com'
__copyright__ = '(c) 2015 Canonical Ltd.'
__license__ = 'LGPL 3+'
import dbus
from dbusmock import MOCK_IFACE
BUS_NAME = 'mocked.org.freedesktop.dbus'
MAIN_OBJ = '/org/freedesktop/DBus'
MAIN_IFACE = 'org.freedesktop.DBus'
SYSTEM_BUS = False
def load(mock, parameters):
mock.AddMethod(MAIN_IFACE,
'GetConnectionAppArmorSecurityContext',
's', 's',
'ret = self.contexts.get(args[0], "unconfined")')
mock.contexts = {}
@dbus.service.method(MOCK_IFACE, in_signature='ss', out_signature='')
def AddClient(self, client, context):
'''Adds a client with its security context'''
self.contexts[client] = context
online-accounts-api-0.1+16.04.20160212/tests/daemon/functional_tests/online_accounts-service.py 0000644 0000156 0000165 00000003472 12657306726 032770 0 ustar pbuser pbgroup 0000000 0000000 '''online-accounts-service mock template
This creates the expected methods and properties of the
com.ubuntu.OnlineAccountsUi service. By default, all actions are rejected.
'''
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your option) any
# later version. See http://www.gnu.org/copyleft/lgpl.html for the full text
# of the license.
__author__ = 'Alberto Mardegan'
__email__ = 'alberto.mardegan@canonical.com'
__copyright__ = '(c) 2015 Canonical Ltd.'
__license__ = 'LGPL 3+'
import dbus
from dbusmock import MOCK_IFACE
BUS_NAME = 'com.ubuntu.OnlineAccountsUi'
MAIN_OBJ = '/'
MAIN_IFACE = 'com.ubuntu.OnlineAccountsUi'
SYSTEM_BUS = False
ERROR_PREFIX = 'com.ubuntu.OnlineAccountsUi.'
ERROR_USER_CANCELED = ERROR_PREFIX + 'UserCanceled'
ERROR_INVALID_PARAMETERS = ERROR_PREFIX + 'InvalidParameters'
ERROR_INVALID_APPLICATION= ERROR_PREFIX + 'InvalidApplication'
def load(mock, parameters):
mock.AddMethod(MAIN_IFACE,
'requestAccess',
'a{sv}',
'a{sv}',
'ret = self.request_access(args[0])')
mock.access_reply = {}
mock.access_reply_error = {}
def request_access(self, params):
if 'errorName' in self.access_reply:
raise dbus.exceptions.DBusException('Access error',
name=self.access_reply['errorName'])
return self.access_reply
setattr(mock.__class__, "request_access", request_access)
@dbus.service.method(MOCK_IFACE, in_signature='a{sv}', out_signature='')
def SetRequestAccessReply(self, reply):
'''Prepares the reply for the next RequestAccess call'''
self.access_reply = reply
online-accounts-api-0.1+16.04.20160212/tests/daemon/functional_tests/data/ 0000755 0000156 0000165 00000000000 12657307121 026466 5 ustar pbuser pbgroup 0000000 0000000 ././@LongLink 0000000 0000000 0000000 00000000167 00000000000 011221 L ustar 0000000 0000000 online-accounts-api-0.1+16.04.20160212/tests/daemon/functional_tests/data/com.ubuntu.OnlineAccounts.Manager.service.in online-accounts-api-0.1+16.04.20160212/tests/daemon/functional_tests/data/com.ubuntu.OnlineAccounts.0000644 0000156 0000165 00000000134 12657306726 033521 0 ustar pbuser pbgroup 0000000 0000000 [D-BUS Service]
Name=com.ubuntu.OnlineAccounts.Manager
Exec=${accountd_BINARY_DIR}/accountd
online-accounts-api-0.1+16.04.20160212/tests/daemon/functional_tests/data/coolmail.service 0000644 0000156 0000165 00000001053 12657306726 031660 0 ustar pbuser pbgroup 0000000 0000000
e-mail
Cool Mail
general_myservice
cool
oauth2
user_agent
coolmail.ex
green
10
././@LongLink 0000000 0000000 0000000 00000000155 00000000000 011216 L ustar 0000000 0000000 online-accounts-api-0.1+16.04.20160212/tests/daemon/functional_tests/data/com.ubuntu.tests_coolshare.service online-accounts-api-0.1+16.04.20160212/tests/daemon/functional_tests/data/com.ubuntu.tests_coolshare0000644 0000156 0000165 00000000275 12657306726 033726 0 ustar pbuser pbgroup 0000000 0000000
sharing
Cool Share
general_otherservice
cool
online-accounts-api-0.1+16.04.20160212/tests/daemon/functional_tests/data/applications/ 0000755 0000156 0000165 00000000000 12657307121 031154 5 ustar pbuser pbgroup 0000000 0000000 ././@LongLink 0000000 0000000 0000000 00000000146 00000000000 011216 L ustar 0000000 0000000 online-accounts-api-0.1+16.04.20160212/tests/daemon/functional_tests/data/applications/mailer.desktop online-accounts-api-0.1+16.04.20160212/tests/daemon/functional_tests/data/applications/mailer.deskto0000644 0000156 0000165 00000000243 12657306726 033651 0 ustar pbuser pbgroup 0000000 0000000 [Desktop Entry]
Name=Easy Mailer
Comment=Send and receive mail
Exec=/bin/sh
Icon=mailer-icon
Terminal=false
Type=Application
Categories=Application;Network;Email;
online-accounts-api-0.1+16.04.20160212/tests/daemon/functional_tests/data/mailer.application 0000644 0000156 0000165 00000001014 12657306726 032172 0 ustar pbuser pbgroup 0000000 0000000
Mailer application
mailer-catalog
mailer.desktop
Mailer can retrieve your e-mails
Mailer can even share stuff on CoolShare
././@LongLink 0000000 0000000 0000000 00000000163 00000000000 011215 L ustar 0000000 0000000 online-accounts-api-0.1+16.04.20160212/tests/daemon/functional_tests/data/com.ubuntu.tests_application.application online-accounts-api-0.1+16.04.20160212/tests/daemon/functional_tests/data/com.ubuntu.tests_applicati0000644 0000156 0000165 00000000660 12657306726 033713 0 ustar pbuser pbgroup 0000000 0000000
Mailer
mailer-catalog
mailer.desktop
Mailer can even share stuff on CoolShare
com.ubuntu.tests_application_0.3
online-accounts-api-0.1+16.04.20160212/tests/daemon/functional_tests/data/testsession.conf.in 0000644 0000156 0000165 00000003206 12657306726 032340 0 ustar pbuser pbgroup 0000000 0000000
session
unix:tmpdir=/tmp
${CMAKE_CURRENT_BINARY_DIR}/data
60000
1000000000
1000000000
1000000000
120000
240000
100000
10000
100000
10000
50000
50000
50000
300000
online-accounts-api-0.1+16.04.20160212/tests/daemon/functional_tests/data/oauth1auth.service 0000644 0000156 0000165 00000001016 12657306726 032143 0 ustar pbuser pbgroup 0000000 0000000
e-mail
OAuth 1 test
general_myservice
cool
oauth2
HMAC-SHA1
c0nsum3rk3y
c0nsum3rs3cr3t
online-accounts-api-0.1+16.04.20160212/tests/daemon/functional_tests/data/cool.provider 0000644 0000156 0000165 00000000260 12657306726 031206 0 ustar pbuser pbgroup 0000000 0000000
Cool provider
general_myprovider
true
online-accounts-api-0.1+16.04.20160212/tests/daemon/functional_tests/fake_dbus_apparmor.h 0000644 0000156 0000165 00000003306 12657306726 031566 0 ustar pbuser pbgroup 0000000 0000000 /*
* This file is part of libOnlineAccounts
*
* Copyright (C) 2015 Canonical Ltd.
*
* Contact: Alberto Mardegan
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef OAD_FAKE_DBUS_APPARMOR_H
#define OAD_FAKE_DBUS_APPARMOR_H
#include
#include
class FakeDBusApparmor
{
public:
FakeDBusApparmor(QtDBusMock::DBusMock *mock): m_mock(mock) {
m_mock->registerTemplate("mocked.org.freedesktop.dbus",
DBUS_APPARMOR_MOCK_TEMPLATE,
QDBusConnection::SessionBus);
}
void addClient(const QString &client, const QString context) {
mocked().call("AddClient", client, context);
}
private:
OrgFreedesktopDBusMockInterface &mocked() {
return m_mock->mockInterface("mocked.org.freedesktop.dbus",
"/org/freedesktop/DBus",
"org.freedesktop.DBus",
QDBusConnection::SessionBus);
}
private:
QtDBusMock::DBusMock *m_mock;
};
#endif // OAD_FAKE_DBUS_APPARMOR_H
online-accounts-api-0.1+16.04.20160212/tests/daemon/functional_tests/daemon_interface.h 0000644 0000156 0000165 00000006234 12657306726 031230 0 ustar pbuser pbgroup 0000000 0000000 /*
* This file is part of libOnlineAccounts
*
* Copyright (C) 2015 Canonical Ltd.
*
* Contact: Alberto Mardegan
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef OAD_DAEMON_INTERFACE_H
#define OAD_DAEMON_INTERFACE_H
#include "OnlineAccountsDaemon/dbus_constants.h"
#include
#include
#include
#include
#include
#include
#include
#include
class AccountInfo {
public:
AccountInfo(): accountId(0) {}
AccountInfo(uint accountId, const QVariantMap &details):
accountId(accountId), details(details) {}
uint id() const { return accountId; }
QVariantMap data() const { return details; }
private:
friend QDBusArgument &operator<<(QDBusArgument &, const AccountInfo &);
friend const QDBusArgument &operator>>(const QDBusArgument &, AccountInfo &);
uint accountId;
QVariantMap details;
};
Q_DECLARE_METATYPE(AccountInfo)
QDBusArgument &operator<<(QDBusArgument &argument, const AccountInfo &info);
const QDBusArgument &operator>>(const QDBusArgument &argument, AccountInfo &info);
/* Avoid using QDBusInterface which does a blocking introspection call.
*/
class DaemonInterface: public QDBusAbstractInterface
{
Q_OBJECT
public:
DaemonInterface(QObject *parent = 0);
~DaemonInterface() {}
QDBusPendingCall getAccounts(const QVariantMap &filters) {
return asyncCall(QStringLiteral("GetAccounts"), filters);
}
QDBusPendingCall authenticate(uint accountId, const QString &service,
bool interactive, bool invalidate,
const QVariantMap ¶meters) {
return asyncCall(QStringLiteral("Authenticate"), accountId, service,
interactive, invalidate, parameters);
}
QDBusPendingCall requestAccess(const QString &service,
const QVariantMap ¶meters) {
return asyncCall(QStringLiteral("RequestAccess"), service, parameters);
}
Q_SIGNALS:
void accountChanged(const QString &service,
const AccountInfo &info);
private:
bool connect(const char *signal, const char *signature,
QObject *receiver, const char *slot) {
return connection().connect(service(), path(), interface(),
QLatin1String(signal),
QLatin1String(signature),
receiver, slot);
}
};
#endif // OAD_DAEMON_INTERFACE_H
online-accounts-api-0.1+16.04.20160212/tests/daemon/functional_tests/daemon_interface.cpp 0000644 0000156 0000165 00000003676 12657306726 031572 0 ustar pbuser pbgroup 0000000 0000000 /*
* This file is part of libOnlineAccounts
*
* Copyright (C) 2015 Canonical Ltd.
*
* Contact: Alberto Mardegan
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "daemon_interface.h"
#include
#include
QDBusArgument &operator<<(QDBusArgument &argument, const AccountInfo &info) {
argument.beginStructure();
argument << info.accountId << info.details;
argument.endStructure();
return argument;
}
const QDBusArgument &operator>>(const QDBusArgument &argument, AccountInfo &info) {
argument.beginStructure();
argument >> info.accountId >> info.details;
argument.endStructure();
return argument;
}
DaemonInterface::DaemonInterface(QObject *parent):
QDBusAbstractInterface(ONLINE_ACCOUNTS_MANAGER_SERVICE_NAME,
ONLINE_ACCOUNTS_MANAGER_PATH,
ONLINE_ACCOUNTS_MANAGER_INTERFACE,
QDBusConnection::sessionBus(),
parent)
{
setTimeout(INT_MAX);
qDBusRegisterMetaType();
qDBusRegisterMetaType>();
bool ok = connect("AccountChanged", "s(ua{sv})",
this, SIGNAL(accountChanged(const QString&,const AccountInfo&)));
if (Q_UNLIKELY(!ok)) {
qCritical() << "Connection to AccountChanged signal failed";
}
}
online-accounts-api-0.1+16.04.20160212/tests/daemon/functional_tests/fake_signond.h 0000644 0000156 0000165 00000003375 12657306726 030377 0 ustar pbuser pbgroup 0000000 0000000 /*
* This file is part of libOnlineAccounts
*
* Copyright (C) 2015 Canonical Ltd.
*
* Contact: Alberto Mardegan
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef OAD_FAKE_SIGNOND_H
#define OAD_FAKE_SIGNOND_H
#include
#include
class FakeSignond
{
public:
FakeSignond(QtDBusMock::DBusMock *mock): m_mock(mock) {
m_mock->registerTemplate("com.google.code.AccountsSSO.SingleSignOn",
SIGNOND_MOCK_TEMPLATE,
QDBusConnection::SessionBus);
}
void addIdentity(uint id, const QVariantMap &info) {
mockedAuthService().call("AddIdentity", id, info);
}
private:
OrgFreedesktopDBusMockInterface &mockedAuthService() {
return m_mock->mockInterface("com.google.code.AccountsSSO.SingleSignOn",
"/com/google/code/AccountsSSO/SingleSignOn",
"com.google.code.AccountsSSO.SingleSignOn.AuthService",
QDBusConnection::SessionBus);
}
private:
QtDBusMock::DBusMock *m_mock;
};
#endif // OAD_FAKE_SIGNOND_H
online-accounts-api-0.1+16.04.20160212/tests/daemon/functional_tests/CMakeLists.txt 0000644 0000156 0000165 00000002740 12657306726 030332 0 ustar pbuser pbgroup 0000000 0000000 set(TEST tst_daemon)
set(SOURCES
daemon_interface.cpp
functional_tests.cpp
)
pkg_check_modules(QTDBUSMOCK REQUIRED libqtdbusmock-1)
pkg_check_modules(QTDBUSTEST REQUIRED libqtdbustest-1)
pkg_check_modules(ACCOUNTSQT accounts-qt5 REQUIRED)
add_executable(${TEST} ${SOURCES})
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${OnlineAccountsQt_SOURCE_DIR}/..
${OnlineAccountsDaemon_SOURCE_DIR}/..
${ACCOUNTSQT_INCLUDE_DIRS}
${QTDBUSMOCK_INCLUDE_DIRS}
${QTDBUSTEST_INCLUDE_DIRS}
)
add_definitions(
-DTEST_DBUS_CONFIG_FILE="${CMAKE_CURRENT_BINARY_DIR}/data/testsession.conf"
-DTEST_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data"
-DTEST_PROCESS="${CMAKE_CURRENT_SOURCE_DIR}/test_process.py"
-DSIGNOND_MOCK_TEMPLATE="${CMAKE_CURRENT_SOURCE_DIR}/signond.py"
-DDBUS_APPARMOR_MOCK_TEMPLATE="${CMAKE_CURRENT_SOURCE_DIR}/dbus_apparmor.py"
-DONLINE_ACCOUNTS_SERVICE_MOCK_TEMPLATE="${CMAKE_CURRENT_SOURCE_DIR}/online_accounts-service.py"
)
configure_file(data/testsession.conf.in data/testsession.conf)
configure_file(data/com.ubuntu.OnlineAccounts.Manager.service.in
data/com.ubuntu.OnlineAccounts.Manager.service
)
target_link_libraries(${TEST}
OnlineAccountsQt
${ACCOUNTSQT_LIBRARIES}
${QTDBUSMOCK_LIBRARIES}
${QTDBUSTEST_LIBRARIES}
)
qt5_use_modules(${TEST} Core DBus Test)
set_target_properties(${TEST} PROPERTIES AUTOMOC TRUE)
add_test(${TEST} ${XVFB_COMMAND} ${CMAKE_CURRENT_BINARY_DIR}/${TEST})
add_dependencies(check ${TEST})
online-accounts-api-0.1+16.04.20160212/tests/daemon/functional_tests/test_process.py 0000755 0000156 0000165 00000004236 12657306726 030666 0 ustar pbuser pbgroup 0000000 0000000 #! /usr/bin/python3
# coding: UTF-8
import argparse
import dbus
import dbus.mainloop.glib
from gi.repository import GLib
import json
import sys
import traceback
BUS_NAME = 'com.ubuntu.OnlineAccounts.Manager'
MAIN_OBJ = '/com/ubuntu/OnlineAccounts/Manager'
MAIN_IFACE = 'com.ubuntu.OnlineAccounts.Manager'
class TestProcess:
def __init__(self, bus):
self.parser = self.create_parser()
self.main_loop = GLib.MainLoop()
self.manager = bus.get_object(BUS_NAME, MAIN_OBJ)
self.manager.connect_to_signal("AccountChanged", self.on_account_changed,
dbus_interface=MAIN_IFACE)
def get_accounts(self, args):
filters = dbus.Dictionary(signature='sv')
if args.filters:
filters.update(json.loads(args.filters))
print('%s' % json.dumps(self.manager.GetAccounts(filters), sort_keys=True),
flush=True)
def on_account_changed(self, serviceId, accountInfo):
info = json.dumps(accountInfo, sort_keys=True)
print('AccountChanged %s %s' % (serviceId, info), flush=True)
def on_line_read(self, line):
if not line:
self.main_loop.quit()
return
args = self.parser.parse_args(line.split())
args.func(args)
def run(self):
GLib.io_add_watch(0, GLib.IO_IN | GLib.IO_HUP, self.on_input)
self.main_loop.run()
def on_input(self, source, reason):
if reason & GLib.IO_IN:
line = sys.stdin.readline()
self.on_line_read(line.strip())
else:
self.on_line_read('')
return True
def create_parser(self):
parser = argparse.ArgumentParser(description='Test process')
subparsers = parser.add_subparsers()
parser_accounts = subparsers.add_parser('GetAccounts')
parser_accounts.add_argument('-f', '--filters')
parser_accounts.set_defaults(func=self.get_accounts)
return parser
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SessionBus()
print('%s' % bus.get_unique_name(), flush=True)
try:
app = TestProcess(bus)
except dbus.DBusException:
traceback.print_exc()
sys.exit(1)
app.run()
online-accounts-api-0.1+16.04.20160212/tests/daemon/functional_tests/functional_tests.cpp 0000644 0000156 0000165 00000047133 12657306726 031667 0 ustar pbuser pbgroup 0000000 0000000 /*
* This file is part of libOnlineAccounts
*
* Copyright (C) 2015 Canonical Ltd.
*
* Contact: Alberto Mardegan
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "OnlineAccountsDaemon/dbus_constants.h"
#include "daemon_interface.h"
#include "fake_dbus_apparmor.h"
#include "fake_online_accounts_service.h"
#include "fake_signond.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
namespace QTest {
template<>
char *toString(const QSet &set)
{
QByteArray ba = "QSet(";
QStringList list;
Q_FOREACH(int i, set) {
list.append(QString::number(i));
}
ba += list.join(", ");
ba += ")";
return qstrdup(ba.data());
}
template<>
char *toString(const QVariantMap &map)
{
QJsonDocument doc(QJsonObject::fromVariantMap(map));
return qstrdup(doc.toJson(QJsonDocument::Compact).data());
}
} // QTest namespace
class TestProcess: public QProcess
{
Q_OBJECT
public:
TestProcess(QObject *parent = 0):
QProcess(parent),
m_replyExpected(false)
{
setProgram(QStringLiteral(TEST_PROCESS));
setReadChannel(QProcess::StandardOutput);
setProcessChannelMode(QProcess::ForwardedErrorChannel);
start();
QVERIFY(waitForStarted());
QVERIFY(waitForReadyRead());
m_uniqueName = QString::fromUtf8(readLine()).trimmed();
QObject::connect(this, SIGNAL(readyReadStandardOutput()),
this, SLOT(onReadyRead()));
}
~TestProcess() { quit(); }
QString uniqueName() const { return m_uniqueName; }
void quit() { write("\n"); waitForFinished(); }
QList getAccounts(const QVariantMap &filters) {
QJsonDocument doc(QJsonObject::fromVariantMap(filters));
m_replyExpected = true;
write("GetAccounts -f ");
write(doc.toJson(QJsonDocument::Compact) + '\n');
waitForReadyRead();
doc = QJsonDocument::fromJson(readLine());
m_replyExpected = false;
QList accountInfos;
Q_FOREACH(const QJsonValue &v, doc.array()) {
QJsonArray a = v.toArray();
accountInfos.append(AccountInfo(a.at(0).toInt(),
a.at(1).toObject().toVariantMap()));
}
return accountInfos;
}
private Q_SLOTS:
void onReadyRead() {
if (m_replyExpected) return;
QByteArray line = readLine().trimmed();
QList parts = line.split(' ');
if (parts[0] != "AccountChanged") return;
QByteArray changes = parts.mid(2).join(' ');
QJsonDocument doc = QJsonDocument::fromJson(changes);
QJsonArray a = doc.array();
Q_EMIT accountChanged(QString::fromUtf8(parts[1]),
AccountInfo(a.at(0).toInt(),
a.at(1).toObject().toVariantMap()));
}
Q_SIGNALS:
void accountChanged(QString serviceId, AccountInfo account);
private:
QString m_uniqueName;
bool m_replyExpected;
};
class FunctionalTests: public QObject
{
Q_OBJECT
struct EnvSetup {
EnvSetup();
};
public:
FunctionalTests();
private Q_SLOTS:
void testGetAccountsFiltering_data();
void testGetAccountsFiltering();
void testAuthenticate_data();
void testAuthenticate();
void testRequestAccess_data();
void testRequestAccess();
void testAccountChanges();
void testLifetime();
void cleanupTestCase();
private:
void clearDb();
private:
EnvSetup m_env;
QtDBusTest::DBusTestRunner m_dbus;
QtDBusMock::DBusMock m_mock;
FakeDBusApparmor m_dbusApparmor;
FakeOnlineAccountsService m_onlineAccounts;
FakeSignond m_signond;
int m_firstAccountId;
int m_account3CredentialsId;
};
FunctionalTests::EnvSetup::EnvSetup() {
qputenv("ACCOUNTS", "/tmp/");
qputenv("AG_APPLICATIONS", TEST_DATA_DIR);
qputenv("AG_SERVICES", TEST_DATA_DIR);
qputenv("AG_SERVICE_TYPES", TEST_DATA_DIR);
qputenv("AG_PROVIDERS", TEST_DATA_DIR);
qputenv("XDG_DATA_HOME", TEST_DATA_DIR);
qputenv("SSO_USE_PEER_BUS", "0");
qputenv("OAD_TIMEOUT", "2");
qputenv("OAD_TESTING", "1");
}
FunctionalTests::FunctionalTests():
QObject(),
m_dbus(TEST_DBUS_CONFIG_FILE),
m_mock(m_dbus),
m_dbusApparmor(&m_mock),
m_onlineAccounts(&m_mock),
m_signond(&m_mock),
m_account3CredentialsId(35)
{
clearDb();
/* Populate the accounts DB */
Accounts::Manager *manager = new Accounts::Manager(this);
Accounts::Service coolMail = manager->service("coolmail");
Accounts::Service coolShare = manager->service("com.ubuntu.tests_coolshare");
Accounts::Service oauth1auth = manager->service("oauth1auth");
Accounts::Account *account1 = manager->createAccount("cool");
QVERIFY(account1 != 0);
account1->setEnabled(true);
account1->setDisplayName("CoolAccount 1");
// Do not create this identity, we want it to be non-existing
account1->setCredentialsId(249);
account1->selectService(coolMail);
account1->setEnabled(true);
account1->syncAndBlock();
m_firstAccountId = account1->id() - 1;
Accounts::Account *account2 = manager->createAccount("cool");
QVERIFY(account2 != 0);
account2->setEnabled(true);
account2->setDisplayName("CoolAccount 2");
account2->selectService(coolMail);
account2->setEnabled(false);
account2->selectService(coolShare);
account2->setEnabled(true);
account2->syncAndBlock();
Accounts::Account *account3 = manager->createAccount("cool");
QVERIFY(account3 != 0);
account3->setEnabled(true);
account3->setDisplayName("CoolAccount 3");
account3->setValue("color", "red");
account3->setValue("size", "big");
account3->setCredentialsId(m_account3CredentialsId);
account3->selectService(coolMail);
account3->setEnabled(true);
account3->selectService(oauth1auth);
account3->setEnabled(true);
account3->syncAndBlock();
delete manager;
m_dbus.startServices();
}
void FunctionalTests::clearDb()
{
QDir dbroot(QString::fromLatin1(qgetenv("ACCOUNTS")));
dbroot.remove("accounts.db");
}
void FunctionalTests::testGetAccountsFiltering_data()
{
QTest::addColumn("filters");
QTest::addColumn("securityContext");
QTest::addColumn >("expectedAccountIds");
QVariantMap filters;
QTest::newRow("empty filters") <<
filters <<
"unconfined" <<
(QList() << 1 << 2 << 3);
QTest::newRow("empty filters, confined") <<
filters <<
"com.ubuntu.tests_application_0.2" <<
(QList() << 2);
filters[ONLINE_ACCOUNTS_INFO_KEY_SERVICE_ID] = "coolmail";
QTest::newRow("by service ID") <<
filters <<
"unconfined" <<
(QList() << 1 << 3);
}
void FunctionalTests::testGetAccountsFiltering()
{
QFETCH(QVariantMap, filters);
QFETCH(QString, securityContext);
QFETCH(QList, expectedAccountIds);
DaemonInterface *daemon = new DaemonInterface;
TestProcess testProcess;
m_dbusApparmor.addClient(testProcess.uniqueName(), securityContext);
QList accountInfos = testProcess.getAccounts(filters);
QList accountIds;
Q_FOREACH(const AccountInfo &info, accountInfos) {
accountIds.append(info.id() + m_firstAccountId);
}
QCOMPARE(accountIds.toSet(), expectedAccountIds.toSet());
delete daemon;
}
void FunctionalTests::testAuthenticate_data()
{
QTest::addColumn("accountId");
QTest::addColumn("serviceId");
QTest::addColumn("interactive");
QTest::addColumn("invalidate");
QTest::addColumn("authParams");
QTest::addColumn("expectedCredentials");
QTest::addColumn("errorName");
QVariantMap authParams;
QVariantMap credentials;
QTest::newRow("invalid account ID") <<
12412341 <<
"coolmail" <<
false << false <<
authParams <<
credentials <<
ONLINE_ACCOUNTS_ERROR_PERMISSION_DENIED;
authParams["errorName"] =
"com.google.code.AccountsSSO.SingleSignOn.Error.Network";
QTest::newRow("Authentication error") <<
3 <<
"coolmail" <<
false << false <<
authParams <<
credentials <<
"com.ubuntu.OnlineAccounts.Error.Network";
authParams.clear();
authParams["one"] = 1;
credentials["one"] = 1;
credentials["host"] = "coolmail.ex";
credentials["UiPolicy"] = 2;
QTest::newRow("no interactive, no invalidate") <<
3 <<
"coolmail" <<
false << false <<
authParams <<
credentials <<
QString();
credentials["UiPolicy"] = 0;
QTest::newRow("interactive, no invalidate") <<
3 <<
"coolmail" <<
true << false <<
authParams <<
credentials <<
QString();
credentials["ForceTokenRefresh"] = true;
QTest::newRow("interactive, invalidate") <<
3 <<
"coolmail" <<
true << true <<
authParams <<
credentials <<
QString();
authParams.clear();
credentials.clear();
credentials["UiPolicy"] = 0;
credentials["ConsumerKey"] = "c0nsum3rk3y";
credentials["ConsumerSecret"] = "c0nsum3rs3cr3t";
QTest::newRow("OAuth1 client data") <<
3 <<
"oauth1auth" <<
true << false <<
authParams <<
credentials <<
QString();
authParams.clear();
authParams["ConsumerKey"] = "overridden";
credentials.clear();
credentials["UiPolicy"] = 0;
credentials["ConsumerKey"] = "overridden";
credentials["ConsumerSecret"] = "c0nsum3rs3cr3t";
QTest::newRow("OAuth1 client data, overridden") <<
3 <<
"oauth1auth" <<
true << false <<
authParams <<
credentials <<
QString();
}
void FunctionalTests::testAuthenticate()
{
QFETCH(int, accountId);
QFETCH(QString, serviceId);
QFETCH(bool, interactive);
QFETCH(bool, invalidate);
QFETCH(QVariantMap, authParams);
QFETCH(QVariantMap, expectedCredentials);
QFETCH(QString, errorName);
m_signond.addIdentity(m_account3CredentialsId, QVariantMap());
DaemonInterface *daemon = new DaemonInterface;
QDBusPendingReply reply =
daemon->authenticate(m_firstAccountId + accountId, serviceId,
interactive, invalidate, authParams);
reply.waitForFinished();
if (errorName.isEmpty()) {
QVERIFY(!reply.isError());
QVariantMap credentials = reply.argumentAt<0>();
// Add the requestor PID
expectedCredentials["requestorPid"] = getpid();
QCOMPARE(credentials, expectedCredentials);
} else {
QVERIFY(reply.isError());
QCOMPARE(reply.error().name(), errorName);
}
delete daemon;
}
void FunctionalTests::testRequestAccess_data()
{
QTest::addColumn("serviceId");
QTest::addColumn("authParams");
QTest::addColumn("accessReply");
QTest::addColumn("expectedAccountId");
QTest::addColumn("expectedAccountInfo");
QTest::addColumn("expectedCredentials");
QTest::addColumn("errorName");
QVariantMap authParams;
QVariantMap accessReply;
QVariantMap accountInfo;
QVariantMap credentials;
QTest::newRow("access denied") <<
"coolmail" <<
authParams <<
accessReply <<
0 <<
accountInfo <<
credentials <<
ONLINE_ACCOUNTS_ERROR_PERMISSION_DENIED;
accessReply["accountId"] = m_firstAccountId + 3;
accountInfo[ONLINE_ACCOUNTS_INFO_KEY_AUTH_METHOD] =
ONLINE_ACCOUNTS_AUTH_METHOD_OAUTH2;
accountInfo[ONLINE_ACCOUNTS_INFO_KEY_DISPLAY_NAME] = "CoolAccount 3";
accountInfo[ONLINE_ACCOUNTS_INFO_KEY_SERVICE_ID] = "coolmail";
accountInfo["settings/auth/mechanism"] = "user_agent";
accountInfo["settings/auth/method"] = "oauth2";
accountInfo["settings/auth/oauth2/user_agent/host"] = "coolmail.ex";
accountInfo["settings/auto-explode-after"] = 10;
accountInfo["settings/color"] = "green";
accountInfo["settings/size"] = "big";
credentials["host"] = "coolmail.ex";
QTest::newRow("no auth params") <<
"coolmail" <<
authParams <<
accessReply <<
m_firstAccountId + 3 <<
accountInfo <<
credentials <<
"";
authParams["one"] = 1;
credentials["one"] = 1;
QTest::newRow("with auth params") <<
"coolmail" <<
authParams <<
accessReply <<
m_firstAccountId + 3 <<
accountInfo <<
credentials <<
"";
}
void FunctionalTests::testRequestAccess()
{
QFETCH(QString, serviceId);
QFETCH(QVariantMap, authParams);
QFETCH(QVariantMap, accessReply);
QFETCH(int, expectedAccountId);
QFETCH(QVariantMap, expectedAccountInfo);
QFETCH(QVariantMap, expectedCredentials);
QFETCH(QString, errorName);
m_onlineAccounts.setRequestAccessReply(accessReply);
m_signond.addIdentity(m_account3CredentialsId, QVariantMap());
DaemonInterface *daemon = new DaemonInterface;
QDBusPendingReply reply =
daemon->requestAccess(serviceId, authParams);
reply.waitForFinished();
if (errorName.isEmpty()) {
QVERIFY(!reply.isError());
AccountInfo accountInfo = reply.argumentAt<0>();
QVariantMap credentials = reply.argumentAt<1>();
QCOMPARE(int(accountInfo.id()), expectedAccountId);
QCOMPARE(accountInfo.data(), expectedAccountInfo);
QCOMPARE(credentials, expectedCredentials);
} else {
QVERIFY(reply.isError());
QCOMPARE(reply.error().name(), errorName);
}
delete daemon;
}
void FunctionalTests::testAccountChanges()
{
DaemonInterface *daemon = new DaemonInterface;
/* First, we make a call to the service so that it knows about our client
* and will later notify it about changes.
*/
QVariantMap filters;
filters["applicationId"] = "com.ubuntu.tests_application";
TestProcess testProcess;
QSignalSpy accountChanged(&testProcess,
SIGNAL(accountChanged(QString,AccountInfo)));
QList accountInfos = testProcess.getAccounts(filters);
QList initialAccountIds;
Q_FOREACH(const AccountInfo &info, accountInfos) {
initialAccountIds.append(info.id());
}
/* Create a new account */
Accounts::Manager *manager = new Accounts::Manager(this);
Accounts::Service coolShare = manager->service("com.ubuntu.tests_coolshare");
Accounts::Account *account = manager->createAccount("cool");
QVERIFY(account != 0);
account->setEnabled(true);
account->setDisplayName("New account");
account->selectService(coolShare);
account->setEnabled(true);
account->syncAndBlock();
QTRY_COMPARE(accountChanged.count(), 1);
QString serviceId = accountChanged.at(0).at(0).toString();
AccountInfo accountInfo = accountChanged.at(0).at(1).value();
QCOMPARE(serviceId, coolShare.name());
QCOMPARE(accountInfo.id(), account->id());
QVariantMap expectedAccountInfo;
expectedAccountInfo["authMethod"] = ONLINE_ACCOUNTS_AUTH_METHOD_UNKNOWN;
expectedAccountInfo["changeType"] = ONLINE_ACCOUNTS_INFO_CHANGE_ENABLED;
expectedAccountInfo["displayName"] = "New account";
expectedAccountInfo["serviceId"] = "com.ubuntu.tests_coolshare";
QCOMPARE(accountInfo.data(), expectedAccountInfo);
/* Change a setting */
accountChanged.clear();
account->setValue("color", "blue");
account->syncAndBlock();
QTRY_COMPARE(accountChanged.count(), 1);
serviceId = accountChanged.at(0).at(0).toString();
accountInfo = accountChanged.at(0).at(1).value();
QCOMPARE(serviceId, coolShare.name());
QCOMPARE(accountInfo.id(), account->id());
expectedAccountInfo["authMethod"] = ONLINE_ACCOUNTS_AUTH_METHOD_UNKNOWN;
expectedAccountInfo["changeType"] = ONLINE_ACCOUNTS_INFO_CHANGE_UPDATED;
expectedAccountInfo["settings/color"] = "blue";
expectedAccountInfo["displayName"] = "New account";
expectedAccountInfo["serviceId"] = "com.ubuntu.tests_coolshare";
QCOMPARE(accountInfo.data(), expectedAccountInfo);
/* Delete the account */
accountChanged.clear();
account->remove();
account->syncAndBlock();
QTRY_COMPARE(accountChanged.count(), 1);
serviceId = accountChanged.at(0).at(0).toString();
accountInfo = accountChanged.at(0).at(1).value();
QCOMPARE(serviceId, coolShare.name());
QCOMPARE(accountInfo.id(), account->id());
expectedAccountInfo["authMethod"] = ONLINE_ACCOUNTS_AUTH_METHOD_UNKNOWN;
expectedAccountInfo["changeType"] = ONLINE_ACCOUNTS_INFO_CHANGE_DISABLED;
expectedAccountInfo["displayName"] = "New account";
expectedAccountInfo["serviceId"] = "com.ubuntu.tests_coolshare";
QCOMPARE(accountInfo.data(), expectedAccountInfo);
delete daemon;
}
void FunctionalTests::testLifetime()
{
/* Make a dbus call, and have signond reply after 3 seconds; make sure that
* the online accounts daemon doesn't time out. */
m_signond.addIdentity(m_account3CredentialsId, QVariantMap());
DaemonInterface *daemon = new DaemonInterface;
QDBusServiceWatcher watcher(ONLINE_ACCOUNTS_MANAGER_SERVICE_NAME,
QDBusConnection::sessionBus(),
QDBusServiceWatcher::WatchForUnregistration);
QSignalSpy unregistered(&watcher,
SIGNAL(serviceUnregistered(const QString &)));
QVariantMap authParams;
authParams["delay"] = 3;
QDBusPendingReply reply =
daemon->authenticate(m_firstAccountId + 3, "coolmail",
false, false, authParams);
reply.waitForFinished();
QVERIFY(!reply.isError());
QVariantMap expectedCredentials(authParams);
expectedCredentials["UiPolicy"] = 2;
expectedCredentials["host"] = "coolmail.ex";
expectedCredentials["requestorPid"] = getpid();
QVariantMap credentials = reply.argumentAt<0>();
QCOMPARE(credentials, expectedCredentials);
QCOMPARE(unregistered.count(), 0);
delete daemon;
}
void FunctionalTests::cleanupTestCase()
{
QDBusConnection conn = QDBusConnection::sessionBus();
QString serviceName(QStringLiteral(ONLINE_ACCOUNTS_MANAGER_SERVICE_NAME));
QDBusReply reply =
conn.interface()->isServiceRegistered(serviceName);
if (reply.value()) {
/* Let'äs wait for the daemon to quit */
QDBusServiceWatcher watcher(serviceName, conn,
QDBusServiceWatcher::WatchForUnregistration);
QSignalSpy unregistered(&watcher,
SIGNAL(serviceUnregistered(const QString &)));
QTRY_COMPARE(unregistered.count(), 1);
}
}
QTEST_MAIN(FunctionalTests)
#include "functional_tests.moc"
online-accounts-api-0.1+16.04.20160212/tests/daemon/functional_tests/signond.py 0000644 0000156 0000165 00000006710 12657306726 027606 0 ustar pbuser pbgroup 0000000 0000000 '''signond mock template
This creates the expected methods and properties of the
com.google.code.AccountsSSO.SingleSignOn service.
'''
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your option) any
# later version. See http://www.gnu.org/copyleft/lgpl.html for the full text
# of the license.
__author__ = 'Alberto Mardegan'
__email__ = 'alberto.mardegan@canonical.com'
__copyright__ = '(c) 2015 Canonical Ltd.'
__license__ = 'LGPL 3+'
import dbus
import time
from dbusmock import MOCK_IFACE
import dbusmock
BUS_NAME = 'com.google.code.AccountsSSO.SingleSignOn'
MAIN_OBJ = '/com/google/code/AccountsSSO/SingleSignOn'
AUTH_SERVICE_IFACE = 'com.google.code.AccountsSSO.SingleSignOn.AuthService'
MAIN_IFACE = AUTH_SERVICE_IFACE
IDENTITY_IFACE = 'com.google.code.AccountsSSO.SingleSignOn.Identity'
AUTH_SESSION_IFACE = 'com.google.code.AccountsSSO.SingleSignOn.AuthSession'
SYSTEM_BUS = False
ERROR_PREFIX = 'com.google.code.AccountsSSO.SingleSignOn.Error.'
ERROR_IDENTITY_NOT_FOUND = ERROR_PREFIX + 'IdentityNotFound'
ERROR_PERMISSION_DENIED = ERROR_PREFIX + 'PermissionDenied'
ERROR_USER_INTERACTION= ERROR_PREFIX + 'UserInteraction'
def get_identity(self, identity):
if identity not in self.identities:
raise dbus.exceptions.DBusException('Identity not found',
name=ERROR_IDENTITY_NOT_FOUND)
path = '/Identity%s' % identity
if not path in dbusmock.get_objects():
self.AddObject(path, IDENTITY_IFACE, {}, [
('getInfo', '', 'a{sv}', 'ret = self.parent.identities[%s]' % identity)
])
identity_obj = dbusmock.get_object(path)
identity_obj.parent = self
return (path, self.identities[identity])
def auth_session_process(identity, params, method):
if 'errorName' in params:
raise dbus.exceptions.DBusException('Authentication error',
name=params['errorName'])
if 'delay' in params:
time.sleep(params['delay'])
return params
def get_auth_session_object_path(self, identity, method):
if identity != 0 and (identity not in self.identities):
raise dbus.exceptions.DBusException('Identity not found',
name=ERROR_IDENTITY_NOT_FOUND)
path = '/AuthSession%s' % self.sessions_counter
self.sessions_counter += 1
self.AddObject(path, AUTH_SESSION_IFACE, {}, [
('process', 'a{sv}s', 'a{sv}', 'ret = self.auth_session_process(self.identity, args[0], args[1])'),
])
auth_session = dbusmock.get_object(path)
auth_session.auth_session_process = auth_session_process
auth_session.identity = identity
auth_session.method = method
return path
def load(mock, parameters):
mock.get_identity = get_identity
mock.get_auth_session_object_path = get_auth_session_object_path
mock.AddMethods(AUTH_SERVICE_IFACE, [
('getIdentity', 'u', 'oa{sv}', 'ret = self.get_identity(self, args[0])'),
('getAuthSessionObjectPath', 'us', 's', 'ret = self.get_auth_session_object_path(self, args[0], args[1])'),
])
mock.sessions_counter = 1
mock.identities = {}
mock.auth_sessions = {}
mock.auth_replies = {}
@dbus.service.method(MOCK_IFACE, in_signature='ua{sv}', out_signature='')
def AddIdentity(self, identity, data):
self.identities[identity] = data
online-accounts-api-0.1+16.04.20160212/tests/daemon/CMakeLists.txt 0000644 0000156 0000165 00000000043 12657306726 024740 0 ustar pbuser pbgroup 0000000 0000000 add_subdirectory(functional_tests)
online-accounts-api-0.1+16.04.20160212/tests/lib/ 0000755 0000156 0000165 00000000000 12657307121 021474 5 ustar pbuser pbgroup 0000000 0000000 online-accounts-api-0.1+16.04.20160212/tests/lib/OnlineAccounts/ 0000755 0000156 0000165 00000000000 12657307121 024420 5 ustar pbuser pbgroup 0000000 0000000 online-accounts-api-0.1+16.04.20160212/tests/lib/OnlineAccounts/functional_tests/ 0000755 0000156 0000165 00000000000 12657307121 030004 5 ustar pbuser pbgroup 0000000 0000000 online-accounts-api-0.1+16.04.20160212/tests/lib/OnlineAccounts/functional_tests/CMakeLists.txt 0000644 0000156 0000165 00000001202 12657306726 032551 0 ustar pbuser pbgroup 0000000 0000000 set(TEST functional_tests)
set(SOURCES
functional_tests.cpp
)
pkg_check_modules(QTDBUSMOCK REQUIRED libqtdbusmock-1)
pkg_check_modules(QTDBUSTEST REQUIRED libqtdbustest-1)
add_executable(${TEST} ${SOURCES})
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${OnlineAccountsQt_SOURCE_DIR}/..
${OnlineAccountsDaemon_SOURCE_DIR}/..
${QTDBUSMOCK_INCLUDE_DIRS}
${QTDBUSTEST_INCLUDE_DIRS}
)
target_link_libraries(${TEST}
OnlineAccountsQt
${QTDBUSMOCK_LIBRARIES}
${QTDBUSTEST_LIBRARIES}
)
qt5_use_modules(${TEST} Core Test)
add_test(${TEST} ${CMAKE_CURRENT_BINARY_DIR}/${TEST})
add_dependencies(check ${TEST})
././@LongLink 0000000 0000000 0000000 00000000146 00000000000 011216 L ustar 0000000 0000000 online-accounts-api-0.1+16.04.20160212/tests/lib/OnlineAccounts/functional_tests/functional_tests.cpp online-accounts-api-0.1+16.04.20160212/tests/lib/OnlineAccounts/functional_tests/functional_tests.cp0000644 0000156 0000165 00000052675 12657306732 033742 0 ustar pbuser pbgroup 0000000 0000000 /*
* This file is part of libOnlineAccounts
*
* Copyright (C) 2015-2016 Canonical Ltd.
*
* Contact: Alberto Mardegan
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "OnlineAccounts/Account"
#include "OnlineAccounts/Manager"
#include "OnlineAccounts/OAuth1Data"
#include "OnlineAccounts/OAuth2Data"
#include "OnlineAccounts/PasswordData"
#include "OnlineAccounts/account_info.h"
#include "OnlineAccountsDaemon/dbus_constants.h"
#include
#include
#include
#include
#include
namespace QTest {
template<>
char *toString(const QVariantMap &map)
{
QJsonDocument doc(QJsonObject::fromVariantMap(map));
return qstrdup(doc.toJson(QJsonDocument::Compact).data());
}
} // QTest namespace
class FunctionalTests: public QObject
{
Q_OBJECT
public:
FunctionalTests();
OrgFreedesktopDBusMockInterface &mocked() {
return m_mock.mockInterface(ONLINE_ACCOUNTS_MANAGER_SERVICE_NAME,
ONLINE_ACCOUNTS_MANAGER_PATH,
ONLINE_ACCOUNTS_MANAGER_INTERFACE,
QDBusConnection::SessionBus);
}
void addMockedMethod(const QString &name,
const QString &in_sig,
const QString &out_sig,
const QString &code)
{
return mocked().AddMethod(ONLINE_ACCOUNTS_MANAGER_INTERFACE,
name, in_sig, out_sig, code).waitForFinished();
}
void emitAccountChanged(const QString &service,
uint accountId,
const QVariantMap &changes)
{
QVariantList args;
args << service;
OnlineAccounts::AccountInfo accountInfo(accountId, changes);
args << QVariant::fromValue(accountInfo);
mocked().EmitSignal(ONLINE_ACCOUNTS_MANAGER_INTERFACE,
"AccountChanged", "s(ua{sv})",
args);
}
private Q_SLOTS:
void testManagerReady_data();
void testManagerReady();
void testManagerAvailableAccounts_data();
void testManagerAvailableAccounts();
void testManagerAccount();
void testManagerRequestAccess_data();
void testManagerRequestAccess();
void testAccountData_data();
void testAccountData();
void testAccountChanges();
void testPendingCallWatcher();
void testAuthentication();
void testAuthenticationErrors_data();
void testAuthenticationErrors();
private:
QtDBusTest::DBusTestRunner m_dbus;
QtDBusMock::DBusMock m_mock;
};
FunctionalTests::FunctionalTests():
QObject(),
m_mock(m_dbus)
{
m_mock.registerCustomMock(ONLINE_ACCOUNTS_MANAGER_SERVICE_NAME,
ONLINE_ACCOUNTS_MANAGER_PATH,
ONLINE_ACCOUNTS_MANAGER_INTERFACE,
QDBusConnection::SessionBus);
m_dbus.startServices();
}
void FunctionalTests::testManagerReady_data()
{
QTest::addColumn("haveGetAccountsMethod");
QTest::newRow("no GetAccounts method") << false;
QTest::newRow("with GetAccounts method") << true;
}
void FunctionalTests::testManagerReady()
{
QFETCH(bool, haveGetAccountsMethod);
if (haveGetAccountsMethod) {
addMockedMethod("GetAccounts", "a{sv}", "a(ua{sv})", "ret = []");
}
OnlineAccounts::Manager manager("my-app");
QSignalSpy ready(&manager, SIGNAL(ready()));
manager.waitForReady();
QVERIFY(manager.isReady());
QCOMPARE(ready.count(), 1);
}
void FunctionalTests::testManagerAvailableAccounts_data()
{
QTest::addColumn("reply");
QTest::addColumn >("expectedIds");
QTest::addColumn("expectedDisplayNames");
QTest::newRow("no accounts") <<
"ret = []" <<
QList() <<
QStringList();
QTest::newRow("one account, no data") <<
"ret = [(1, {'displayName': 'Tom'})]" <<
(QList() << 1) <<
(QStringList() << "Tom");
}
void FunctionalTests::testManagerAvailableAccounts()
{
QFETCH(QString, reply);
QFETCH(QList, expectedIds);
QFETCH(QStringList, expectedDisplayNames);
addMockedMethod("GetAccounts", "a{sv}", "a(ua{sv})", reply);
OnlineAccounts::Manager manager("my-app");
manager.waitForReady();
QList ids;
QStringList displayNames;
Q_FOREACH(OnlineAccounts::Account *account, manager.availableAccounts()) {
ids.append(account->id());
displayNames.append(account->displayName());
}
QCOMPARE(ids, expectedIds);
QCOMPARE(displayNames, expectedDisplayNames);
}
void FunctionalTests::testManagerAccount()
{
addMockedMethod("GetAccounts", "a{sv}", "a(ua{sv})",
"ret = [(1, {'displayName': 'John'})]");
OnlineAccounts::Manager manager("my-app");
manager.waitForReady();
// retrieve an invalid account
OnlineAccounts::Account *account = manager.account(4);
QVERIFY(!account);
// valid account
account = manager.account(1);
QVERIFY(account);
QCOMPARE(account->displayName(), QString("John"));
}
void FunctionalTests::testManagerRequestAccess_data()
{
QTest::addColumn("reply");
QTest::addColumn("waitForFinished");
QTest::addColumn("errorCode");
QTest::addColumn("displayName");
QTest::addColumn("accessToken");
QTest::newRow("dbus error") <<
"raise dbus.exceptions.DBusException('org.foo.bar', 'not foobarized')" <<
true <<
int(OnlineAccounts::Error::PermissionDenied) <<
"" <<
"";
QTest::newRow("access granted") <<
"ret = ((1, {'displayName': 'Bob'}),{'AccessToken':'GoOn'})" <<
true <<
int(0) <<
"Bob" <<
"GoOn";
QTest::newRow("access granted, no wait") <<
"ret = ((1, {'displayName': 'Bob'}),{'AccessToken':'GoOn'})" <<
false <<
int(0) <<
"Bob" <<
"GoOn";
}
void FunctionalTests::testManagerRequestAccess()
{
QFETCH(QString, reply);
QFETCH(bool, waitForFinished);
QFETCH(int, errorCode);
QFETCH(QString, displayName);
QFETCH(QString, accessToken);
addMockedMethod("GetAccounts", "a{sv}", "a(ua{sv})", "ret = []");
addMockedMethod("RequestAccess", "sa{sv}", "(ua{sv})a{sv}", reply);
OnlineAccounts::Manager manager("my-app");
manager.waitForReady();
OnlineAccounts::OAuth2Data oauth;
oauth.setClientId("happy app");
OnlineAccounts::PendingCall call = manager.requestAccess("my-service",
oauth);
if (waitForFinished) {
call.waitForFinished();
QVERIFY(call.isFinished());
}
OnlineAccounts::RequestAccessReply accessReply(call);
QCOMPARE(int(accessReply.error().code()), errorCode);
OnlineAccounts::Account *account = accessReply.account();
if (errorCode > 0) {
QVERIFY(!account);
} else {
QVERIFY(account);
QCOMPARE(account->displayName(), displayName);
}
OnlineAccounts::OAuth2Reply oauthReply(call);
QCOMPARE(int(oauthReply.error().code()), errorCode);
QCOMPARE(oauthReply.accessToken(), accessToken.toUtf8());
}
void FunctionalTests::testAccountData_data()
{
QTest::addColumn("reply");
QTest::addColumn("accountId");
QTest::addColumn("displayName");
QTest::addColumn("serviceId");
QTest::addColumn("authenticationMethod");
QTest::addColumn("settings");
QTest::newRow("empty account") <<
"ret = [(1, {})]" <<
1 <<
"" << "" << 0 << QVariantMap();
QTest::newRow("no settings") <<
"ret = [(3, {"
" 'displayName': 'Bob',"
" 'serviceId': 'MyService',"
" 'authMethod': 1,"
"})]" <<
3 <<
"Bob" <<
"MyService" <<
1 <<
QVariantMap();
QVariantMap settings;
settings.insert("Host", "example.com");
settings.insert("Port", int(7000));
QTest::newRow("with settings") <<
"ret = [(4, {"
" 'displayName': 'Tom',"
" 'serviceId': 'MyService',"
" 'authMethod': 2,"
" 'settings/Host': 'example.com',"
" 'settings/Port': 7000,"
"})]" <<
4 <<
"Tom" <<
"MyService" <<
2 <<
settings;
}
void FunctionalTests::testAccountData()
{
QFETCH(QString, reply);
QFETCH(int, accountId);
QFETCH(QString, displayName);
QFETCH(QString, serviceId);
QFETCH(int, authenticationMethod);
QFETCH(QVariantMap, settings);
addMockedMethod("GetAccounts", "a{sv}", "a(ua{sv})", reply);
OnlineAccounts::Manager manager("my-app");
manager.waitForReady();
QList accounts = manager.availableAccounts();
QCOMPARE(accounts.count(), 1);
OnlineAccounts::Account *account = accounts.first();
QVERIFY(account);
QVERIFY(account->isValid());
QCOMPARE(int(account->id()), accountId);
QCOMPARE(account->displayName(), displayName);
QCOMPARE(account->serviceId(), serviceId);
QCOMPARE(int(account->authenticationMethod()), authenticationMethod);
QVariantMap accountSettings;
Q_FOREACH(const QString &key, account->keys()) {
accountSettings.insert(key, account->setting(key));
}
QCOMPARE(accountSettings, settings);
delete account;
}
void FunctionalTests::testPendingCallWatcher()
{
addMockedMethod("GetAccounts", "a{sv}", "a(ua{sv})", "ret = []");
addMockedMethod("RequestAccess", "sa{sv}", "(ua{sv})a{sv}",
"ret = ((1, {'displayName': 'Bob'}),{})");
OnlineAccounts::Manager manager("my-app");
manager.waitForReady();
OnlineAccounts::OAuth2Data oauth;
oauth.setClientId("happy app");
OnlineAccounts::PendingCall call = manager.requestAccess("my-service",
oauth);
// Test also the PendingCall assignment operator
OnlineAccounts::PendingCall otherCall(call);
call = otherCall;
QVERIFY(!call.isFinished());
QVERIFY(!otherCall.isFinished());
OnlineAccounts::PendingCallWatcher *watcher =
new OnlineAccounts::PendingCallWatcher(otherCall);
QSignalSpy finished(watcher, SIGNAL(finished()));
QVERIFY(finished.wait());
QCOMPARE(finished.count(), 1);
QVERIFY(call.isFinished());
QVERIFY(otherCall.isFinished());
delete watcher;
}
void FunctionalTests::testAccountChanges()
{
addMockedMethod("GetAccounts", "a{sv}", "a(ua{sv})", "ret = []");
OnlineAccounts::Manager manager("my-app");
QSignalSpy accountAvailable(&manager,
SIGNAL(accountAvailable(OnlineAccounts::Account*)));
manager.waitForReady();
QVariantMap changes;
changes.insert(ONLINE_ACCOUNTS_INFO_KEY_CHANGE_TYPE,
uint(ONLINE_ACCOUNTS_INFO_CHANGE_ENABLED));
changes.insert(ONLINE_ACCOUNTS_INFO_KEY_DISPLAY_NAME, "John");
changes.insert(ONLINE_ACCOUNTS_INFO_KEY_SERVICE_ID, "coolService");
emitAccountChanged("coolService", 5, changes);
QVERIFY(accountAvailable.wait());
QCOMPARE(accountAvailable.count(), 1);
OnlineAccounts::Account *account =
accountAvailable.at(0).at(0).value();
QSignalSpy changed(account, SIGNAL(changed()));
QSignalSpy disabled(account, SIGNAL(disabled()));
QVERIFY(account);
QVERIFY(account->isValid());
QCOMPARE(account->id(), OnlineAccounts::AccountId(5));
QCOMPARE(account->displayName(), QString("John"));
QCOMPARE(account->serviceId(), QString("coolService"));
/* Now change some of the account data */
accountAvailable.clear();
changes.clear();
changes.insert(ONLINE_ACCOUNTS_INFO_KEY_CHANGE_TYPE,
uint(ONLINE_ACCOUNTS_INFO_CHANGE_UPDATED));
changes.insert(ONLINE_ACCOUNTS_INFO_KEY_DISPLAY_NAME, "Bob");
changes.insert(ONLINE_ACCOUNTS_INFO_KEY_SERVICE_ID, "coolService");
emitAccountChanged("coolService", 5, changes);
QVERIFY(changed.wait());
QCOMPARE(accountAvailable.count(), 0);
QCOMPARE(changed.count(), 1);
QCOMPARE(disabled.count(), 0);
QVERIFY(account->isValid());
QCOMPARE(account->id(), OnlineAccounts::AccountId(5));
QCOMPARE(account->displayName(), QString("Bob"));
QCOMPARE(account->serviceId(), QString("coolService"));
/* Now disable the account */
changed.clear();
changes.clear();
changes.insert(ONLINE_ACCOUNTS_INFO_KEY_CHANGE_TYPE,
uint(ONLINE_ACCOUNTS_INFO_CHANGE_DISABLED));
changes.insert(ONLINE_ACCOUNTS_INFO_KEY_DISPLAY_NAME, "Bob");
changes.insert(ONLINE_ACCOUNTS_INFO_KEY_SERVICE_ID, "coolService");
emitAccountChanged("coolService", 5, changes);
QVERIFY(disabled.wait());
QCOMPARE(accountAvailable.count(), 0);
QCOMPARE(changed.count(), 0);
QCOMPARE(disabled.count(), 1);
QVERIFY(!account->isValid());
}
void FunctionalTests::testAuthentication()
{
addMockedMethod("GetAccounts", "a{sv}", "a(ua{sv})",
"ret = ["
"(1, {"
" 'displayName': 'Bob',"
" 'serviceId': 'MyService0',"
" 'authMethod': 1,"
"}),"
"(2, {"
" 'displayName': 'Tom',"
" 'serviceId': 'MyService1',"
" 'authMethod': 2,"
"}),"
"(3, {"
" 'displayName': 'Sam',"
" 'serviceId': 'MyService2',"
" 'authMethod': 3,"
"}),"
"(4, {"
" 'displayName': 'Jim',"
" 'serviceId': 'MyService3',"
" 'authMethod': 4,"
"}),"
"]");
addMockedMethod("Authenticate", "usbba{sv}", "a{sv}",
"if args[0] == 1:\n"
" ret = {"
" 'ConsumerKey': args[4]['ConsumerKey'],"
" 'ConsumerSecret': args[4]['ConsumerSecret'],"
" 'Token': 'a token',"
" 'TokenSecret': 'a token secret',"
" 'SignatureMethod': 'PLAIN',"
" }\n"
"elif args[0] == 2:\n"
" ret = {"
" 'AccessToken': 'my token',"
" 'ExpiresIn': 3600,"
" 'GrantedScopes': args[4]['Scopes'],"
" }\n"
"elif args[0] == 3:\n"
" ret = {"
" 'Username': 'admin',"
" 'Password': 'rootme',"
" }\n"
"elif args[0] == 4:\n"
" ret = {"
" 'Response': 'pong',"
" 'ChosenMechanism': 'tennis',"
" 'state': 1,"
" }\n"
"else:\n"
" ret = {}");
OnlineAccounts::Manager manager("my-app");
manager.waitForReady();
/* Test OAuth 1.0 */
OnlineAccounts::Account *account = manager.account(1);
QVERIFY(account);
QCOMPARE(account->authenticationMethod(),
OnlineAccounts::AuthenticationMethodOAuth1);
OnlineAccounts::OAuth1Data oauth1data;
oauth1data.setInteractive(false);
oauth1data.setConsumerKey("a key");
QCOMPARE(oauth1data.consumerKey(), QByteArray("a key"));
oauth1data.setConsumerSecret("a secret");
QCOMPARE(oauth1data.consumerSecret(), QByteArray("a secret"));
OnlineAccounts::OAuth1Reply oauth1reply(account->authenticate(oauth1data));
QCOMPARE(oauth1reply.consumerKey(), QByteArray("a key"));
QCOMPARE(oauth1reply.consumerSecret(), QByteArray("a secret"));
QCOMPARE(oauth1reply.token(), QByteArray("a token"));
QCOMPARE(oauth1reply.tokenSecret(), QByteArray("a token secret"));
QCOMPARE(oauth1reply.signatureMethod(), QByteArray("PLAIN"));
/* Compare the whole data dictionary */
QVariantMap expectedData;
expectedData.insert(ONLINE_ACCOUNTS_AUTH_KEY_CONSUMER_KEY, "a key");
expectedData.insert(ONLINE_ACCOUNTS_AUTH_KEY_CONSUMER_SECRET, "a secret");
expectedData.insert(ONLINE_ACCOUNTS_AUTH_KEY_TOKEN, "a token");
expectedData.insert(ONLINE_ACCOUNTS_AUTH_KEY_TOKEN_SECRET, "a token secret");
expectedData.insert(ONLINE_ACCOUNTS_AUTH_KEY_SIGNATURE_METHOD, "PLAIN");
QCOMPARE(oauth1reply.data(), expectedData);
/* Test OAuth 2.0 */
account = manager.account(2);
QVERIFY(account);
QCOMPARE(account->authenticationMethod(),
OnlineAccounts::AuthenticationMethodOAuth2);
OnlineAccounts::OAuth2Data oauth2data;
oauth2data.invalidateCachedReply();
QVERIFY(oauth2data.mustInvalidateCachedReply());
oauth2data.setClientId("a client");
QCOMPARE(oauth2data.clientId(), QByteArray("a client"));
oauth2data.setClientSecret("a secret");
QCOMPARE(oauth2data.clientSecret(), QByteArray("a secret"));
QList scopes =
QList() << "one" << "two" << "three";
oauth2data.setScopes(scopes);
QCOMPARE(oauth2data.scopes(), scopes);
OnlineAccounts::OAuth2Reply oauth2reply(account->authenticate(oauth2data));
QCOMPARE(oauth2reply.accessToken(), QByteArray("my token"));
QCOMPARE(oauth2reply.expiresIn(), 3600);
QCOMPARE(oauth2reply.grantedScopes(), scopes);
/* Test SASL */
account = manager.account(4);
QVERIFY(account);
QCOMPARE(account->authenticationMethod(),
OnlineAccounts::AuthenticationMethodSasl);
OnlineAccounts::SaslData sasldata;
OnlineAccounts::SaslReply saslreply(account->authenticate(sasldata));
QCOMPARE(saslreply.chosenMechanism(), QString("tennis"));
QCOMPARE(saslreply.response(), QByteArray("pong"));
QCOMPARE(saslreply.state(), OnlineAccounts::SaslReply::Continue);
/* Test Password */
account = manager.account(3);
QVERIFY(account);
QCOMPARE(account->authenticationMethod(),
OnlineAccounts::AuthenticationMethodPassword);
OnlineAccounts::PasswordData pwdata;
OnlineAccounts::PasswordReply pwreply(account->authenticate(pwdata));
QCOMPARE(pwreply.username(), QByteArray("admin"));
QCOMPARE(pwreply.password(), QByteArray("rootme"));
/* Test the copy constructor */
OnlineAccounts::OAuth2Data copy(oauth2data);
QCOMPARE(copy.clientId(), QByteArray("a client"));
/* Trigger the copy on write */
copy.setClientId("new client");
QCOMPARE(copy.clientId(), QByteArray("new client"));
QCOMPARE(oauth2data.clientId(), QByteArray("a client"));
}
void FunctionalTests::testAuthenticationErrors_data()
{
QTest::addColumn("reply");
QTest::addColumn("errorCode");
QTest::addColumn("errorMessage");
QTest::newRow("random dbus error") <<
"raise dbus.exceptions.DBusException('not foobarized', name='org.foo.bar')" <<
int(OnlineAccounts::Error::PermissionDenied) <<
"not foobarized";
QTest::newRow("no account") <<
"raise dbus.exceptions.DBusException('Not there',"
"name='" ONLINE_ACCOUNTS_ERROR_NO_ACCOUNT "')" <<
int(OnlineAccounts::Error::NoAccount) <<
"Not there";
QTest::newRow("user canceled") <<
"raise dbus.exceptions.DBusException('Sorry',"
"name='" ONLINE_ACCOUNTS_ERROR_USER_CANCELED "')" <<
int(OnlineAccounts::Error::UserCanceled) <<
"Sorry";
QTest::newRow("permission denied") <<
"raise dbus.exceptions.DBusException('Nope',"
"name='" ONLINE_ACCOUNTS_ERROR_PERMISSION_DENIED "')" <<
int(OnlineAccounts::Error::PermissionDenied) <<
"Nope";
QTest::newRow("Interaction required") <<
"raise dbus.exceptions.DBusException('Ask the user',"
"name='" ONLINE_ACCOUNTS_ERROR_INTERACTION_REQUIRED "')" <<
int(OnlineAccounts::Error::InteractionRequired) <<
"Ask the user";
}
void FunctionalTests::testAuthenticationErrors()
{
QFETCH(QString, reply);
QFETCH(int, errorCode);
QFETCH(QString, errorMessage);
addMockedMethod("GetAccounts", "a{sv}", "a(ua{sv})",
"ret = [(1, {"
" 'displayName': 'Bob',"
" 'serviceId': 'MyService0',"
" 'authMethod': 2,"
"})]");
addMockedMethod("Authenticate", "usbba{sv}", "a{sv}", reply);
OnlineAccounts::Manager manager("my-app");
manager.waitForReady();
OnlineAccounts::Account *account = manager.account(1);
QVERIFY(account);
OnlineAccounts::OAuth2Data oauth2data;
oauth2data.setClientId("a client");
oauth2data.setClientSecret("a secret");
oauth2data.setScopes(QList() << "one" << "two");
OnlineAccounts::OAuth2Reply r(account->authenticate(oauth2data));
QVERIFY(r.hasError());
QCOMPARE(int(r.error().code()), errorCode);
QCOMPARE(r.error().text(), errorMessage);
}
QTEST_MAIN(FunctionalTests)
#include "functional_tests.moc"
online-accounts-api-0.1+16.04.20160212/tests/lib/OnlineAccounts/tst_authentication_data/ 0000755 0000156 0000165 00000000000 12657307121 031322 5 ustar pbuser pbgroup 0000000 0000000 ././@LongLink 0000000 0000000 0000000 00000000164 00000000000 011216 L ustar 0000000 0000000 online-accounts-api-0.1+16.04.20160212/tests/lib/OnlineAccounts/tst_authentication_data/tst_authentication_data.cpp online-accounts-api-0.1+16.04.20160212/tests/lib/OnlineAccounts/tst_authentication_data/tst_authenti0000644 0000156 0000165 00000003662 12657306726 034001 0 ustar pbuser pbgroup 0000000 0000000 /*
* This file is part of libOnlineAccounts
*
* Copyright (C) 2015 Canonical Ltd.
*
* Contact: Alberto Mardegan
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include
#include
#include "authentication_data.h"
using namespace OnlineAccounts;
class AuthenticationDataTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void testData();
};
void AuthenticationDataTest::testData()
{
OAuth2Data oauth2;
oauth2.setClientId("client");
QCOMPARE(oauth2.clientId(), QByteArray("client"));
oauth2.setInteractive(false);
QCOMPARE(oauth2.interactive(), false);
OAuth2Data copy = oauth2;
QCOMPARE(copy.clientId(), QByteArray("client"));
QCOMPARE(copy.interactive(), false);
oauth2.setClientId("client-changed");
QCOMPARE(oauth2.clientId(), QByteArray("client-changed"));
QCOMPARE(copy.clientId(), QByteArray("client"));
/* As dictionary */
QVariantMap expectedParameters;
expectedParameters.insert("ClientId", "client-changed");
QCOMPARE(oauth2.parameters(), expectedParameters);
QVariantMap parameters;
parameters.insert("UnknownKey", "some value");
parameters.insert("Hello", "World");
oauth2.setParameters(parameters);
QCOMPARE(oauth2.parameters(), parameters);
}
QTEST_MAIN(AuthenticationDataTest)
#include "tst_authentication_data.moc"
././@LongLink 0000000 0000000 0000000 00000000147 00000000000 011217 L ustar 0000000 0000000 online-accounts-api-0.1+16.04.20160212/tests/lib/OnlineAccounts/tst_authentication_data/CMakeLists.txt online-accounts-api-0.1+16.04.20160212/tests/lib/OnlineAccounts/tst_authentication_data/CMakeLists.t0000644 0000156 0000165 00000000660 12657306726 033522 0 ustar pbuser pbgroup 0000000 0000000 set(TEST tst_authentication_data)
set(SOURCES
${OnlineAccountsQt_SOURCE_DIR}/authentication_data.cpp
tst_authentication_data.cpp
)
add_executable(${TEST} ${SOURCES})
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${OnlineAccountsQt_SOURCE_DIR}
${OnlineAccountsDaemon_SOURCE_DIR}/..
)
qt5_use_modules(${TEST} Core DBus Test)
add_test(${TEST} ${CMAKE_CURRENT_BINARY_DIR}/${TEST})
add_dependencies(check ${TEST})
online-accounts-api-0.1+16.04.20160212/tests/lib/OnlineAccounts/CMakeLists.txt 0000644 0000156 0000165 00000000115 12657306726 027167 0 ustar pbuser pbgroup 0000000 0000000 add_subdirectory(functional_tests)
add_subdirectory(tst_authentication_data)
online-accounts-api-0.1+16.04.20160212/tests/lib/qml_module/ 0000755 0000156 0000165 00000000000 12657307121 023632 5 ustar pbuser pbgroup 0000000 0000000 online-accounts-api-0.1+16.04.20160212/tests/lib/qml_module/tst_qml_module.cpp 0000644 0000156 0000165 00000051255 12657306740 027404 0 ustar pbuser pbgroup 0000000 0000000 /*
* This file is part of OnlineAccountsModule
*
* Copyright (C) 2015 Canonical Ltd.
*
* Contact: Alberto Mardegan
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "OnlineAccountsDaemon/dbus_constants.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
namespace QTest {
template<>
char *toString(const QVariantMap &map)
{
QJsonDocument doc(QJsonObject::fromVariantMap(map));
return qstrdup(doc.toJson(QJsonDocument::Compact).data());
}
} // QTest namespace
class ModuleTest: public QObject
{
Q_OBJECT
public:
ModuleTest();
OrgFreedesktopDBusMockInterface &mocked() {
return m_mock.mockInterface(ONLINE_ACCOUNTS_MANAGER_SERVICE_NAME,
ONLINE_ACCOUNTS_MANAGER_PATH,
ONLINE_ACCOUNTS_MANAGER_INTERFACE,
QDBusConnection::SessionBus);
}
void addMockedMethod(const QString &name,
const QString &in_sig,
const QString &out_sig,
const QString &code)
{
return mocked().AddMethod(ONLINE_ACCOUNTS_MANAGER_INTERFACE,
name, in_sig, out_sig, code).waitForFinished();
}
void emitAccountChanged(const QString &service,
uint accountId,
const QVariantMap &changes)
{
QVariantList args;
args << service;
QDBusArgument info;
info.beginStructure();
info << accountId << changes;
info.endStructure();
args << QVariant::fromValue(info);
mocked().EmitSignal(ONLINE_ACCOUNTS_MANAGER_INTERFACE,
"AccountChanged", "s(ua{sv})",
args);
}
QVariant get(const QAbstractListModel *model, int row, QString roleName)
{
QHash roleNames = model->roleNames();
int role = roleNames.key(roleName.toLatin1(), -1);
return model->data(model->index(row), role);
}
private Q_SLOTS:
void initTestCase();
void testModuleImport();
void testModelProperties();
void testModelRoles_data();
void testModelRoles();
void testModelFilters_data();
void testModelFilters();
void testModelChanges();
void testModelRequestAccess_data();
void testModelRequestAccess();
void testAccountAuthentication_data();
void testAccountAuthentication();
void testInitialization_data();
void testInitialization();
private:
QtDBusTest::DBusTestRunner m_dbus;
QtDBusMock::DBusMock m_mock;
};
ModuleTest::ModuleTest():
QObject(),
m_mock(m_dbus)
{
m_mock.registerCustomMock(ONLINE_ACCOUNTS_MANAGER_SERVICE_NAME,
ONLINE_ACCOUNTS_MANAGER_PATH,
ONLINE_ACCOUNTS_MANAGER_INTERFACE,
QDBusConnection::SessionBus);
m_dbus.startServices();
}
void ModuleTest::initTestCase()
{
qputenv("QML2_IMPORT_PATH", TEST_QML_IMPORT_PATH);
}
void ModuleTest::testModuleImport()
{
QQmlEngine engine;
QQmlComponent component(&engine);
component.setData("import Ubuntu.OnlineAccounts 2.0\n"
"AccountModel {}",
QUrl());
QObject *object = component.create();
QVERIFY(object != 0);
delete object;
}
void ModuleTest::testModelProperties()
{
QQmlEngine engine;
QQmlComponent component(&engine);
component.setData("import Ubuntu.OnlineAccounts 2.0\n"
"AccountModel {}",
QUrl());
QObject *object = component.create();
QVERIFY(object != 0);
QVERIFY(object->setProperty("applicationId", "foo"));
QCOMPARE(object->property("applicationId").toString(), QString("foo"));
QVERIFY(object->setProperty("serviceId", "bar"));
QCOMPARE(object->property("serviceId").toString(), QString("bar"));
QCOMPARE(object->property("ready").toBool(), false);
delete object;
}
void ModuleTest::testModelRoles_data()
{
QTest::addColumn("accountData");
QTest::addColumn("displayName");
QTest::addColumn("serviceId");
QTest::addColumn("authenticationMethod");
QTest::addColumn("settings");
QVariantMap settings;
QTest::newRow("empty") <<
"{}" <<
"" << "" << 0 << settings;
settings.insert("Server", "www.example.com");
settings.insert("Port", "9900");
QTest::newRow("complete") <<
"{"
" '" ONLINE_ACCOUNTS_INFO_KEY_DISPLAY_NAME "': 'Tom',"
" '" ONLINE_ACCOUNTS_INFO_KEY_SERVICE_ID "': 'cool',"
" '" ONLINE_ACCOUNTS_INFO_KEY_AUTH_METHOD "': 2,"
" '" ONLINE_ACCOUNTS_INFO_KEY_SETTINGS "Server': 'www.example.com',"
" '" ONLINE_ACCOUNTS_INFO_KEY_SETTINGS "Port': 9900,"
"}" <<
"Tom" << "cool" << 2 << settings;
}
void ModuleTest::testModelRoles()
{
QFETCH(QString, accountData);
QFETCH(QString, displayName);
QFETCH(QString, serviceId);
QFETCH(int, authenticationMethod);
QFETCH(QVariantMap, settings);
addMockedMethod("GetAccounts", "a{sv}", "a(ua{sv})",
QString("ret = [(1, %1)]").arg(accountData));
QQmlEngine engine;
QQmlComponent component(&engine);
component.setData("import Ubuntu.OnlineAccounts 2.0\n"
"AccountModel { applicationId: \"foo\" }",
QUrl());
QObject *object = component.create();
QVERIFY(object != 0);
QAbstractListModel *model = qobject_cast(object);
QVERIFY(model != 0);
QCOMPARE(object->property("ready").toBool(), false);
QSignalSpy ready(object, SIGNAL(isReadyChanged()));
ready.wait();
QCOMPARE(object->property("ready").toBool(), true);
QCOMPARE(model->rowCount(), 1);
QCOMPARE(model->data(model->index(0), Qt::DisplayRole).toString(),
QString("%1 - %2").arg(displayName).arg(serviceId));
QCOMPARE(get(model, 0, "displayName").toString(), displayName);
QCOMPARE(get(model, 0, "valid").toBool(), true);
QCOMPARE(get(model, 0, "accountId").toInt(), 1);
QCOMPARE(get(model, 0, "serviceId").toString(), serviceId);
QCOMPARE(get(model, 0, "authenticationMethod").toInt(),
authenticationMethod);
// until https://bugs.launchpad.net/bugs/1479768 is fixed
QCOMPARE(get(model, 0, "settings").toMap(), settings);
QObject *account = get(model, 0, "account").value();
QVERIFY(account != 0);
QCOMPARE(account->metaObject()->className(), "OnlineAccountsModule::Account");
QCOMPARE(account,
model->property("accountList").value >().first());
delete object;
}
void ModuleTest::testModelFilters_data()
{
QTest::addColumn("reply");
QTest::addColumn("filters");
QTest::addColumn >("expectedIds");
QTest::addColumn("expectedDisplayNames");
QTest::newRow("no accounts") <<
"ret = []" <<
"" <<
QList();
QTest::newRow("one account, no service filter") <<
"ret = [(1, {'displayName': 'Tom', 'serviceId': 'Foo' })]" <<
"" <<
(QList() << 1);
QTest::newRow("one account, with service filter") <<
"ret = [(1, {'displayName': 'Tom', 'serviceId': 'Foo' })]" <<
"serviceId: \"bar\"" <<
QList();
}
void ModuleTest::testModelFilters()
{
QFETCH(QString, reply);
QFETCH(QString, filters);
QFETCH(QList, expectedIds);
addMockedMethod("GetAccounts", "a{sv}", "a(ua{sv})", reply);
QQmlEngine engine;
QQmlComponent component(&engine);
component.setData("import Ubuntu.OnlineAccounts 2.0\n"
"AccountModel {\n"
" applicationId: \"foo\";" + filters.toUtf8() + "\n"
"}",
QUrl());
QObject *object = component.create();
QVERIFY(object != 0);
QAbstractListModel *model = qobject_cast(object);
QVERIFY(model != 0);
QTRY_COMPARE(model->property("count").toInt(), expectedIds.count());
QList ids;
QStringList displayNames;
for (int i = 0; i < expectedIds.count(); i++) {
ids.append(get(model, i, "accountId").toInt());
}
QCOMPARE(ids, expectedIds);
delete object;
}
void ModuleTest::testModelChanges()
{
addMockedMethod("GetAccounts", "a{sv}", "a(ua{sv})", "ret = []");
QQmlEngine engine;
QQmlComponent component(&engine);
component.setData("import Ubuntu.OnlineAccounts 2.0\n"
"AccountModel { applicationId: \"foo\" }",
QUrl());
QObject *object = component.create();
QVERIFY(object != 0);
QAbstractListModel *model = qobject_cast(object);
QVERIFY(model != 0);
QSignalSpy countChanged(model, SIGNAL(countChanged()));
QSignalSpy dataChanged(model, SIGNAL(dataChanged(const QModelIndex&,
const QModelIndex&)));
QVariantMap changes;
changes.insert(ONLINE_ACCOUNTS_INFO_KEY_CHANGE_TYPE,
uint(ONLINE_ACCOUNTS_INFO_CHANGE_ENABLED));
changes.insert(ONLINE_ACCOUNTS_INFO_KEY_DISPLAY_NAME, "John");
changes.insert(ONLINE_ACCOUNTS_INFO_KEY_SERVICE_ID, "coolService");
emitAccountChanged("coolService", 5, changes);
QVERIFY(countChanged.wait());
QCOMPARE(dataChanged.count(), 0);
QTRY_COMPARE(model->rowCount(), 1);
QCOMPARE(model->property("accountList").value().count(), 1);
QCOMPARE(get(model, 0, "displayName").toString(), QString("John"));
QObject *account =
model->property("accountList").value().first();
QSignalSpy accountChanged(account, SIGNAL(accountChanged()));
QSignalSpy validChanged(account, SIGNAL(validChanged()));
QVERIFY(account);
QVERIFY(account->property("valid").toBool());
QCOMPARE(account->property("displayName").toString(), QString("John"));
countChanged.clear();
// Change the display name
changes.clear();
changes.insert(ONLINE_ACCOUNTS_INFO_KEY_CHANGE_TYPE,
uint(ONLINE_ACCOUNTS_INFO_CHANGE_UPDATED));
changes.insert(ONLINE_ACCOUNTS_INFO_KEY_DISPLAY_NAME, "Bob");
changes.insert(ONLINE_ACCOUNTS_INFO_KEY_SERVICE_ID, "coolService");
emitAccountChanged("coolService", 5, changes);
QVERIFY(dataChanged.wait());
QCOMPARE(dataChanged.count(), 1);
QCOMPARE(countChanged.count(), 0);
QCOMPARE(accountChanged.count(), 1);
QCOMPARE(validChanged.count(), 0);
QCOMPARE(get(model, 0, "displayName").toString(), QString("Bob"));
dataChanged.clear();
accountChanged.clear();
// disable the account
changes.clear();
changes.insert(ONLINE_ACCOUNTS_INFO_KEY_CHANGE_TYPE,
uint(ONLINE_ACCOUNTS_INFO_CHANGE_DISABLED));
changes.insert(ONLINE_ACCOUNTS_INFO_KEY_DISPLAY_NAME, "Bob");
changes.insert(ONLINE_ACCOUNTS_INFO_KEY_SERVICE_ID, "coolService");
emitAccountChanged("coolService", 5, changes);
QVERIFY(countChanged.wait());
QCOMPARE(countChanged.count(), 1);
QCOMPARE(accountChanged.count(), 0);
QCOMPARE(validChanged.count(), 1);
QCOMPARE(model->rowCount(), 0);
QCOMPARE(model->property("accountList").value().count(), 0);
QCOMPARE(account->property("valid").toBool(), false);
delete object;
}
void ModuleTest::testModelRequestAccess_data()
{
QTest::addColumn("reply");
QTest::addColumn("expectedAccessReply");
QTest::addColumn("expectedAuthenticationData");
QVariantMap accessReply;
QVariantMap authenticationData;
accessReply["errorCode"] = 4;
accessReply["errorText"] = "('org.foo.bar', 'not foobarized')";
QTest::newRow("dbus error") <<
"raise dbus.exceptions.DBusException('org.foo.bar', 'not foobarized')" <<
accessReply <<
authenticationData;
accessReply.clear();
accessReply["accountDisplayName"] = "Bob";
authenticationData.clear();
authenticationData.insert("AccessToken", "GoOn");
QTest::newRow("access granted") <<
"ret = ((1, {'displayName': 'Bob'}),{'AccessToken':'GoOn'})" <<
accessReply <<
authenticationData;
}
void ModuleTest::testModelRequestAccess()
{
QFETCH(QString, reply);
QFETCH(QVariantMap, expectedAccessReply);
QFETCH(QVariantMap, expectedAuthenticationData);
addMockedMethod("GetAccounts", "a{sv}", "a(ua{sv})",
"ret = [(1, {'displayName': 'Tom', 'serviceId': 'Foo' })]");
addMockedMethod("RequestAccess", "sa{sv}", "(ua{sv})a{sv}", reply);
QQmlEngine engine;
QQmlComponent component(&engine);
component.setData("import Ubuntu.OnlineAccounts 2.0\n"
"AccountModel {\n"
" applicationId: \"foo\"\n"
"}",
QUrl());
QObject *object = component.create();
QVERIFY(object != 0);
QAbstractListModel *model = qobject_cast(object);
QVERIFY(model != 0);
QSignalSpy accessReplySpy(model,
SIGNAL(accessReply(const QVariantMap&,const QVariantMap&)));
QString serviceId = "bar";
QVariantMap params;
bool ok = QMetaObject::invokeMethod(model, "requestAccess",
Q_ARG(QString, serviceId),
Q_ARG(QVariantMap, params));
QVERIFY(ok);
QVERIFY(accessReplySpy.wait());
QVariantMap accessReply = accessReplySpy.at(0).at(0).toMap();
QVariantMap authenticationData = accessReplySpy.at(0).at(1).toMap();
if (expectedAccessReply.contains("accountDisplayName")) {
QObject *account = accessReply["account"].value();
QVERIFY(account != 0);
QCOMPARE(account->metaObject()->className(),
"OnlineAccountsModule::Account");
QCOMPARE(account->property("displayName").toString(),
expectedAccessReply["accountDisplayName"].toString());
} else {
QCOMPARE(accessReply, expectedAccessReply);
}
QCOMPARE(authenticationData, expectedAuthenticationData);
delete object;
}
void ModuleTest::testAccountAuthentication_data()
{
QTest::addColumn("authMethod");
QTest::addColumn("reply");
QTest::addColumn("params");
QTest::addColumn("expectedAuthenticationData");
QVariantMap params;
QVariantMap authenticationData;
authenticationData["errorCode"] = 4;
authenticationData["errorText"] = "not foobarized";
QTest::newRow("random dbus error") <<
ONLINE_ACCOUNTS_AUTH_METHOD_OAUTH1 <<
"raise dbus.exceptions.DBusException('not foobarized', name='org.foo.bar')" <<
params <<
authenticationData;
authenticationData["errorCode"] = 1;
authenticationData["errorText"] = "Not there";
QTest::newRow("no account") <<
ONLINE_ACCOUNTS_AUTH_METHOD_OAUTH1 <<
"raise dbus.exceptions.DBusException('Not there',"
"name='" ONLINE_ACCOUNTS_ERROR_NO_ACCOUNT "')" <<
params <<
authenticationData;
authenticationData["errorCode"] = 3;
authenticationData["errorText"] = "Sorry";
QTest::newRow("user canceled") <<
ONLINE_ACCOUNTS_AUTH_METHOD_OAUTH1 <<
"raise dbus.exceptions.DBusException('Sorry',"
"name='" ONLINE_ACCOUNTS_ERROR_USER_CANCELED "')" <<
params <<
authenticationData;
params["ConsumerKey"] = "aaaa";
params["ConsumerSecret"] = "bbb";
authenticationData = params;
authenticationData["Token"] = "a token";
authenticationData["TokenSecret"] = "a token secret";
authenticationData["SignatureMethod"] = "PLAIN";
QTest::newRow("oauth 1.0") <<
ONLINE_ACCOUNTS_AUTH_METHOD_OAUTH1 <<
"ret = {"
" 'ConsumerKey': args[4]['ConsumerKey'],"
" 'ConsumerSecret': args[4]['ConsumerSecret'],"
" 'Token': 'a token',"
" 'TokenSecret': 'a token secret',"
" 'SignatureMethod': 'PLAIN',"
"}" <<
params <<
authenticationData;
params.clear();
authenticationData.clear();
params["ClientId"] = "aaaa";
params["ClientSecret"] = "bbb";
params["Scopes"] = (QStringList() << "one" << "two");
authenticationData["AccessToken"] = "my token";
authenticationData["ExpiresIn"] = 3600;
authenticationData["GrantedScopes"] = (QStringList() << "one" << "two");
QTest::newRow("oauth 2.0") <<
ONLINE_ACCOUNTS_AUTH_METHOD_OAUTH2 <<
"ret = {"
" 'AccessToken': 'my token',"
" 'ExpiresIn': 3600,"
" 'GrantedScopes': args[4]['Scopes'],"
"}" <<
params <<
authenticationData;
params.clear();
authenticationData.clear();
authenticationData["Username"] = "admin";
authenticationData["Password"] = "rootme";
QTest::newRow("password") <<
ONLINE_ACCOUNTS_AUTH_METHOD_PASSWORD <<
"ret = {"
" 'Username': 'admin',"
" 'Password': 'rootme',"
"}" <<
params <<
authenticationData;
}
void ModuleTest::testAccountAuthentication()
{
QFETCH(int, authMethod);
QFETCH(QString, reply);
QFETCH(QVariantMap, params);
QFETCH(QVariantMap, expectedAuthenticationData);
addMockedMethod("GetAccounts", "a{sv}", "a(ua{sv})",
QString("ret = [(1, {"
" 'displayName': 'Bob',"
" 'serviceId': 'MyService0',"
" 'authMethod': %1,"
"})]").arg(authMethod));
addMockedMethod("Authenticate", "usbba{sv}", "a{sv}", reply);
QQmlEngine engine;
QQmlComponent component(&engine);
component.setData("import Ubuntu.OnlineAccounts 2.0\n"
"AccountModel {\n"
" applicationId: \"foo\"\n"
"}",
QUrl());
QObject *object = component.create();
QVERIFY(object != 0);
QAbstractListModel *model = qobject_cast(object);
QVERIFY(model != 0);
QTRY_COMPARE(model->rowCount(), 1);
QObject *account =
model->property("accountList").value().first();
QSignalSpy authenticationReply(account,
SIGNAL(authenticationReply(const QVariantMap&)));
bool ok = QMetaObject::invokeMethod(account, "authenticate",
Q_ARG(QVariantMap, params));
QVERIFY(ok);
QVERIFY(authenticationReply.wait());
QVariantMap authenticationData = authenticationReply.at(0).at(0).toMap();
QCOMPARE(authenticationData, expectedAuthenticationData);
delete object;
}
void ModuleTest::testInitialization_data()
{
QTest::addColumn("appId");
QTest::addColumn("errorExpected");
QTest::newRow("empty APP_ID") <<
"" <<
true;
QTest::newRow("invalid APP_ID") <<
"" <<
true;
QTest::newRow("valid APP_ID") <<
"my.package_app_0.2" <<
false;
}
void ModuleTest::testInitialization()
{
QFETCH(QString, appId);
QFETCH(bool, errorExpected);
qputenv("APP_ID", appId.toUtf8());
if (errorExpected) {
QTest::ignoreMessage(QtWarningMsg,
QRegularExpression("Ubuntu.OnlineAccounts:.*"));
}
QQmlEngine engine;
QQmlComponent component(&engine);
component.setData("import Ubuntu.OnlineAccounts 2.0\n"
"AccountModel {}",
QUrl());
QObject *object = component.create();
QVERIFY(object != 0);
if (!errorExpected) {
/* We just want to check that invoking this method won't cause a crash */
QString serviceId = "bar";
QVariantMap params;
bool ok = QMetaObject::invokeMethod(object, "requestAccess",
Q_ARG(QString, serviceId),
Q_ARG(QVariantMap, params));
QVERIFY(ok);
}
delete object;
}
QTEST_MAIN(ModuleTest)
#include "tst_qml_module.moc"
online-accounts-api-0.1+16.04.20160212/tests/lib/qml_module/CMakeLists.txt 0000644 0000156 0000165 00000001243 12657306726 026404 0 ustar pbuser pbgroup 0000000 0000000 set(TEST tst_qml_module)
set(SOURCES
tst_qml_module.cpp
)
pkg_check_modules(QTDBUSMOCK REQUIRED libqtdbusmock-1)
pkg_check_modules(QTDBUSTEST REQUIRED libqtdbustest-1)
add_executable(${TEST} ${SOURCES})
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${OnlineAccountsDaemon_SOURCE_DIR}/..
${QTDBUSMOCK_INCLUDE_DIRS}
${QTDBUSTEST_INCLUDE_DIRS}
)
target_link_libraries(${TEST}
${QTDBUSMOCK_LIBRARIES}
${QTDBUSTEST_LIBRARIES}
)
add_definitions(
-DTEST_QML_IMPORT_PATH="${OnlineAccountsQML_BINARY_DIR}/../.."
)
qt5_use_modules(${TEST} Core DBus Qml Test)
add_test(${TEST} ${CMAKE_CURRENT_BINARY_DIR}/${TEST})
add_dependencies(check ${TEST})
online-accounts-api-0.1+16.04.20160212/tests/CMakeLists.txt 0000644 0000156 0000165 00000000423 12657306726 023477 0 ustar pbuser pbgroup 0000000 0000000 set(XVFB_COMMAND)
find_program(XVFBRUN xvfb-run)
if(XVFBRUN)
set(XVFB_COMMAND ${XVFBRUN} -s "-screen 0 640x480x24" -a)
else()
message(WARNING "Cannot find xvfb-run.")
endif()
add_subdirectory(daemon)
add_subdirectory(lib/OnlineAccounts)
add_subdirectory(lib/qml_module)
online-accounts-api-0.1+16.04.20160212/src/ 0000755 0000156 0000165 00000000000 12657307121 020353 5 ustar pbuser pbgroup 0000000 0000000 online-accounts-api-0.1+16.04.20160212/src/daemon/ 0000755 0000156 0000165 00000000000 12657307121 021616 5 ustar pbuser pbgroup 0000000 0000000 online-accounts-api-0.1+16.04.20160212/src/daemon/main.cpp 0000644 0000156 0000165 00000004553 12657306726 023267 0 ustar pbuser pbgroup 0000000 0000000 /*
* This file is part of OnlineAccountsDaemon
*
* Copyright (C) 2015 Canonical Ltd.
*
* Contact: Alberto Mardegan
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include
#include
#include
#include "inactivity_timer.h"
#include "OnlineAccountsDaemon/Manager"
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
/* default daemonTimeout to 5 seconds */
int daemonTimeout = 5;
/* override daemonTimeout if OAU_DAEMON_TIMEOUT is set */
if (environment.contains(QLatin1String("OAD_TIMEOUT"))) {
bool isOk;
int value = environment.value(
QLatin1String("OAD_TIMEOUT")).toInt(&isOk);
if (isOk)
daemonTimeout = value;
}
auto manager = (QObject *)oad_create_manager(0);
auto inactivityTimer =
new OnlineAccountsDaemon::InactivityTimer(daemonTimeout * 1000);
inactivityTimer->watchObject(manager);
QObject::connect(inactivityTimer, SIGNAL(timeout()), &app, SLOT(quit()));
QDBusConnection bus = QDBusConnection::sessionBus();
bus.registerObject("/com/ubuntu/OnlineAccounts/Manager", manager);
bus.registerService("com.ubuntu.OnlineAccounts.Manager");
bus.connect(QString(),
QStringLiteral("/org/freedesktop/DBus/Local"),
QStringLiteral("org.freedesktop.DBus.Local"),
QStringLiteral("Disconnected"),
manager, SLOT(onDisconnected()));
int ret = app.exec();
bus.unregisterService("com.ubuntu.OnlineAccounts.Manager");
bus.unregisterObject("/com/ubuntu/OnlineAccounts/Manager");
delete inactivityTimer;
delete manager;
return ret;
}
online-accounts-api-0.1+16.04.20160212/src/daemon/com.ubuntu.OnlineAccounts.Manager.service.in 0000644 0000156 0000165 00000000145 12657306726 032212 0 ustar pbuser pbgroup 0000000 0000000 [D-BUS Service]
Name=com.ubuntu.OnlineAccounts.Manager
Exec=${CMAKE_INSTALL_FULL_BINDIR}/${ACCOUNTD}
online-accounts-api-0.1+16.04.20160212/src/daemon/inactivity_timer.cpp 0000644 0000156 0000165 00000003411 12657306726 025716 0 ustar pbuser pbgroup 0000000 0000000 /*
* Copyright (C) 2013-2015 Canonical Ltd.
*
* Contact: Alberto Mardegan
*
* This file is part of OnlineAccountsDaemon
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*/
#include "inactivity_timer.h"
#include
using namespace OnlineAccountsDaemon;
InactivityTimer::InactivityTimer(int interval, QObject *parent):
QObject(parent),
m_interval(interval)
{
m_timer.setSingleShot(true);
QObject::connect(&m_timer, SIGNAL(timeout()),
this, SLOT(onTimeout()));
}
void InactivityTimer::watchObject(QObject *object)
{
connect(object, SIGNAL(isIdleChanged()), SLOT(onIdleChanged()));
m_watchedObjects.append(object);
/* Force an initial check */
onIdleChanged();
}
void InactivityTimer::onIdleChanged()
{
if (allObjectsAreIdle()) {
m_timer.start(m_interval);
} else {
m_timer.stop();
}
}
void InactivityTimer::onTimeout()
{
if (allObjectsAreIdle()) {
Q_EMIT timeout();
}
}
bool InactivityTimer::allObjectsAreIdle() const
{
Q_FOREACH(const QObject *object, m_watchedObjects) {
if (!object->property("isIdle").toBool()) {
return false;
}
}
return true;
}
online-accounts-api-0.1+16.04.20160212/src/daemon/inactivity_timer.h 0000644 0000156 0000165 00000002653 12657306726 025372 0 ustar pbuser pbgroup 0000000 0000000 /*
* Copyright (C) 2013-2015 Canonical Ltd.
*
* Contact: Alberto Mardegan
*
* This file is part of OnlineAccountsDaemon
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*/
#ifndef ONLINE_ACCOUNTS_DAEMON_INACTIVITY_TIMER_H
#define ONLINE_ACCOUNTS_DAEMON_INACTIVITY_TIMER_H
#include
#include
#include
namespace OnlineAccountsDaemon {
class InactivityTimer: public QObject
{
Q_OBJECT
public:
InactivityTimer(int interval, QObject *parent = 0);
~InactivityTimer() {}
void watchObject(QObject *object);
Q_SIGNALS:
void timeout();
private Q_SLOTS:
void onIdleChanged();
void onTimeout();
private:
bool allObjectsAreIdle() const;
private:
QList m_watchedObjects;
QTimer m_timer;
int m_interval;
};
} // namespace
#endif // ONLINE_ACCOUNTS_DAEMON_INACTIVITY_TIMER_H
online-accounts-api-0.1+16.04.20160212/src/daemon/CMakeLists.txt 0000644 0000156 0000165 00000001177 12657306726 024376 0 ustar pbuser pbgroup 0000000 0000000 project(accountd)
set(ACCOUNTD accountd)
include_directories(.
${OnlineAccountsDaemon_SOURCE_DIR}/..
)
add_executable(${ACCOUNTD}
inactivity_timer.cpp
main.cpp
)
qt5_use_modules(${ACCOUNTD} DBus)
target_link_libraries(${ACCOUNTD}
OnlineAccountsDaemon
)
set_target_properties(${ACCOUNTD} PROPERTIES AUTOMOC TRUE)
install(TARGETS ${ACCOUNTD}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
set(SERVICE_FILE com.ubuntu.OnlineAccounts.Manager.service)
configure_file(${SERVICE_FILE}.in ${SERVICE_FILE})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${SERVICE_FILE}
DESTINATION ${CMAKE_INSTALL_DATADIR}/dbus-1/services
)
online-accounts-api-0.1+16.04.20160212/src/lib/ 0000755 0000156 0000165 00000000000 12657307121 021121 5 ustar pbuser pbgroup 0000000 0000000 online-accounts-api-0.1+16.04.20160212/src/lib/OnlineAccountsDaemon/ 0000755 0000156 0000165 00000000000 12657307121 025171 5 ustar pbuser pbgroup 0000000 0000000 online-accounts-api-0.1+16.04.20160212/src/lib/OnlineAccountsDaemon/authentication_request.cpp 0000644 0000156 0000165 00000005235 12657306726 032503 0 ustar pbuser pbgroup 0000000 0000000 /*
* This file is part of OnlineAccountsDaemon
*
* Copyright (C) 2015 Canonical Ltd.
*
* Contact: Alberto Mardegan
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "authentication_request.h"
#include
#include "authenticator.h"
#include "manager_adaptor.h"
using namespace OnlineAccountsDaemon;
namespace OnlineAccountsDaemon {
class AuthenticationRequestPrivate: public QObject
{
Q_OBJECT
Q_DECLARE_PUBLIC(AuthenticationRequest)
public:
AuthenticationRequestPrivate(AuthenticationRequest *q);
private Q_SLOTS:
void onFinished();
private:
Authenticator m_authenticator;
AuthenticationRequest *q_ptr;
};
} // namespace
AuthenticationRequestPrivate::AuthenticationRequestPrivate(AuthenticationRequest *q):
QObject(q),
q_ptr(q)
{
QObject::connect(&m_authenticator, SIGNAL(finished()),
this, SLOT(onFinished()));
}
void AuthenticationRequestPrivate::onFinished()
{
Q_Q(AuthenticationRequest);
if (m_authenticator.isError()) {
q->setError(m_authenticator.errorName(),
m_authenticator.errorMessage());
} else {
q->setReply(QList() << m_authenticator.reply());
}
}
AuthenticationRequest::AuthenticationRequest(const CallContext &context, QObject *parent):
AsyncOperation(context, parent),
d_ptr(new AuthenticationRequestPrivate(this))
{
}
AuthenticationRequest::~AuthenticationRequest()
{
delete d_ptr;
}
void AuthenticationRequest::setInteractive(bool interactive)
{
Q_D(AuthenticationRequest);
d->m_authenticator.setInteractive(interactive);
}
void AuthenticationRequest::invalidateCache()
{
Q_D(AuthenticationRequest);
d->m_authenticator.invalidateCache();
}
void AuthenticationRequest::authenticate(const Accounts::AuthData &authData,
const QVariantMap ¶meters)
{
Q_D(AuthenticationRequest);
QVariantMap p(parameters);
p.insert("requestorPid", context().clientPid());
d->m_authenticator.authenticate(authData, p);
}
#include "authentication_request.moc"
online-accounts-api-0.1+16.04.20160212/src/lib/OnlineAccountsDaemon/manager_adaptor.cpp 0000644 0000156 0000165 00000012242 12657306726 031034 0 ustar pbuser pbgroup 0000000 0000000 /*
* This file is part of OnlineAccountsDaemon
*
* Copyright (C) 2015 Canonical Ltd.
*
* Contact: Alberto Mardegan
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "manager_adaptor.h"
#include
#include
#include "client_registry.h"
using namespace OnlineAccountsDaemon;
QDBusArgument &operator<<(QDBusArgument &argument, const AccountInfo &info)
{
argument.beginStructure();
argument << info.accountId << info.details;
argument.endStructure();
return argument;
}
const QDBusArgument &operator>>(const QDBusArgument &argument,
AccountInfo &info)
{
argument.beginStructure();
argument >> info.accountId >> info.details;
argument.endStructure();
return argument;
}
CallContext::CallContext(QDBusContext *dbusContext):
m_connection(dbusContext->connection()),
m_message(dbusContext->message())
{
CallContextCounter::instance()->addContext(*this);
}
CallContext::CallContext(const CallContext &other):
m_connection(other.m_connection),
m_message(other.m_message)
{
CallContextCounter::instance()->addContext(*this);
}
CallContext::~CallContext()
{
CallContextCounter::instance()->removeContext(*this);
}
void CallContext::setDelayedReply(bool delayed)
{
m_message.setDelayedReply(delayed);
}
void CallContext::sendReply(const QList &args) const
{
m_connection.send(m_message.createReply(args));
}
void CallContext::sendError(const QString &name, const QString &message) const
{
m_connection.send(m_message.createErrorReply(name, message));
}
QString CallContext::securityContext() const
{
ClientRegistry *clientRegistry = ClientRegistry::instance();
QString client = clientRegistry->registerClient(m_connection, m_message);
return clientRegistry->clientSecurityContext(client);
}
pid_t CallContext::clientPid() const
{
ClientRegistry *clientRegistry = ClientRegistry::instance();
return clientRegistry->clientPid(m_message.service());
}
QString CallContext::clientName() const
{
return m_message.service();
}
static CallContextCounter *m_callContextCounterInstance = 0;
CallContextCounter::CallContextCounter():
QObject(),
m_contexts(0)
{
}
CallContextCounter *CallContextCounter::instance()
{
if (!m_callContextCounterInstance) {
m_callContextCounterInstance = new CallContextCounter;
}
return m_callContextCounterInstance;
}
void CallContextCounter::addContext(const CallContext &)
{
m_contexts++;
Q_EMIT activeContextsChanged();
}
void CallContextCounter::removeContext(const CallContext &)
{
m_contexts--;
Q_EMIT activeContextsChanged();
}
namespace OnlineAccountsDaemon {
class ManagerAdaptorPrivate {
public:
ManagerAdaptorPrivate();
private:
friend class ManagerAdaptor;
};
} // namespace
ManagerAdaptorPrivate::ManagerAdaptorPrivate()
{
}
ManagerAdaptor::ManagerAdaptor(Manager *parent):
QDBusAbstractAdaptor(parent),
d_ptr(new ManagerAdaptorPrivate)
{
qRegisterMetaType("AccountInfo");
qRegisterMetaType >("QList");
qDBusRegisterMetaType();
qDBusRegisterMetaType>();
setAutoRelaySignals(false);
}
ManagerAdaptor::~ManagerAdaptor()
{
delete d_ptr;
}
void ManagerAdaptor::notifyAccountChange(const AccountInfo &info,
uint changeType)
{
AccountInfo copy(info);
copy.details[ONLINE_ACCOUNTS_INFO_KEY_CHANGE_TYPE] = changeType;
Q_EMIT AccountChanged(copy.serviceId(), copy);
}
QVariantMap ManagerAdaptor::Authenticate(uint accountId,
const QString &serviceId,
bool interactive, bool invalidate,
const QVariantMap ¶meters)
{
parent()->authenticate(accountId, serviceId,
interactive, invalidate, parameters,
CallContext(dbusContext()));
return QVariantMap();
}
QList ManagerAdaptor::GetAccounts(const QVariantMap &filters)
{
return parent()->getAccounts(filters,
CallContext(dbusContext()));
}
AccountInfo ManagerAdaptor::RequestAccess(const QString &serviceId,
const QVariantMap ¶meters,
QVariantMap &credentials)
{
parent()->requestAccess(serviceId, parameters,
CallContext(dbusContext()));
credentials = QVariantMap();
return AccountInfo();
}
#include "manager_adaptor.moc"
online-accounts-api-0.1+16.04.20160212/src/lib/OnlineAccountsDaemon/client_registry.cpp 0000644 0000156 0000165 00000012662 12657306726 031124 0 ustar pbuser pbgroup 0000000 0000000 /*
* This file is part of OnlineAccountsDaemon
*
* Copyright (C) 2015 Canonical Ltd.
*
* Contact: Alberto Mardegan
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "client_registry.h"
#include
#include
#include
#include
#include
#include
#include
using namespace OnlineAccountsDaemon;
namespace OnlineAccountsDaemon {
class ClientRegistryPrivate: public QObject
{
Q_OBJECT
Q_DECLARE_PUBLIC(ClientRegistry)
public:
ClientRegistryPrivate(ClientRegistry *q);
void registerClient(const QString &client);
QString getSecurityContext(const QString &client) const;
pid_t getPid(const QString &client) const;
private Q_SLOTS:
void onServiceUnregistered(const QString &client);
private:
static ClientRegistry *m_instance;
QDBusConnection m_connection;
QDBusServiceWatcher m_watcher;
QHash m_clientContexts;
ClientRegistry *q_ptr;
};
ClientRegistry *ClientRegistryPrivate::m_instance = 0;
} // namespace
ClientRegistryPrivate::ClientRegistryPrivate(ClientRegistry *q):
QObject(q),
m_connection(QDBusConnection::sessionBus()),
q_ptr(q)
{
m_watcher.setConnection(m_connection);
QObject::connect(&m_watcher, SIGNAL(serviceUnregistered(const QString&)),
this, SLOT(onServiceUnregistered(const QString&)));
}
void ClientRegistryPrivate::registerClient(const QString &client)
{
Q_Q(ClientRegistry);
if (m_clientContexts.contains(client)) return;
bool wasEmpty = m_clientContexts.isEmpty();
m_clientContexts.insert(client, getSecurityContext(client));
m_watcher.addWatchedService(client);
if (wasEmpty) {
Q_EMIT q->hasClientsChanged();
}
}
QString ClientRegistryPrivate::getSecurityContext(const QString &client) const
{
QString dbusService = qEnvironmentVariableIsEmpty("OAD_TESTING") ?
"org.freedesktop.DBus" : "mocked.org.freedesktop.dbus";
QDBusMessage msg =
QDBusMessage::createMethodCall(dbusService,
"/org/freedesktop/DBus",
"org.freedesktop.DBus",
"GetConnectionAppArmorSecurityContext");
msg << client;
QDBusMessage reply = m_connection.call(msg, QDBus::Block);
QString context;
if (reply.type() == QDBusMessage::ReplyMessage) {
context = reply.arguments().value(0).value();
} else {
qWarning() << "Could not determine AppArmor context: " <<
reply.errorName() << ": " << reply.errorMessage();
context = QStringLiteral("unconfined");
}
return context;
}
pid_t ClientRegistryPrivate::getPid(const QString &client) const
{
QDBusReply reply = m_connection.interface()->servicePid(client);
return pid_t(reply.value());
}
void ClientRegistryPrivate::onServiceUnregistered(const QString &client)
{
Q_Q(ClientRegistry);
qDebug() << "Client disappeared:" << client;
m_clientContexts.remove(client);
if (m_clientContexts.isEmpty()) {
Q_EMIT q->hasClientsChanged();
}
}
ClientRegistry::ClientRegistry():
QObject(),
d_ptr(new ClientRegistryPrivate(this))
{
}
ClientRegistry::~ClientRegistry()
{
delete d_ptr;
}
ClientRegistry *ClientRegistry::instance()
{
if (!ClientRegistryPrivate::m_instance) {
ClientRegistryPrivate::m_instance = new ClientRegistry();
}
return ClientRegistryPrivate::m_instance;
}
QString ClientRegistry::registerClient(const QDBusConnection &connection,
const QDBusMessage &message)
{
Q_UNUSED(connection); // only needed for p2p clients
QString client = message.service();
registerClient(client);
return client;
}
void ClientRegistry::registerClient(const QString &client)
{
Q_D(ClientRegistry);
d->registerClient(client);
}
QStringList ClientRegistry::clients() const
{
Q_D(const ClientRegistry);
return d->m_clientContexts.keys();
}
void ClientRegistry::registerActiveClients(const QStringList &clients)
{
Q_D(const ClientRegistry);
QStringList activeServices =
d->m_connection.interface()->registeredServiceNames().value();
Q_FOREACH(const QString &client, clients) {
if (activeServices.contains(client)) {
registerClient(client);
}
}
}
QString ClientRegistry::clientSecurityContext(const QString &client) const
{
Q_D(const ClientRegistry);
QHash::const_iterator i =
d->m_clientContexts.find(client);
if (i != d->m_clientContexts.constEnd()) {
return i.value();
}
return d->getSecurityContext(client);
}
pid_t ClientRegistry::clientPid(const QString &client) const
{
Q_D(const ClientRegistry);
return d->getPid(client);
}
#include "client_registry.moc"
online-accounts-api-0.1+16.04.20160212/src/lib/OnlineAccountsDaemon/authenticator.h 0000644 0000156 0000165 00000003247 12657306726 030234 0 ustar pbuser pbgroup 0000000 0000000 /*
* This file is part of OnlineAccountsDaemon
*
* Copyright (C) 2015 Canonical Ltd.
*
* Contact: Alberto Mardegan
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef ONLINE_ACCOUNTS_DAEMON_AUTHENTICATOR_H
#define ONLINE_ACCOUNTS_DAEMON_AUTHENTICATOR_H
#include
#include
#include
namespace Accounts {
class AuthData;
}
namespace OnlineAccountsDaemon {
class AuthenticatorPrivate;
class Authenticator: public QObject
{
Q_OBJECT
public:
explicit Authenticator(QObject *parent = 0);
~Authenticator();
void setInteractive(bool interactive);
void invalidateCache();
void authenticate(const Accounts::AuthData &authData,
const QVariantMap ¶meters);
bool isError() const { return !errorName().isEmpty(); }
QVariantMap reply() const;
QString errorName() const;
QString errorMessage() const;
Q_SIGNALS:
void finished();
private:
Q_DECLARE_PRIVATE(Authenticator)
AuthenticatorPrivate *d_ptr;
};
} // namespace
#endif // ONLINE_ACCOUNTS_DAEMON_AUTHENTICATOR_H
online-accounts-api-0.1+16.04.20160212/src/lib/OnlineAccountsDaemon/access_request.h 0000644 0000156 0000165 00000003501 12657306726 030364 0 ustar pbuser pbgroup 0000000 0000000 /*
* This file is part of OnlineAccountsDaemon
*
* Copyright (C) 2015 Canonical Ltd.
*
* Contact: Alberto Mardegan
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef ONLINE_ACCOUNTS_DAEMON_ACCESS_REQUEST_H
#define ONLINE_ACCOUNTS_DAEMON_ACCESS_REQUEST_H
#include
#include
#include
#include
#include "async_operation.h"
namespace Accounts {
class AuthData;
}
namespace OnlineAccountsDaemon {
class AccountInfo;
class AccessRequestPrivate;
class AccessRequest: public AsyncOperation
{
Q_OBJECT
public:
explicit AccessRequest(const CallContext &context,
QObject *parent = 0);
~AccessRequest();
void requestAccess(const QString &applicationId,
const QString &serviceId,
const QVariantMap ¶meters,
pid_t clientPid);
void setAccountInfo(const AccountInfo &accountInfo,
const Accounts::AuthData &authData);
Q_SIGNALS:
void loadRequest(uint accountId, const QString &serviceId);
private:
Q_DECLARE_PRIVATE(AccessRequest)
AccessRequestPrivate *d_ptr;
};
} // namespace
#endif // ONLINE_ACCOUNTS_DAEMON_ACCESS_REQUEST_H
online-accounts-api-0.1+16.04.20160212/src/lib/OnlineAccountsDaemon/dbus_constants.h 0000644 0000156 0000165 00000007342 12657306732 030410 0 ustar pbuser pbgroup 0000000 0000000 /*
* This file is part of OnlineAccountsDaemon
*
* Copyright (C) 2015-2016 Canonical Ltd.
*
* Contact: Alberto Mardegan
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef ONLINE_ACCOUNTS_DBUS_CONSTANTS_P_H
#define ONLINE_ACCOUNTS_DBUS_CONSTANTS_P_H
/* Manager service, object path and interface name */
#define ONLINE_ACCOUNTS_MANAGER_SERVICE_NAME \
"com.ubuntu.OnlineAccounts.Manager"
#define ONLINE_ACCOUNTS_MANAGER_PATH "/com/ubuntu/OnlineAccounts/Manager"
#define ONLINE_ACCOUNTS_MANAGER_INTERFACE ONLINE_ACCOUNTS_MANAGER_SERVICE_NAME
/* Keys for the account info dictionary */
#define ONLINE_ACCOUNTS_INFO_KEY_DISPLAY_NAME "displayName"
#define ONLINE_ACCOUNTS_INFO_KEY_SERVICE_ID "serviceId"
#define ONLINE_ACCOUNTS_INFO_KEY_AUTH_METHOD "authMethod"
# define ONLINE_ACCOUNTS_AUTH_METHOD_UNKNOWN 0
# define ONLINE_ACCOUNTS_AUTH_METHOD_OAUTH1 1
# define ONLINE_ACCOUNTS_AUTH_METHOD_OAUTH2 2
# define ONLINE_ACCOUNTS_AUTH_METHOD_PASSWORD 3
# define ONLINE_ACCOUNTS_AUTH_METHOD_SASL 4
#define ONLINE_ACCOUNTS_INFO_KEY_SETTINGS "settings/"
#define ONLINE_ACCOUNTS_INFO_KEY_CHANGE_TYPE "changeType"
# define ONLINE_ACCOUNTS_INFO_CHANGE_ENABLED 0
# define ONLINE_ACCOUNTS_INFO_CHANGE_DISABLED 1
# define ONLINE_ACCOUNTS_INFO_CHANGE_UPDATED 2
/* Error codes */
#define ONLINE_ACCOUNTS_ERROR_PREFIX "com.ubuntu.OnlineAccounts.Error."
#define ONLINE_ACCOUNTS_ERROR_NO_ACCOUNT \
ONLINE_ACCOUNTS_ERROR_PREFIX "NoAccount"
#define ONLINE_ACCOUNTS_ERROR_USER_CANCELED \
ONLINE_ACCOUNTS_ERROR_PREFIX "UserCanceled"
#define ONLINE_ACCOUNTS_ERROR_PERMISSION_DENIED \
ONLINE_ACCOUNTS_ERROR_PREFIX "PermissionDenied"
#define ONLINE_ACCOUNTS_ERROR_INTERACTION_REQUIRED \
ONLINE_ACCOUNTS_ERROR_PREFIX "InteractionRequired"
/* Keys for the authentication data dictionaries */
#define ONLINE_ACCOUNTS_AUTH_KEY_CLIENT_ID "ClientId"
#define ONLINE_ACCOUNTS_AUTH_KEY_CLIENT_SECRET "ClientSecret"
#define ONLINE_ACCOUNTS_AUTH_KEY_SCOPES "Scopes"
#define ONLINE_ACCOUNTS_AUTH_KEY_ACCESS_TOKEN "AccessToken"
#define ONLINE_ACCOUNTS_AUTH_KEY_EXPIRES_IN "ExpiresIn"
#define ONLINE_ACCOUNTS_AUTH_KEY_GRANTED_SCOPES "GrantedScopes"
#define ONLINE_ACCOUNTS_AUTH_KEY_CONSUMER_KEY "ConsumerKey"
#define ONLINE_ACCOUNTS_AUTH_KEY_CONSUMER_SECRET "ConsumerSecret"
#define ONLINE_ACCOUNTS_AUTH_KEY_TOKEN "Token"
#define ONLINE_ACCOUNTS_AUTH_KEY_TOKEN_SECRET "TokenSecret"
#define ONLINE_ACCOUNTS_AUTH_KEY_SIGNATURE_METHOD "SignatureMethod"
#define ONLINE_ACCOUNTS_AUTH_KEY_SERVICE "Service"
#define ONLINE_ACCOUNTS_AUTH_KEY_MECHANISMS "MechList"
#define ONLINE_ACCOUNTS_AUTH_KEY_FQDN "Fqdn"
#define ONLINE_ACCOUNTS_AUTH_KEY_LOCAL_IP "IpLocal"
#define ONLINE_ACCOUNTS_AUTH_KEY_REMOTE_IP "IpRemote"
#define ONLINE_ACCOUNTS_AUTH_KEY_CHALLENGE "Challenge"
#define ONLINE_ACCOUNTS_AUTH_KEY_CHOSEN_MECHANISM "ChosenMechanism"
#define ONLINE_ACCOUNTS_AUTH_KEY_RESPONSE "Response"
#define ONLINE_ACCOUNTS_AUTH_KEY_STATE "state"
# define ONLINE_ACCOUNTS_AUTH_SASL_STATE_FINISHED 0
# define ONLINE_ACCOUNTS_AUTH_SASL_STATE_CONTINUE 1
#define ONLINE_ACCOUNTS_AUTH_KEY_USERNAME "Username"
#define ONLINE_ACCOUNTS_AUTH_KEY_PASSWORD "Password"
#endif // ONLINE_ACCOUNTS_DBUS_CONSTANTS_P_H
online-accounts-api-0.1+16.04.20160212/src/lib/OnlineAccountsDaemon/manager_adaptor.h 0000644 0000156 0000165 00000010652 12657306726 030504 0 ustar pbuser pbgroup 0000000 0000000 /*
* This file is part of OnlineAccountsDaemon
*
* Copyright (C) 2015 Canonical Ltd.
*
* Contact: Alberto Mardegan
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef ONLINE_ACCOUNTS_DAEMON_MANAGER_ADAPTOR_H
#define ONLINE_ACCOUNTS_DAEMON_MANAGER_ADAPTOR_H
#include
#include
#include
#include
#include
#include
#include
#include "account_info.h"
#include "manager.h"
namespace OnlineAccountsDaemon {
class CallContext {
public:
explicit CallContext(QDBusContext *dbusContext);
CallContext(const CallContext &other);
virtual ~CallContext();
void setDelayedReply(bool delayed);
void sendReply(const QList &args) const;
void sendError(const QString &name, const QString &message) const;
QString securityContext() const;
pid_t clientPid() const;
QString clientName() const;
private:
QDBusConnection m_connection;
QDBusMessage m_message;
};
class CallContextCounter: public QObject
{
Q_OBJECT
public:
static CallContextCounter *instance();
int activeContexts() const { return m_contexts; }
Q_SIGNALS:
void activeContextsChanged();
protected:
void addContext(const CallContext &context);
void removeContext(const CallContext &context);
private:
friend class CallContext;
CallContextCounter();
int m_contexts;
};
class ManagerAdaptorPrivate;
class ManagerAdaptor: public QDBusAbstractAdaptor
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "com.ubuntu.OnlineAccounts.Manager")
Q_CLASSINFO("D-Bus Introspection", ""
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
"")
public:
explicit ManagerAdaptor(Manager *parent);
~ManagerAdaptor();
inline Manager *parent() const
{ return static_cast(QObject::parent()); }
inline QDBusContext *dbusContext() const
{ return static_cast(parent()); }
void notifyAccountChange(const AccountInfo &info, uint changeType);
public Q_SLOTS:
QVariantMap Authenticate(uint accountId, const QString &serviceId,
bool interactive, bool invalidate,
const QVariantMap ¶meters);
QList GetAccounts(const QVariantMap &filters);
AccountInfo RequestAccess(const QString &serviceId,
const QVariantMap ¶meters,
QVariantMap &credentials);
Q_SIGNALS:
void AccountChanged(const QString &serviceId, AccountInfo account);
private:
Q_DECLARE_PRIVATE(ManagerAdaptor)
ManagerAdaptorPrivate *d_ptr;
};
} // namespace
#endif // ONLINE_ACCOUNTS_DAEMON_MANAGER_ADAPTOR_H
online-accounts-api-0.1+16.04.20160212/src/lib/OnlineAccountsDaemon/authentication_request.h 0000644 0000156 0000165 00000003217 12657306726 032146 0 ustar pbuser pbgroup 0000000 0000000 /*
* This file is part of OnlineAccountsDaemon
*
* Copyright (C) 2015 Canonical Ltd.
*
* Contact: Alberto Mardegan
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef ONLINE_ACCOUNTS_DAEMON_AUTHENTICATION_REQUEST_H
#define ONLINE_ACCOUNTS_DAEMON_AUTHENTICATION_REQUEST_H
#include
#include
#include
#include "async_operation.h"
namespace Accounts {
class AuthData;
}
namespace OnlineAccountsDaemon {
class AuthenticationRequestPrivate;
class AuthenticationRequest: public AsyncOperation
{
Q_OBJECT
public:
explicit AuthenticationRequest(const CallContext &context,
QObject *parent = 0);
~AuthenticationRequest();
void setInteractive(bool interactive);
void invalidateCache();
void authenticate(const Accounts::AuthData &authData,
const QVariantMap ¶meters);
private:
Q_DECLARE_PRIVATE(AuthenticationRequest)
AuthenticationRequestPrivate *d_ptr;
};
} // namespace
#endif // ONLINE_ACCOUNTS_DAEMON_AUTHENTICATION_REQUEST_H
online-accounts-api-0.1+16.04.20160212/src/lib/OnlineAccountsDaemon/Manager 0000644 0000156 0000165 00000000025 12657306726 026475 0 ustar pbuser pbgroup 0000000 0000000 #include "manager.h"
online-accounts-api-0.1+16.04.20160212/src/lib/OnlineAccountsDaemon/client_registry.h 0000644 0000156 0000165 00000003457 12657306726 030573 0 ustar pbuser pbgroup 0000000 0000000 /*
* This file is part of OnlineAccountsDaemon
*
* Copyright (C) 2015 Canonical Ltd.
*
* Contact: Alberto Mardegan
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef ONLINE_ACCOUNTS_DAEMON_CLIENT_REGISTRY_H
#define ONLINE_ACCOUNTS_DAEMON_CLIENT_REGISTRY_H
#include
#include
#include
class QDBusConnection;
class QDBusMessage;
namespace OnlineAccountsDaemon {
class ClientRegistryPrivate;
class ClientRegistry: public QObject
{
Q_OBJECT
public:
~ClientRegistry();
static ClientRegistry *instance();
QString registerClient(const QDBusConnection &connection,
const QDBusMessage &message);
void registerClient(const QString &client);
void registerActiveClients(const QStringList &clients);
QStringList clients() const;
bool hasClients() const { return !clients().isEmpty(); }
QString clientSecurityContext(const QString &client) const;
pid_t clientPid(const QString &client) const;
Q_SIGNALS:
void hasClientsChanged();
private:
ClientRegistry();
Q_DECLARE_PRIVATE(ClientRegistry)
ClientRegistryPrivate *d_ptr;
};
} // namespace
#endif // ONLINE_ACCOUNTS_DAEMON_CLIENT_REGISTRY_H
online-accounts-api-0.1+16.04.20160212/src/lib/OnlineAccountsDaemon/global.h 0000644 0000156 0000165 00000002051 12657306726 026612 0 ustar pbuser pbgroup 0000000 0000000 /*
* This file is part of libOnlineAccountsDaemon
*
* Copyright (C) 2015 Canonical Ltd.
*
* Contact: Alberto Mardegan
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef ONLINE_ACCOUNTS_DAEMON_GLOBAL_H
#define ONLINE_ACCOUNTS_DAEMON_GLOBAL_H
#include
#if defined(BUILDING_ONLINE_ACCOUNTS_DAEMON)
# define OAD_EXPORT Q_DECL_EXPORT
#else
# define OAD_EXPORT Q_DECL_IMPORT
#endif
#endif // ONLINE_ACCOUNTS_DAEMON_GLOBAL_H
online-accounts-api-0.1+16.04.20160212/src/lib/OnlineAccountsDaemon/state_saver.h 0000644 0000156 0000165 00000002732 12657306726 027700 0 ustar pbuser pbgroup 0000000 0000000 /*
* This file is part of OnlineAccountsDaemon
*
* Copyright (C) 2015 Canonical Ltd.
*
* Contact: Alberto Mardegan
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef ONLINE_ACCOUNTS_DAEMON_STATE_SAVER_H
#define ONLINE_ACCOUNTS_DAEMON_STATE_SAVER_H
#include
#include
#include "account_info.h"
namespace OnlineAccountsDaemon {
typedef QPair Client;
class StateSaverPrivate;
class StateSaver: public QObject
{
Q_OBJECT
public:
explicit StateSaver(QObject *parent = 0);
~StateSaver();
void setAccounts(const QList &accounts);
QList accounts() const;
void setClients(const QList &clients);
QList clients() const;
private:
Q_DECLARE_PRIVATE(StateSaver)
StateSaverPrivate *d_ptr;
};
} // namespace
#endif // ONLINE_ACCOUNTS_DAEMON_STATE_SAVER_H
online-accounts-api-0.1+16.04.20160212/src/lib/OnlineAccountsDaemon/OnlineAccountsDaemon.pc.in 0000644 0000156 0000165 00000000470 12657306726 032205 0 ustar pbuser pbgroup 0000000 0000000 prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
libdir=${prefix}/@LIBDIR@
includedir=${prefix}/include
Name: @ACCOUNTD_LIB@
Description: Binding development files for the Online Accounts simplified API
Version: @PROJECT_VERSION@
Requires: Qt5Core
Libs: -L${libdir} -l@ACCOUNTD_LIB@
Cflags: -I${includedir}/
online-accounts-api-0.1+16.04.20160212/src/lib/OnlineAccountsDaemon/async_operation.h 0000644 0000156 0000165 00000003024 12657306726 030550 0 ustar pbuser pbgroup 0000000 0000000 /*
* This file is part of OnlineAccountsDaemon
*
* Copyright (C) 2015 Canonical Ltd.
*
* Contact: Alberto Mardegan
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef ONLINE_ACCOUNTS_DAEMON_ASYNC_OPERATION_H
#define ONLINE_ACCOUNTS_DAEMON_ASYNC_OPERATION_H
#include
#include
#include
#include
namespace OnlineAccountsDaemon {
class CallContext;
class AsyncOperationPrivate;
class AsyncOperation: public QObject
{
Q_OBJECT
public:
explicit AsyncOperation(const CallContext &context,
QObject *parent = 0);
~AsyncOperation();
const CallContext &context() const;
protected:
void setReply(const QList &reply);
void setError(const QString &name, const QString &message);
private:
Q_DECLARE_PRIVATE(AsyncOperation)
AsyncOperationPrivate *d_ptr;
};
} // namespace
#endif // ONLINE_ACCOUNTS_DAEMON_ASYNC_OPERATION_H
online-accounts-api-0.1+16.04.20160212/src/lib/OnlineAccountsDaemon/state_saver.cpp 0000644 0000156 0000165 00000011636 12657306726 030236 0 ustar pbuser pbgroup 0000000 0000000 /*
* This file is part of OnlineAccountsDaemon
*
* Copyright (C) 2015 Canonical Ltd.
*
* Contact: Alberto Mardegan
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "state_saver.h"
#include
#include
#include
#include
#include
#include
#include
#include