~launchpad-pqm/launchpad/devel

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
= PPA Subscriptions =

Note: This file contains all the pagetests for functionality that is not
part of the stories in xx-private-ppa-subscription-stories.txt.

== Managing Archive subscriptions ==

Public PPAs do not have an option for managing subscriptions:

    >>> cprov_browser = setupBrowser(
    ...     auth="Basic celso.providelo@canonical.com:cprov")
    >>> cprov_browser.open("http://launchpad.dev/~cprov/+archive/ppa")
    >>> cprov_browser.getLink("Manage subscriptions")
    Traceback (most recent call last):
    ...
    LinkNotFoundError

Similarly, trying to access the subscriptions page directly will simply
redirect back to the PPA page with a feedback message:

    >>> cprov_browser.open(
    ...     "http://launchpad.dev/~cprov/+archive/ppa/+subscriptions")

    >>> print cprov_browser.url
    http://launchpad.dev/~cprov/+archive/ppa

    >>> for msg in get_feedback_messages(cprov_browser.contents):
    ...     print msg
    Only private archives can have subscribers.

Setup private PPAs for both Celso and Mark:

    >>> from zope.component import getUtility
    >>> from lp.registry.interfaces.person import IPersonSet
    >>> login('admin@canonical.com')
    >>> cprov = getUtility(IPersonSet).getByName('cprov')
    >>> mark = getUtility(IPersonSet).getByName('mark')
    >>> from lp.registry.interfaces.distribution import IDistributionSet
    >>> ubuntu = getUtility(IDistributionSet).getByName('ubuntu')
    >>> cprov_private_ppa = factory.makeArchive(
    ...     owner=cprov, name="p3a", distribution=ubuntu, private=True)
    >>> mark_private_ppa = factory.makeArchive(
    ...     owner=mark, name="p3a", distribution=ubuntu, private=True)
    >>> logout()

The PPA page includes a link to manage subscriptions:

    >>> cprov_browser.open("http://launchpad.dev/~cprov/+archive/p3a")
    >>> cprov_browser.getLink("Manage access").click()

The page includes the required dependencies for the yui2-based date
picker:

    >>> print extract_all_script_and_style_links(cprov_browser.contents)
    /...
    ...
    http://launchpad.dev/+icing/.../build/app/calendar.js
    http://launchpad.dev/+icing/.../yui_2.7.0b/build/calendar/assets/skins/sam/calendar.css

Initially there are no subscriptions for a newly privatized PPA (although,
this may need to change, to add the owner/team). A heading is displayed
with a message:

    >>> main_content = find_main_content(cprov_browser.contents)
    >>> print extract_text(main_content.find('h1'))
    Manage access to PPA named p3a for Celso Providelo

    >>> print extract_text(find_tag_by_id(cprov_browser.contents,
    ...     'no-subscribers'))
    No one has access to install software from this PPA.

Create two new users that can be subscribed to archives, and a team:

    >>> login('foo.bar@canonical.com')
    >>> joesmith = factory.makePerson(name="joesmith", displayname="Joe Smith",
    ...     password="test", email="joe@example.com")
    >>> teamjoe = factory.makeTeam(
    ...     owner=joesmith, displayname="Team Joe", name='teamjoe')
    >>> bradsmith = factory.makePerson(name="bradsmith", displayname="Brad Smith",
    ...     password="test", email="brad@example.com")
    >>> logout()

People and teams can be subscribed by entering their details into the
displayed form:

    >>> cprov_browser.getControl(name='field.subscriber').value = 'teamjoe'
    >>> cprov_browser.getControl(
    ...     name='field.description').value = "Joes friends are my friends"
    >>> cprov_browser.getControl(name="field.actions.add").click()
    >>> cprov_browser.getControl(name='field.subscriber').value = 'bradsmith'
    >>> cprov_browser.getControl(
    ...     name='field.date_expires').value = '2200-08-01'
    >>> cprov_browser.getControl(
    ...     name='field.description').value = "Brad can access for a while."
    >>> cprov_browser.getControl(name="field.actions.add").click()

Once the subscription has been added, it will display in the table:

    >>> for row in find_tags_by_class(cprov_browser.contents,
    ...                               'archive_subscriber_row'):
    ...     print extract_text(row)
    Name                Expires     Comment
    Brad Smith          2200-08-01  Brad can access for a while.  Edit/Cancel
    Team Joe                        Joes friends are my friends   Edit/Cancel


== Managing a persons' Archive subscriptions ==

The title of a persons archive subscriptions is displayed as the main
heading:

    >>> cprov_browser.open("/~cprov/+archivesubscriptions")
    >>> print find_main_content(cprov_browser.contents)
    <div...
    <h1>Private PPA access</h1>...

