• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

yast / yast-proxy / 10845635253

13 Sep 2024 08:20AM UTC coverage: 23.545%. Remained the same
10845635253

push

github

lslezak
Clean merge of SP7

178 of 756 relevant lines covered (23.54%)

0.74 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

20.0
/src/include/proxy/dialogs.rb
1
# File:  include/proxy/dialogs.ycp
2
# Package:  Proxy configuration
3
# Authors:  Michal Svec <msvec@suse.cz>
4
#
5
# $Id$
6
module Yast
1✔
7
  module ProxyDialogsInclude
1✔
8
    def initialize_proxy_dialogs(_include_target)
1✔
9
      Yast.import "UI"
3✔
10

11
      textdomain "proxy"
3✔
12

13
      Yast.import "Address"
3✔
14
      Yast.import "Hostname"
3✔
15
      Yast.import "Label"
3✔
16
      Yast.import "Mode"
3✔
17
      Yast.import "Netmask"
3✔
18
      Yast.import "Popup"
3✔
19
      Yast.import "Proxy"
3✔
20
      Yast.import "String"
3✔
21
      Yast.import "URL"
3✔
22
      Yast.import "Wizard"
3✔
23

24
      @enabled = false
3✔
25
      @http = ""
3✔
26
      @https = ""
3✔
27
      @ftp = ""
3✔
28
      @no = ""
3✔
29
      @user = ""
3✔
30
      @pass = ""
3✔
31
      @same_proxy = false
3✔
32
      # String to pre-filled into the proxy server field
33
      @prefill = "http://"
3✔
34

35
      # Known return codes - good proxy response
36
      @return_codes_good = [
37
        "200", # OK
3✔
38
        "201", # Created
39
        "202", # Accepted
40
        "203", # Non-Authorative Information
41
        "204", # No Content
42
        "205", # Reset Content
43
        "206", # Partial Content
44
        "300", # Multiple Choices
45
        "301", # Moved Permanently
46
        "302", # Moved Temporarily
47
        "303", # See Other
48
        "304", # Not Modified
49
        "305"
50
      ] # Use Proxy
51

52
      # Known return codes - bad proxy response
53
      @return_codes_bad = [
54
        # Proxy Errors
55
        "400", # Bad Request
3✔
56
        "401", # Authorization Required
57
        "402", # Payment Required (not used yet)
58
        "403", # Forbidden
59
        "404", # Not Found
60
        "405", # Method Not Allowed
61
        "406", # Not Acceptable (encoding)
62
        "407", # Proxy Authentication Required
63
        "408", # Request Timed Out
64
        "409", # Conflicting Request
65
        "410", # Gone
66
        "411", # Content Length Required
67
        "412", # Precondition Failed
68
        "413", # Request Entity Too Long
69
        "414", # Request URI Too Long
70
        "415", # Unsupported Media Type
71
        # Server Errors
72
        "500", # Internal Server Error
73
        "501", # Not Implemented
74
        "502", # Bad Gateway
75
        "503", # Service Unavailable
76
        "504", # Gateway Timeout
77
        "505"
78
      ] # HTTP Version Not Supported
79
    end
80

81
    def modified
1✔
82
      !(Proxy.http == @http && Proxy.ftp == @ftp && Proxy.no == @no &&
×
83
        Proxy.https == @https &&
84
        Proxy.user == @user &&
85
        Proxy.pass == @pass &&
86
        Proxy.enabled == @enabled)
87
    end
88

89
    # from OnlineUpdateDialogs.ycp
90
    # Function opens the generic error dialog including the
91
    # message with the [Details >>] button. It handles pressing
92
    # the button itself.
93
    #
94
    # @param [String] message with the short error message
95
    # @param [String] details with all of the error details
96
    def ErrorPopupGeneric(message, details)
1✔
97
      # Informative label
98
      details = _("No details available.") if Builtins.size(details) == 0
×
99

100
      # A push button
101
      detailsStringOn = _("&Details <" + "<") # avoid confusing Emacs
×
102
      # A push button
103
      detailsStringOff = _("&Details >>")
×
104

105
      detailsButton = PushButton(Id(:details), detailsStringOff)
×
106

107
      heading = Label.ErrorMsg
×
108

