示例#1
0
    def test_TD_COAP_BLOCK_04(self):
        """
        Identifier: TD_COAP_BLOCK_04
        Objective: Handle POST block wise transfer for large resource
        Configuration: CoAP_CFG_01

        Pre-test conditions:
            - Client supports Block transfers
            - Server supports Block transfers
            - Server accepts creation of new resources on /large-create

        - Step 1 stimulus Client is requested to create a new resource on Server

        - Step 2 (check (CON)) Client sends a POST request containing Block1 option
            indicating block number 0 and block size

        - Step 3 (check (CON)) Client sends further requests containing
            Block1 option indicating block number and size

        - Step 4 (verify (IOP)) Server indicates presence of the complete new resource
        """
        payload = "7" * 63 * 20
        r = coap.post(self.server.url + "/large-create",
            confirmable=True, payload=payload,
            options={options.block1: (0, PLUGTEST_BLOCK_SIZE)})
        # get actual number of blocks for check
        self.assertIn(options.block1, r.sent.options)
        self.assertEqual(msgType.ack, r.msgType)
        self.assertEqual(r.code, codes.created)
        maxNUM = r.options[options.block1]
        self.assertEqual((options.BLOCK1, maxNUM, message.encodeSZX(PLUGTEST_BLOCK_SIZE), False,), r.options[options.block1] )
        assert(r.hasLocation)
示例#2
0
    def test_TD_COAP_BLOCK_02(self):
        """
        :Identifier: TD_COAP_BLOCK_02
        :Objective: Handle GET block wise transfer for large resource (late negotiation)
        :Configuration: CoAP_CFG_01

        :Pre-test conditions:
            - Client supports Block transfers
            - Server supports Block transfers
            - Server offers a large resource /large
            - Client does not know /large requires block transfer

        - Step 1 stimulus Client is requested to retrieve resource /large

        - Step 2 (check (CON)) Client sends a GET request not containing Block2 option

        - Step 3 (check (CON)) Server sends response containing Block2 option indicating block number and size

        - Step 4 (check (CON)) Client send GET requests for further blocks

        - Step 5 (check (CON)) Each request contains Block2 option indicating block number
            of the next block and size of the last received block or the
            desired size of next block

        - Step 6 (check (CON)) Server sends further responses containing
            Block2 option indicating block number and size

        - Step 7 (verify (IOP)) Client displays the received information
        """
        r = coap.get(self.server.url + "/large", confirmable=True)
        self.assertEqual(r.code, codes.content)
        self.assertEqual(r.msgType, msgType.ack)
        self.assertin(r.options, options.block2)
        # get actual number of blocks for check
        maxNUM = r.options[options.block2]
        self.assertEqual(r.options[options.block2],
            options.BLOCK2, maxNUM, message.encodeSZX(PLUGTEST_BLOCK_SIZE))