Code Duplication    Length = 36-36 lines in 2 locations

gvm/protocols/gmpv208/gmpv208.py 1 location

@@ 248-283 (lines=36) @@
245
        """
246
        return self._authenticated
247
248
    def authenticate(self, username: str, password: str) -> Any:
249
        """Authenticate to gvmd.
250
251
        The generated authenticate command will be send to server.
252
        Afterwards the response is read, transformed and returned.
253
254
        Arguments:
255
            username: Username
256
            password: Password
257
258
        Returns:
259
            Transformed response from server.
260
        """
261
        cmd = XmlCommand("authenticate")
262
263
        if not username:
264
            raise RequiredArgument(
265
                function=self.authenticate.__name__, argument='username'
266
            )
267
268
        if not password:
269
            raise RequiredArgument(
270
                function=self.authenticate.__name__, argument='password'
271
            )
272
273
        credentials = cmd.add_element("credentials")
274
        credentials.add_element("username", username)
275
        credentials.add_element("password", password)
276
277
        self._send(cmd.to_string())
278
        response = self._read()
279
280
        if _check_command_status(response):
281
            self._authenticated = True
282
283
        return self._transform(response)
284
285
    def create_alert(
286
        self,

gvm/protocols/gmpv7/gmpv7.py 1 location

@@ 223-258 (lines=36) @@
220
        """
221
        return self._authenticated
222
223
    def authenticate(self, username: str, password: str) -> Any:
224
        """Authenticate to gvmd.
225
226
        The generated authenticate command will be send to server.
227
        Afterwards the response is read, transformed and returned.
228
229
        Arguments:
230
            username: Username
231
            password: Password
232
233
        Returns:
234
            Transformed response from server.
235
        """
236
        cmd = XmlCommand("authenticate")
237
238
        if not username:
239
            raise RequiredArgument(
240
                function=self.authenticate.__name__, argument='username'
241
            )
242
243
        if not password:
244
            raise RequiredArgument(
245
                function=self.authenticate.__name__, argument='password'
246
            )
247
248
        credentials = cmd.add_element("credentials")
249
        credentials.add_element("username", username)
250
        credentials.add_element("password", password)
251
252
        self._send(cmd.to_string())
253
        response = self._read()
254
255
        if _check_command_status(response):
256
            self._authenticated = True
257
258
        return self._transform(response)
259
260
    def create_agent(
261
        self,