I'm pretty sure I have one of those. If I'm right I installed one.
A couple of months ago I removed the cap from a clean out pipe, but the threads were too corroded to screw it back in, so I got a rubber pipe plug, stuck it in the opening, tighten it, and problem solved.
There is no pipe fitting that is made like the photo that You attached to your message - what your photo shows is something that has been pushed into the pipe itself - not connected to it.
As Mr_David has identified there is half of a pipe Union on the end of the pipe and if it is a 1/2" pipe I am guessing that some idiot has pushed a Schrader type valve [Car tyre type] down into the pipe to either `Cap it` [!] or to do a `Do it yourself` pressure test [!].
I have not checked the diameter of the bottom rubber `grommet` like end of the valve sheath on one of these car tyre Shrader valves [because that part is not visible when the valve is fitted to a car tyre] but I know that they are bigger that they look in the screenshot that I have attached - I am just guessing that it might be a tight fit inside a 1/2" iron pipe ?
Also there are MANY types of `Shrader valves` - used for a multitude of operations - I guessed the car tyre type only because of the Rubber `grommet` like end piece - however it could be another type of these valves that just happens to also have a rubber surround or circular end which fitted tightly into the pipe ?
I am hoping to be able to attach a screenshot of a car tyre type Shrader valve to show how it is possible that the rubber `grommet` like end of the valve sheath might be what is `Sealing` the end of the pipe [!].
Whatever has previously happened You have NOT got a correctly capped off pipe and if it is still a `Live` GAS pipe You need to get it capped off correctly.
Although this situation may have existed for years [?] if I am correct the rubber outer sheath of a Car tyre type Shrader valve [or any other rubber `seal`] will be deteriorating over time and could cause a serious Gas leak with the obvious Dangers that would present.
I know I am way late to this thread but I am going with what is known as a “football”. They are a rubber expanding plug that takes a special key to install and remove. These are installed by the gas company for people who are delinquent on their bills or the home has a bad leak or something that the gas company has determined is unsafe. Either way, it’s to prevent a homeowner/tenant from turning on the gas.