109
      buttons = HBox(detailsButton, PushButton(Id(:ok), Label.OKButton))
×
110

111
      UI.OpenDialog(
×
112
        Opt(:decorated),
113
        VBox(
114
          HBox(HSpacing(0.5), Left(Heading(heading))),
115
          VSpacing(0.2),
116
          Left(Label(message)),
117
          ReplacePoint(Id(:rp), Empty()),
118
          buttons
119
        )
120
      )
121

122
      ret = nil
×
123
      showDetails = false
×
124

125
      while ret != :ok
×
126
        ret = UI.UserInput
×
127

128
        next unless ret == :details
×
129

130
        if showDetails
×
131
          UI.ReplaceWidget(Id(:rp), Empty())
×
132
          UI.ChangeWidget(Id(:details), :Label, detailsStringOff)
×
133
        else
134
          UI.ReplaceWidget(
×
135
            Id(:rp),
136
            HBox(
137
              HSpacing(0.5),
138
              HWeight(1, RichText(Opt(:plainText), details)),
139
              HSpacing(0.5)
140
            )
141
          )
142
          UI.ChangeWidget(Id(:details), :Label, detailsStringOn)
×
143
        end
144
        showDetails = !showDetails
×
145
      end
146

147
      UI.CloseDialog
×
148

149
      nil
150
    end
151

152
    # Function checks the proxy-return code and displays a pop-up
153
    # if the code means an error.
154
    #
155
    # @param [String] test_type HTTP, HTTPS or FTP
156
    # @param [String] proxy_ret_stderr such as "HTTP/1.0 403 Forbidden"
157
    # @return [Boolean] true if the proxy response is a good one
158
    def TestProxyReturnCode(test_type, proxy_ret_stderr)
1✔
159
      proxy_retcode = ""
3✔
160
      # getting the return code string from the stderr
161
      Builtins.foreach(Builtins.splitstring(proxy_ret_stderr, "\r?\n")) do |proxy_stderr|
3✔
162
        if Builtins.regexpmatch(
82✔
163
          proxy_stderr, "HTTP/[0-9.]+ [0-9]+"
164
        )
165
          proxy_retcode = Builtins.regexpsub(proxy_stderr, ".*(HTTP.*)",
2✔
166
            "\\1")
167
        end
168
      end
169

170
      Builtins.y2milestone("Proxy %1 test: %2", test_type, proxy_retcode)
3✔
171

172
      # The default error code, replaced with the current error code got from
173
      # proxy if any code found
174
      retcode = _("Unknown Error Code")
3✔
175
      Builtins.foreach(Builtins.splitstring(proxy_retcode, " ")) do |ret_code_part|
3✔
176
        if Builtins.regexpmatch(ret_code_part, "^[0-9]+$") &&
9✔
177
            Ops.greater_or_equal(Builtins.size(ret_code_part), 3)
178
          retcode = ret_code_part
2✔
179
        end
180
      end
181

182
      # known good return code
183
      return true if Builtins.contains(@return_codes_good, retcode)
3✔
184

185
      # known bad return code
186
      if Builtins.contains(@return_codes_bad, retcode)
2✔
187
        # Error message,
188
        #  %1 is a string "HTTP", "HTTPS" or "FTP"
189
        #  %2 is an error string such as "HTTP/1.0 403 Forbidden"
190
        ErrorPopupGeneric(
1✔
191
          Builtins.sformat(
192
            _(
193
              "An error occurred during the %1 proxy test.\nProxy return code: %2.\n"
194
            ),
195
            test_type,
196
            proxy_retcode
197
          ),
198
          proxy_ret_stderr
199
        )
200
        return false
1✔
201
      end
202

203
      # Unknown return code,
204
      #  %1 is the string HTTP, "HTTPS" or FTP,
205
      #  %2 is an error string such as "HTTP/1.0 403 Forbidden"
206
      ErrorPopupGeneric(
1✔
207
        Builtins.sformat(
208
          _(
209
            "An unknown error occurred during the %1 proxy test.\nProxy return code: %2.\n"
210
          ),
211
          test_type,
212
          proxy_retcode
213
        ),
214
        proxy_ret_stderr
215
      )
216

217
      nil
218
    end
219

