0001-ics-return-404-on-incomplete-ics-url-access-41449.patch
tests/test_api.py | ||
---|---|---|
2289 | 2289 |
local_user.roles = [role.id] |
2290 | 2290 |
local_user.store() |
2291 | 2291 | |
2292 | 2292 |
def remove_dtstamp(body): |
2293 | 2293 |
# remove dtstamp as the precise timing may vary between two consecutive |
2294 | 2294 |
# calls and we shouldn't care. |
2295 | 2295 |
return re.sub('DTSTAMP:.*', 'DTSTAMP:--', body) |
2296 | 2296 | |
2297 |
# check 404 on incomplete ics url access |
|
2298 |
assert get_app(pub).get(sign_uri('/api/forms/test/ics/', user=local_user), status=404) |
|
2299 | ||
2297 | 2300 |
# check it gets the data |
2298 | 2301 |
resp = get_app(pub).get(sign_uri('/api/forms/test/ics/foobar', user=local_user)) |
2299 | 2302 |
resp2 = get_app(pub).get(sign_uri('/api/forms/test/ics/foobar/', user=local_user)) |
2300 | 2303 |
assert remove_dtstamp(resp.text) == remove_dtstamp(resp2.text) |
2301 | 2304 |
assert resp.headers['content-type'] == 'text/calendar; charset=utf-8' |
2302 | 2305 |
assert resp.text.count('BEGIN:VEVENT') == 10 |
2303 | 2306 |
# check that description contains form name, display id, workflow status, |
2304 | 2307 |
# backoffice url and attached user |
wcs/backoffice/management.py | ||
---|---|---|
1918 | 1918 |
# of the field to use as start date (may be a date field or a |
1919 | 1919 |
# string field). |
1920 | 1920 |
# ics/<component>/<component2> with <component2> as the identifier |
1921 | 1921 |
# of the field to use as end date (ditto, date or string field) |
1922 | 1922 |
def _q_traverse(self, path): |
1923 | 1923 |
if not path[-1]: |
1924 | 1924 |
# allow trailing slash |
1925 | 1925 |
path = path[:-1] |
1926 |
if len(path) not in (1, 2): |
|
1927 |
raise errors.TraversalError() |
|
1926 | 1928 |
start_date_field_varname = path[0] |
1927 | 1929 |
end_date_field_varname = None |
1928 | 1930 |
if len(path) == 2: |
1929 | 1931 |
end_date_field_varname = path[1] |
1930 |
elif len(path) > 2: |
|
1931 |
raise errors.TraversalError() |
|
1932 | 1932 | |
1933 | 1933 |
start_date_field_id = None |
1934 | 1934 |
end_date_field_id = None |
1935 | 1935 |
for field in formdef.get_all_fields(): |
1936 | 1936 |
if getattr(field, 'varname', None) == start_date_field_varname: |
1937 | 1937 |
start_date_field_id = field.id |
1938 | 1938 |
if end_date_field_varname and getattr(field, 'varname', None) == end_date_field_varname: |
1939 | 1939 |
end_date_field_id = field.id |
1940 |
- |