def test_10():
    channel = "test_10-" + str(time.time())
    message = "Hello World"
    auth_key = "auth-" + channel
    pubnub.set_auth_key(auth_key)

    def _cb1(resp, ch=None):
        assert False

    def _err1(resp):
        assert resp['message'] == 'Forbidden'
        assert resp['payload'] == {u'channels': [channel]}

        def _cb2(resp, ch=None):
            assert resp == {
                'message': u'Success',
                'payload': {u'channels': {channel: {u'r': 1, u'm': 0, u'w': 1}},
                            u'subscribe_key': subkey,
                            u'level': u'channel', u'ttl': 10}
            }

            def _cb3(resp, ch=None):
                assert resp[0] == 1

                def _cb4(resp, ch=None):
                    assert resp == {
                        'message': u'Success',
                        'payload': {u'channels': {channel: {u'r': 0, u'm': 0, u'w': 0}},
                                    u'subscribe_key': subkey,
                                    u'level': u'channel', u'ttl': 1}
                    }

                    def _cb5(resp, ch=None):
                        print(resp)
                        assert False

                    def _err5(resp):
                        assert resp['message'] == 'Forbidden'
                        assert resp['payload'] == {u'channels': [channel]}

                    time.sleep(5)
                    pubnub.publish(channel=channel, message=message, callback=_cb5, error=_err5)

                def _err4(resp):
                    assert False

                pubnub_pam.revoke(channel=channel, callback=_cb4, error=_err4)

            def _err3(resp):
                assert False

            time.sleep(5)
            pubnub.publish(channel=channel, message=message, callback=_cb3, error=_err3)

        def _err2(resp):
            assert False

        pubnub_pam.grant(channel=channel, read=True, write=True, ttl=10, callback=_cb2, error=_err2)

    pubnub.publish(channel=channel, message=message, callback=_cb1, error=_err1)


# Complete flow , try publish on forbidden channel, grant permission subkey level for subkey and try again.
# then revoke and try again
dataset/ETHPy150Open pubnub/python/python-twisted/tests/test_grant_async.py/test_10/original