220
    # Function test the current HTTP and FTP proxy settings.
221
    # It currently ignores the "No Proxy" value.
222
    #
223
    # @return [Boolean] true if successful
224
    def TestProxySettings
1✔
225
      # Actually it doesn't make sense to test the proxy settings when proxy is off
226
      return true unless @enabled
×
227

228
      UI.OpenDialog(
×
229
        # An informative popup label diring the proxy testings
230
        Left(Label(_("Testing the current proxy settings...")))
231
      )
232
      ret = Proxy.RunTestProxy(@http, @https, @ftp, @user, @pass)
×
233
      UI.CloseDialog
×
234

235
      # curl error
236
      if Ops.get_boolean(ret, ["HTTP", "tested"], true) == true
×
237
        if Ops.get_integer(ret, ["HTTP", "exit"], 1) != 0
×
238
          # TRANSLATORS: Error popup message
239
          ErrorPopupGeneric(
×
240
            _("An error occurred during the HTTP proxy test."),
241
            Ops.get_string(ret, ["HTTP", "stderr"], "")
242
          )
243
          UI.SetFocus(Id(:http))
×
244
          return false
×
245
        # curl works - proxy error
246
        elsif !TestProxyReturnCode(
×
247
          "HTTP",
248
          Ops.get_string(ret, ["HTTP", "stderr"], "")
249
        )
250
          UI.SetFocus(Id(:http))
×
251
          return false
×
252
        end
253
      end
254

255
      if Ops.get_boolean(ret, ["HTTPS", "tested"], true) == true
×
256
        # curl error
257
        if Ops.get_integer(ret, ["HTTPS", "exit"], 1) != 0
×
258
          # TRANSLATORS: Error popup message
259
          ErrorPopupGeneric(
×
260
            _("An error occurred during the HTTPS proxy test."),
261
            Ops.get_string(ret, ["HTTPS", "stderr"], "")
262
          )
263
          UI.SetFocus(Id(:https))
×
264
          return false
×
265
        # curl works - proxy error
266
        elsif !TestProxyReturnCode(
×
267
          "HTTPS",
268
          Ops.get_string(ret, ["HTTPS", "stderr"], "")
269
        )
270
          UI.SetFocus(Id(:https))
×
271
          return false
×
272
        end
273
      end
274

275
      if Ops.get_boolean(ret, ["FTP", "tested"], true) == true
×
276
        # curl error
277
        if Ops.get_integer(ret, ["FTP", "exit"], 1) != 0
×
278
          # TRANSLATORS: Error popup message
279
          ErrorPopupGeneric(
×
280
            _("An error occurred during the FTP proxy test."),
281
            Ops.get_string(ret, ["FTP", "stderr"], "")
282
          )
283
          UI.SetFocus(Id(:ftp))
×
284
          return false
×
285
        # curl works - proxy error
286
        elsif !TestProxyReturnCode(
×
287
          "FTP",
288
          Ops.get_string(ret, ["FTP", "stderr"], "")
289
        )
290
          UI.SetFocus(Id(:ftp))
×
291
          return false
×
292
        end
293
      end
294

295
      # Popup message
296
      Popup.Message(_("Proxy settings work correctly."))
×
297

298
      true
×
299
    end
300

301
    def InitSameProxy
1✔
302
      # We have the same (non-empty) proxy URL for all protocols
303
      if @http != @prefill && @http == @https && @https == @ftp
×
304
        UI.ChangeWidget(Id(:same_proxy), :Value, true)
×
305
        UI.ChangeWidget(Id(:https), :Enabled, false)
×
306
        UI.ChangeWidget(Id(:https), :Value, @prefill)
×
307
        UI.ChangeWidget(Id(:ftp), :Enabled, false)
×
308
        UI.ChangeWidget(Id(:ftp), :Value, @prefill)
×
309
      end
310

311
      nil
312
    end
313

314
    def QueryWidgets
1✔
315
      @same_proxy = Convert.to_boolean(UI.QueryWidget(Id(:same_proxy), :Value))
×
316
      @http = Convert.to_string(UI.QueryWidget(Id(:http), :Value))
×
317
      if @same_proxy
×
318
        @https = @http
×
319
        @ftp = @http