A person who is not subscribed to any archives will see an appropriate
explanation if they try to view their archive subscriptions:

    >>> explanation = find_main_content(cprov_browser.contents).find('p')
    >>> print extract_text(explanation)
    You do not have any current subscriptions to private archives...

First, create a subscription for Joe Smith's team to mark's archive
so that Joe has multiple subscriptions:

    >>> mark_browser = setupBrowser(
    ...     auth="Basic mark@example.com:test")
    >>> mark_browser.open("http://launchpad.dev/~mark/+archive/p3a/+subscriptions")
    >>> mark_browser.getControl(name='field.subscriber').value = 'joesmith'
    >>> mark_browser.getControl(
    ...     name='field.description').value = "Joe is also my friend"
    >>> mark_browser.getControl(name="field.actions.add").click()

A person who is subscribed to multiple archives will see all the archives
listed in the current subscriptions area:

    >>> joe_browser = setupBrowser(auth="Basic joe@example.com:test")
    >>> joe_browser.open(
    ...     "http://launchpad.dev/~joesmith/+archivesubscriptions")
    >>> for row in find_tags_by_class(joe_browser.contents,
    ...                               'archive-subscription-row'):
    ...     print extract_text(row)
    Archive                          Owner
    PPA named... (ppa:mark/p3a)      Mark Shuttleworth       View
    PPA named... (ppa:cprov/p3a)     Celso Providelo         View

It is not possible to traverse to a team's archive subscriptions to
create tokens.

    >>> joe_browser.open(
    ...     "http://launchpad.dev/~teamjoe/+archivesubscriptions")
    Traceback (most recent call last):
    ...
    NotFound...


== Confirming a subscription ==

When a person clicks on the view button, the subscription is confirmed
automatically (creating a token for the user) and they are taken to a page
displaying their subscription.

    >>> joe_browser.open(
    ...     "http://launchpad.dev/~joesmith/+archivesubscriptions")
    >>> joe_browser.getControl(name="activate", index=0).click()
    >>> sources_list = find_tag_by_id(joe_browser.contents, 'sources_list')
    >>> print(extract_text(sources_list))
    Custom sources.list entries
    ...
    deb http://joesmith:...@private-ppa.launchpad.dev/mark/p3a/ubuntu
        hoary main #Personal access of Joe Smith
        to PPA named p3a for Mark Shuttleworth
    deb-src http://joesmith:...@private-ppa.launchpad.dev/mark/p3a/ubuntu
        hoary main #Personal access of Joe Smith
        to PPA named p3a for Mark Shuttleworth

This page will include information about the signing key, if the archive
has a signing key:

    >>> from zope.component import getUtility
    >>> from lp.registry.interfaces.gpg import IGPGKeySet
    >>> from lp.registry.interfaces.person import IPersonSet
    >>> login('foo.bar@canonical.com')
    >>> mark = getUtility(IPersonSet).getByName('mark')
    >>> a_key = getUtility(IGPGKeySet).get(1)
    >>> mark_private_ppa.signing_key = a_key
    >>> logout()

    >>> joe_browser.reload()
    >>> sources_list = find_tag_by_id(joe_browser.contents, 'sources_list')
    >>> print(extract_text(sources_list))
    Custom sources.list entries
    ...
    deb http://joesmith:...@private-ppa.launchpad.dev/mark/p3a/ubuntu
        hoary main #Personal access of Joe Smith
        to PPA named p3a for Mark Shuttleworth
    deb-src http://joesmith:...@private-ppa.launchpad.dev/mark/p3a/ubuntu
        hoary main #Personal access of Joe Smith
        to PPA named p3a for Mark Shuttleworth
    This repository is signed ...

Once a person has activated a subscription, being subscribed again via
another team does not lead to duplicate entries on the person's
subscriptions page.

    >>> mark_browser.open("http://launchpad.dev/~mark/+archive/p3a")
    >>> mark_browser.getLink("Manage access").click()
    >>> mark_browser.getControl(name='field.subscriber').value = 'teamjoe'
    >>> mark_browser.getControl(
    ...     name='field.description').value = "Joe's friends are my friends."
    >>> mark_browser.getControl(name="field.actions.add").click()
    >>> joe_browser.open(
    ...     "http://launchpad.dev/~joesmith/+archivesubscriptions")
    >>> rows = find_tags_by_class(
    ...     joe_browser.contents, 'archive-subscription-row')
    >>> for row in rows:
    ...     print extract_text(row)
    Archive                                            Owner
    PPA named p3a for Mark Shuttleworth (ppa:mark/p3a) Mark Shuttleworth View
    PPA named p3a for Celso Providelo (ppa:cprov/p3a)  Celso Providelo   View