示例#1
0
 def test_change_acl(self):
     with self.app.app_context():
         bit_store = BitStore('test_pub', 'test_package')
         s3 = boto3.client('s3')
         bucket_name = self.app.config['S3_BUCKET_NAME']
         s3.create_bucket(Bucket=bucket_name)
         read_me_key = bit_store.build_s3_key('test.md')
         data_key = bit_store.build_s3_key('data.csv')
         metadata_key = bit_store.build_s3_key('datapackage.json')
         s3.put_object(Bucket=bucket_name, Key=read_me_key, Body='')
         s3.put_object(Bucket=bucket_name, Key=data_key, Body='')
         s3.put_object(Bucket=bucket_name, Key=metadata_key, Body='')
         bit_store.change_acl("private")
         res = s3.get_object_acl(Bucket=bucket_name, Key=read_me_key)
         grant = res['Grants'][0]['Permission']
         self.assertEqual(grant, 'FULL_CONTROL')
示例#2
0
def delete_data_package(publisher, package):
    """
    DPR data package soft delete operation operation.
    This API is responsible for mark for delete of data package
    ---
    tags:
        - package
    parameters:
        - in: path
          name: publisher
          type: string
          required: true
          description: publisher name
        - in: path
          name: package
          type: string
          required: true
          description: package name
    responses:
        500:
            description: Internal Server Error
        200:
            description: Success Message
            schema:
                id: put_package_success
                properties:
                    status:
                        type: string
                        default: OK
    """
    try:
        bitstore = BitStore(publisher=publisher, package=package)
        status_acl = bitstore.change_acl('private')
        status_db = MetaDataDB.change_status(publisher, package)
        if status_acl and status_db:
            return jsonify({"status": "OK"}), 200
        if not status_acl:
            raise Exception('Failed to change acl')
        if not status_db:
            raise Exception('Failed to change status')
    except Exception as e:
        app.logger.error(e)
        return handle_error('GENERIC_ERROR', e.message, 500)