×
320
      else
321
        @https = Convert.to_string(UI.QueryWidget(Id(:https), :Value))
×
322
        @ftp = Convert.to_string(UI.QueryWidget(Id(:ftp), :Value))
×
323
      end
324

325
      @user = Convert.to_string(UI.QueryWidget(Id(:user), :Value))
×
326
      @pass = Convert.to_string(UI.QueryWidget(Id(:pass), :Value))
×
327
      @enabled = Convert.to_boolean(UI.QueryWidget(Id(:enabled), :Value))
×
328

329
      @no = Convert.to_string(UI.QueryWidget(Id(:no), :Value))
×
330

331
      nil
332
    end
333

334
    def ValidateNoProxyDomains(no_proxies)
1✔
335
      proxy_list = Builtins.splitstring(no_proxies, ",")
×
336
      validate = true
×
337
      hostname = ""
×
338
      netmask = ""
×
339

340
      Builtins.foreach(proxy_list) do |one_proxy|
×
341
        one_proxy = String.CutBlanks(one_proxy)
×
342
        # IP/netmask
343
        if Builtins.findfirstof(one_proxy, "/").nil?
×
344
          hostname = one_proxy
×
345
          # .domain.name case
346
          hostname = Builtins.substring(hostname, 1) if Builtins.findfirstof(hostname, ".") == 0
×
347
        else
348
          tmp = Builtins.splitstring(one_proxy, "/")
×
349
          hostname = Ops.get(tmp, 0, "")
×
350
          netmask = Ops.get(tmp, 1, "")
×
351

352
          validate = false if !Netmask.Check(netmask)
×
353
        end
354
        Builtins.y2milestone("hostname %1, netmask %2", hostname, netmask)
×
355
        validate = false if !Address.Check(hostname)
×
356
      end
357

358
      validate
×
359
    end
360

361
    def UrlContainPassword(url)
1✔
362
      ret = URL.Parse(url)
×
363

364
      Ops.greater_than(Builtins.size(Ops.get_string(ret, "pass", "")), 0)
×
365
    end
366

367
    # If modified, ask for confirmation
368
    # @return true if abort is confirmed
369
    def ReallyAbortCond
1✔
370
      (!modified || installation?) || Popup.ReallyAbort(true)
×
371
    end
372

373
    # Proxy dialog
374
    # @param [Boolean] _standalone true if not run from another ycp client
375
    # @return dialog result
376
    def ProxyMainDialog(_standalone)
1✔
377
      @enabled = Proxy.enabled
×
378
      @http = Proxy.http
×
379
      @https = Proxy.https
×
380
      @ftp = Proxy.ftp
×
381
      @no = Proxy.no
×
382
      @user = Proxy.user
×
383
      @pass = Proxy.pass
×
384

385
      @http = @prefill if @http == ""
×
386
      @https = @prefill if @https == ""
×
387
      @ftp = @prefill if @ftp == ""
×
388

389
      # Proxy dialog caption
390
      caption = _("Proxy Configuration")
×
391

392
      # Proxy dialog help 1/8
