~ubuntu-branches/ubuntu/trusty/swift/trusty-updates

« back to all changes in this revision

Viewing changes to test/functionalnosetests/test_container.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2013-01-28 09:40:30 UTC
  • mfrom: (1.2.16)
  • Revision ID: package-import@ubuntu.com-20130128094030-aetz57x2qz9ye2d4
Tags: 1.7.6-0ubuntu1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/python
2
2
 
 
3
# Copyright (c) 2010-2012 OpenStack, LLC.
 
4
#
 
5
# Licensed under the Apache License, Version 2.0 (the "License");
 
6
# you may not use this file except in compliance with the License.
 
7
# You may obtain a copy of the License at
 
8
#
 
9
#    http://www.apache.org/licenses/LICENSE-2.0
 
10
#
 
11
# Unless required by applicable law or agreed to in writing, software
 
12
# distributed under the License is distributed on an "AS IS" BASIS,
 
13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 
14
# implied.
 
15
# See the License for the specific language governing permissions and
 
16
# limitations under the License.
 
17
 
3
18
import json
4
19
import unittest
5
20
from nose import SkipTest
382
397
        # Make the container accessible by the second account
383
398
        def post(url, token, parsed, conn):
384
399
            conn.request('POST', parsed.path + '/' + self.name, '',
385
 
                {'X-Auth-Token': token, 'X-Container-Read': 'test2',
386
 
                 'X-Container-Write': 'test2'})
 
400
                {'X-Auth-Token': token, 'X-Container-Read': swift_test_user[1],
 
401
                 'X-Container-Write': swift_test_user[1]})
387
402
            return check_response(conn)
388
403
        resp = retry(post)
389
404
        resp.read()
450
465
        # Now make the container also writeable by the second account
451
466
        def post(url, token, parsed, conn):
452
467
            conn.request('POST', parsed.path + '/' + self.name, '',
453
 
                {'X-Auth-Token': token, 'X-Container-Write': 'test2'})
 
468
                {'X-Auth-Token': token, 'X-Container-Write': swift_test_user[1]})
454
469
            return check_response(conn)
455
470
        resp = retry(post)
456
471
        resp.read()
537
552
        self.assertEquals(resp.getheader('Content-Type'),
538
553
                          'text/html; charset=UTF-8')
539
554
 
 
555
    def test_null_name(self):
 
556
        if skip:
 
557
            raise SkipTest
 
558
 
 
559
        def put(url, token, parsed, conn):
 
560
            conn.request('PUT', '%s/abc%%00def' % parsed.path, '',
 
561
                         {'X-Auth-Token': token})
 
562
            return check_response(conn)
 
563
        resp = retry(put)
 
564
        self.assertEquals(resp.read(), 'Invalid UTF8 or contains NULL')
 
565
        self.assertEquals(resp.status, 412)
 
566
 
540
567
 
541
568
if __name__ == '__main__':
542
569
    unittest.main()