393
      help = Ops.add(
×
394
        Ops.add(
395
          Ops.add(
396
            _(
397
              "<p>Configure your Internet proxy (caching) settings here.</p>\n" \
398
              "<p><b>Note:</b> It is generally recommended to relogin for the " \
399
              "settings to take effect, \n" \
400
              "however in some cases the application may pick up new settings " \
401
              "immediately. Please check \n" \
402
              "what your application (web browser, ftp client,...) supports. </p>"
403
            ) +
404
              # Proxy dialog help 2/8
405
              _(
406
                "<p><b>HTTP Proxy URL</b> is the name of the proxy server for your access\n" \
407
                "to the World Wide Web (WWW).</p>\n"
408
              ) +
409
              # Proxy dialog help 3/8
410
              _(
411
                "<p><b>HTTPS Proxy URL</b> is the name of the proxy server for your secured " \
412
                "access\nto the World Wide Web (WWW).</p>\n"
413
              ) +
414
              # Proxy dialog help 3.5/8
415
              _("<p>Example: <i>http://proxy.example.com:3128/</i></p>") +
416
              # Proxy dialog help 4/8
417
              _(
418
                "<p><b>FTP Proxy URL</b> is the name of the proxy server for your access\n" \
419
                "to the file transfer services (FTP).</p>"
420
              ) +
421
              # Proxy dialog help 5/8
422
              _(
423
                "<p>If you check <b>Use the Same Proxy for All Protocols</b>, it is\n" \
424
                "enough to fill in the HTTP proxy URL. It will be used for all protocols\n" \
425
                "(HTTP, HTTPS and FTP).\n"
426
              ),
427
            # Proxy dialog help 6/8
428
            Builtins.sformat(
429
              _(
430
                "<p><b>No Proxy Domains</b> is a comma-separated list of domains\n" \
431
                "for which the requests should be made directly without caching,\n" \
432
                "for example, <i>%1</i>.</p>\n"
433
              ),
434
              "localhost, .intranet.example.com, www.example.com"
435
            )
436
          ),
437
          # Proxy dialog help 7/8
438
          _(
439
            "<p>If you are using a proxy server with authorization, enter\n" \
440
            "the <b>Proxy User Name</b> and <b>Proxy Password</b>. A valid username\n" \
441
            "consists of printable ASCII characters only (except for quotation marks).</p>\n"
442
          )
443
        ),
444
        # Proxy dialog help 8/8
445
        if Mode.installation
×
446
          ""
×
447
        else
448
          _(
×
449
            "<p>Press <b>Test Proxy Settings</b> to test\n" \
450
            "the current configuration for HTTP, HTTPS, and FTP proxy.</p> \n"
451
          )
452
        end
453
      )
454

455
      display_info = UI.GetDisplayInfo
×
456
      textmode = Ops.get_boolean(display_info, "TextMode", false)
×
457

458
      s = textmode ? 0.2 : 0.5
×
459

460
      # Proxy dialog contents
461
      contents = HBox(
×
462
        HSpacing(5),
463
        VBox(
464
          # CheckBox entry label
465
          Left(
466
            CheckBox(Id(:enabled), Opt(:notify), _("&Enable Proxy"), @enabled)
467
          ),
468
          VSpacing(s),
469
          # Frame label
470
          Frame(
471
            Id(:frame1),
472
            _("Proxy Settings"),
473
            HBox(
474
              HSpacing(2),
475
              VBox(
476
                VSpacing(0.2),
477
                # Text entry label
478
                TextEntry(Id(:http), _("&HTTP Proxy URL"), @http),
479
                VSpacing(0.2),
480
                TextEntry(Id(:https), _("HTTP&S Proxy URL"), @https),
481
                VSpacing(0.2),
482
                # Text entry label
483
                TextEntry(Id(:ftp), _("F&TP Proxy URL"), @ftp),
484
                VSpacing(0.2),
485
                Left(
486
                  CheckBox(
487
                    Id(:same_proxy),
488
                    Opt(:notify),
489
                    _("Us&e the Same Proxy for All Protocols")
490
                  )
491
                ),
492
                # Text entry label
493
                # domains without proxying
494
                TextEntry(Id(:no), _("No Proxy &Domains"), @no),
495
                textmode ? Empty() : VSpacing(0.4)
×
496
              ),
497
              HSpacing(2)
498
            )
499
          ),
500
          VSpacing(s),
501
          Frame(
502
            Id(:frame2),
503
            _("Proxy Authentication"),
504
            HBox(
505
              HSpacing(2),
506
              VBox(
507
                # Text entry label
508
                HBox(
509
                  InputField(
510
                    Id(:user),
511
                    Opt(:hstretch),
512
                    _("Proxy &User Name"),
513
                    @user
514
                  ),
515
                  HSpacing(0.5),
516
                  # Password entry label
517
                  Password(
518
                    Id(:pass),
519
                    Opt(:hstretch),
520
                    _("Proxy &Password"),
521
                    @pass
522
                  ),
523
                  textmode ? Empty() : VSpacing(0.4)
×
524
                )
525
              ),
526
              HSpacing(2)
527
            )
528
          ),
529
          VSpacing(s),
530
          # Test Proxy Settings - push button
531
          if Mode.installation
×
532
            Empty()
×
533
          else
534
            PushButton(Id("test_proxy"), _("Test Pr&oxy Settings"))
×
535
          end
536
        ),
537
        HSpacing(5)
538
      )
539

540
      Wizard.SetContentsButtons(
×
541
        caption,
542
        contents,
543
        help,
544
        Label.BackButton,
545
        Label.NextButton
546
      )
547
      adjust_wizard_buttons unless installation?
×
548

549
      # #103841, relaxed. now avoiding only quotes
550
      # #337048 allow using space as well
551
      # was CAlnum() + ".:_-/\\"
552
      _ValidCharsUsername = Ops.add(
×
553
        Builtins.deletechars(String.CGraph, "'\""),
554
        " "
555
      )
556
      UI.ChangeWidget(Id(:http), :ValidChars, URL.ValidChars)
×
557
      UI.ChangeWidget(Id(:https), :ValidChars, URL.ValidChars)
×
558
      UI.ChangeWidget(Id(:ftp), :ValidChars, URL.ValidChars)
×
559
      # '/' character for subnets definition - #490661
560
      UI.ChangeWidget(
×
561
        Id(:no),
562
        :ValidChars,
563
        Ops.add(Hostname.ValidCharsDomain, " ,/")
564
      )
565
      UI.ChangeWidget(Id(:user), :ValidChars, _ValidCharsUsername)
×
566
      UI.ChangeWidget(Id(:frame1), :Enabled, @enabled)
×
567
      UI.ChangeWidget(Id(:frame2), :Enabled, @enabled)
×
568
      UI.ChangeWidget(Id("test_proxy"), :Enabled, @enabled) if !Mode.installation
×
569
      InitSameProxy()
×
570

571
      if @enabled == true
×
572
        UI.SetFocus(Id(:http))
×
573
      else
574
        UI.SetFocus(Id(:enabled))
×
575
      end
576

577
      ret = nil
×
578
      loop do
×
579
        ret = UI.UserInput
×
580
        QueryWidgets()
×
581

582
        # abort?
583
        case ret
×
584
        when :abort, :cancel, :back
585
          break if ReallyAbortCond()
×
586

587
          next
×
588
        when :enabled
589
          UI.ChangeWidget(Id(:frame1), :Enabled, @enabled)
×
590
          UI.ChangeWidget(Id(:frame2), :Enabled, @enabled)
×
591
          UI.ChangeWidget(Id("test_proxy"), :Enabled, @enabled)
×
592
          InitSameProxy()
×
593
          next
×
594
        when :same_proxy
595
          UI.ChangeWidget(Id(:https), :Value, @prefill)
×
596
          UI.ChangeWidget(Id(:ftp), :Value, @prefill)
×
597
          UI.ChangeWidget(Id(:https), :Enabled, !@same_proxy)
×
598
          UI.ChangeWidget(Id(:ftp), :Enabled, !@same_proxy)
×
599
          next
×
600
        # next
601
        when :next, "test_proxy"
602
          @http = "" if @http == @prefill
×
603
          @https = "" if @https == @prefill
×
604
          @ftp = "" if @ftp == @prefill
×
605

606
          break if @enabled == false
×
607

608
          if @http == "" && @https == "" && @ftp == ""
×
609
            # Popup error text - http, https and ftp proxy URLs are blank
610
            if !Popup.ContinueCancel(
×
611
              _(
612
                "Proxy is enabled, but no proxy URL has been specified.\nReally use these settings?"
613
              )
614
            )
615
              next
×
616
            end
617
          else
618
            password_inside = UrlContainPassword(@http) ||
×
619
              UrlContainPassword(@https) ||
620
              UrlContainPassword(@ftp)
621

622
            if password_inside && ret != "test_proxy" && !Popup.ContinueCancel(
×
623
                _(
624
                  "Security warning:\n" \
625
                  "Username and password will be stored unencrypted\n" \
626
                  "in a worldwide readable plaintext file.\n" \
627
                  "Really use these settings?"
628
                )
629
              )
630
              next
×
631
            end
632
          end
633
          # check_*
634
          if @user == "" && @pass != ""
×
635
            # Popup::Error text
636
            Popup.Error(
×
637
              _("You cannot enter a password and leave the user name empty.")
638
            )
639
            UI.SetFocus(Id(:user))
×
640
            next
×
641
          end
642
          if @http != "" && @http != @prefill
×
643
            if !URL.Check(@http)
×
644
              # Popup::Error text
645
              Popup.Error(_("HTTP proxy URL is invalid."))
×
646
              UI.SetFocus(Id(:http))
×
647
              next
×
648
            end
649
            urlmap = URL.Parse(@http)
×
650
            if Ops.get_string(urlmap, "scheme", "") == ""
×
651
              # Popup::Error text
652
              Popup.Error(
×
653
                _("HTTP proxy URL must contain a scheme specification (http).")
654
              )
655
              UI.SetFocus(Id(:http))
×
656
              next
×
657
            end
658
          end
659
          if @https != "" && @https != @prefill
×
660
            if !URL.Check(@https)
×
661
              # Popup::Error text
662
              Popup.Error(_("The HTTPS proxy URL is invalid."))
×
663
              UI.SetFocus(Id(:https))
×
664
              next
×
665
            end
666
            urlmap = URL.Parse(@https)
×
667
            if Ops.get_string(urlmap, "scheme", "") == ""
×
668
              # Popup::Error text
669
              Popup.Error(
×
670
                _(
671
                  "The HTTPS proxy URL must contain a scheme specification (http)."
672
                )
673
              )
674
              UI.SetFocus(Id(:https))
×
675
              next
×
676
            end
677
          end
678
          if @ftp != "" && @ftp != @prefill
×
679
            if !URL.Check(@ftp)
×
680
              # Popup::Error text
681
              Popup.Error(_("FTP proxy URL is invalid."))
×
682
              UI.SetFocus(Id(:ftp))
×
683
              next
×
684
            end
685
            urlmap = URL.Parse(@ftp)
×
686
            if Ops.get_string(urlmap, "scheme", "") == ""
×
687
              # Popup::Error text
688
              Popup.Error(
×
689
                _("FTP proxy URL must contain a scheme specification (http).")
690
              )
691
              UI.SetFocus(Id(:ftp))
×
692
              next
×
693
            end
694
          end
695
          if @no != "" && !@no.nil? && !ValidateNoProxyDomains(@no)
×
696
            # Translators: no proxy domain is a domain that can be accessed without proxy
697
            Popup.Error(
×
698
              _(
699
                "One or more no proxy domains are invalid. \n" \
700
                "Check if all domains match one of the following:\n" \
701
                "* IP address\n" \
702
                "* IP address/netmask\n" \
703
                "* Fully qualified hostname\n" \
704
                "* Domain name prefixed by '.'"
705
              )
706
            )
707
            UI.SetFocus(Id(:no))
×
708
            next
×
709
          end
710

711
          break if ret == :next
×
712

713
          TestProxySettings() if ret == "test_proxy"
×
714
        else
715
          Builtins.y2error("unexpected retcode: %1", ret)
×
716
          next
×
717
        end
718
      end
719

720
      if ret == :next
×
721
        if !modified
×
722
          Builtins.y2debug("not modified")
×
723
          return deep_copy(ret)
×
724
        end
725

726
        Proxy.enabled = @enabled
×
727
        if @enabled
×
728
          Proxy.http = @http
×
729
          Proxy.https = @https
×
730
          Proxy.ftp = @ftp
×
731
          Proxy.no = @no
×
732
          Proxy.user = @user
×
733
          Proxy.pass = @pass
×
734
        end
735

736
        Proxy.SetModified
×
737
      end
738

739
      deep_copy(ret)
×
740
    end
741

742
  private
1✔
743

744
    # Sets OK/Cancel wizard buttons
745
    def adjust_wizard_buttons
1✔
746
      Wizard.SetNextButton(:next, Label.OKButton)
×
747
      Wizard.SetAbortButton(:abort, Label.CancelButton)
×
748
      Wizard.HideBackButton
×
749
    end
750

751
    # Determines whether running in installation mode
752
    #
753
    # We do not use Stage.initial because of firstboot, which runs in 'installation' mode
754
    # but in 'firstboot' stage.
755
    #
756
    # @return [Boolean] Boolean if running in installation or update mode
757
    def installation?
1✔
758
      Mode.installation || Mode.update
×
759
    end
760
  end
761
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc