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

yast / yast-proxy / 4324607476

pending completion
4324607476

push

github

Unknown Committer
Unknown Commit Message

177 of 757 relevant lines covered (23.38%)

0.73 hits per line

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

19.55
/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
        proxy_retcode = Builtins.regexpsub(proxy_stderr, ".*(HTTP.*)", "\\1") if Builtins.regexpmatch(proxy_stderr, "HTTP/[0-9.]+ [0-9]+")
82✔
163
      end
164

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

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

176
      # known good return code
177
      return true if Builtins.contains(@return_codes_good, retcode)
3✔
178

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

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

211
      nil
212
    end
213

214
    # Function test the current HTTP and FTP proxy settings.
215
    # It currently ignores the "No Proxy" value.
216
    #
217
    # @return [Boolean] true if successful
218
    def TestProxySettings
1✔
219
      # Actually it doesn't make sense to test the proxy settings when proxy is off
220
      return true unless @enabled
×
221

222
      UI.OpenDialog(
×
223
        # An informative popup label diring the proxy testings
224
        Left(Label(_("Testing the current proxy settings...")))
225
      )
226
      ret = Proxy.RunTestProxy(@http, @https, @ftp, @user, @pass)
×
227
      UI.CloseDialog
×
228

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

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

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

289
      # Popup message
290
      Popup.Message(_("Proxy settings work correctly."))
×
291

292
      true
×
293
    end
294

295
    def InitSameProxy
1✔
296
      # We have the same (non-empty) proxy URL for all protocols
297
      if @http != @prefill && @http == @https && @https == @ftp
×
298
        UI.ChangeWidget(Id(:same_proxy), :Value, true)
×
299
        UI.ChangeWidget(Id(:https), :Enabled, false)
×
300
        UI.ChangeWidget(Id(:https), :Value, @prefill)
×
301
        UI.ChangeWidget(Id(:ftp), :Enabled, false)
×
302
        UI.ChangeWidget(Id(:ftp), :Value, @prefill)
×
303
      end
304

305
      nil
306
    end
307

308
    def QueryWidgets
1✔
309
      @same_proxy = Convert.to_boolean(UI.QueryWidget(Id(:same_proxy), :Value))
×
310
      @http = Convert.to_string(UI.QueryWidget(Id(:http), :Value))
×
311
      if @same_proxy
×
312
        @https = @http
×
313
        @ftp = @http
×
314
      else
315
        @https = Convert.to_string(UI.QueryWidget(Id(:https), :Value))
×
316
        @ftp = Convert.to_string(UI.QueryWidget(Id(:ftp), :Value))
×
317
      end
318

319
      @user = Convert.to_string(UI.QueryWidget(Id(:user), :Value))
×
320
      @pass = Convert.to_string(UI.QueryWidget(Id(:pass), :Value))
×
321
      @enabled = Convert.to_boolean(UI.QueryWidget(Id(:enabled), :Value))
×
322

323
      @no = Convert.to_string(UI.QueryWidget(Id(:no), :Value))
×
324

325
      nil
326
    end
327

328
    def ValidateNoProxyDomains(no_proxies)
1✔
329
      proxy_list = Builtins.splitstring(no_proxies, ",")
×
330
      validate = true
×
331
      hostname = ""
×
332
      netmask = ""
×
333

334
      Builtins.foreach(proxy_list) do |one_proxy|
×
335
        one_proxy = String.CutBlanks(one_proxy)
×
336
        # IP/netmask
337
        if !Builtins.findfirstof(one_proxy, "/").nil?
×
338
          tmp = Builtins.splitstring(one_proxy, "/")
×
339
          hostname = Ops.get(tmp, 0, "")
×
340
          netmask = Ops.get(tmp, 1, "")
×
341

342
          validate = false if !Netmask.Check(netmask)
×
343
        else
344
          hostname = one_proxy
×
345
          # .domain.name case
346
          hostname = Builtins.substring(hostname, 1) if Builtins.findfirstof(hostname, ".") == 0
×
347
        end
348
        Builtins.y2milestone("hostname %1, netmask %2", hostname, netmask)
×
349
        validate = false if !Address.Check(hostname)
×
350
      end
351

352
      validate
×
353
    end
354

355
    def UrlContainPassword(url)
1✔
356
      ret = URL.Parse(url)
×
357

358
      Ops.greater_than(Builtins.size(Ops.get_string(ret, "pass", "")), 0)
×
359
    end
360

361
    # If modified, ask for confirmation
362
    # @return true if abort is confirmed
363
    def ReallyAbortCond
1✔
364
      (!modified || installation?) || Popup.ReallyAbort(true)
×
365
    end
366

367
    # Proxy dialog
368
    # @param [Boolean] _standalone true if not run from another ycp client
369
    # @return dialog result
370
    def ProxyMainDialog(_standalone)
1✔
371
      @enabled = Proxy.enabled
×
372
      @http = Proxy.http
×
373
      @https = Proxy.https
×
374
      @ftp = Proxy.ftp
×
375
      @no = Proxy.no
×
376
      @user = Proxy.user
×
377
      @pass = Proxy.pass
×
378

379
      @http = @prefill if @http == ""
×
380
      @https = @prefill if @https == ""
×
381
      @ftp = @prefill if @ftp == ""
×
382

383
      # Proxy dialog caption
384
      caption = _("Proxy Configuration")
×
385

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

443
      display_info = UI.GetDisplayInfo
×
444
      textmode = Ops.get_boolean(display_info, "TextMode", false)
×
445

446
      s = textmode ? 0.2 : 0.5
×
447

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

528
      Wizard.SetContentsButtons(
×
529
        caption,
530
        contents,
531
        help,
532
        Label.BackButton,
533
        Label.NextButton
534
      )
535
      adjust_wizard_buttons unless installation?
×
536

537
      # #103841, relaxed. now avoiding only quotes
538
      # #337048 allow using space as well
539
      # was CAlnum() + ".:_-/\\"
540
      _ValidCharsUsername = Ops.add(
×
541
        Builtins.deletechars(String.CGraph, "'\""),
542
        " "
543
      )
544
      UI.ChangeWidget(Id(:http), :ValidChars, URL.ValidChars)
×
545
      UI.ChangeWidget(Id(:https), :ValidChars, URL.ValidChars)
×
546
      UI.ChangeWidget(Id(:ftp), :ValidChars, URL.ValidChars)
×
547
      # '/' character for subnets definition - #490661
548
      UI.ChangeWidget(
×
549
        Id(:no),
550
        :ValidChars,
551
        Ops.add(Hostname.ValidCharsDomain, " ,/")
552
      )
553
      UI.ChangeWidget(Id(:user), :ValidChars, _ValidCharsUsername)
×
554
      UI.ChangeWidget(Id(:frame1), :Enabled, @enabled)
×
555
      UI.ChangeWidget(Id(:frame2), :Enabled, @enabled)
×
556
      UI.ChangeWidget(Id("test_proxy"), :Enabled, @enabled) if !Mode.installation
×
557
      InitSameProxy()
×
558

559
      if @enabled == true
×
560
        UI.SetFocus(Id(:http))
×
561
      else
562
        UI.SetFocus(Id(:enabled))
×
563
      end
564

565
      ret = nil
×
566
      loop do
×
567
        ret = UI.UserInput
×
568
        QueryWidgets()
×
569

570
        # abort?
571
        case ret
×
572
        when :abort, :cancel, :back
573
          break if ReallyAbortCond()
×
574

575
          next
×
576
        when :enabled
577
          UI.ChangeWidget(Id(:frame1), :Enabled, @enabled)
×
578
          UI.ChangeWidget(Id(:frame2), :Enabled, @enabled)
×
579
          UI.ChangeWidget(Id("test_proxy"), :Enabled, @enabled)
×
580
          InitSameProxy()
×
581
          next
×
582
        when :same_proxy
583
          UI.ChangeWidget(Id(:https), :Value, @prefill)
×
584
          UI.ChangeWidget(Id(:ftp), :Value, @prefill)
×
585
          UI.ChangeWidget(Id(:https), :Enabled, !@same_proxy)
×
586
          UI.ChangeWidget(Id(:ftp), :Enabled, !@same_proxy)
×
587
          next
×
588
        # next
589
        when :next, "test_proxy"
590
          @http = "" if @http == @prefill
×
591
          @https = "" if @https == @prefill
×
592
          @ftp = "" if @ftp == @prefill
×
593

594
          break if @enabled == false
×
595

596
          if @http == "" && @https == "" && @ftp == ""
×
597
            # Popup error text - http, https and ftp proxy URLs are blank
598
            if !Popup.ContinueCancel(
×
599
              _(
600
                "Proxy is enabled, but no proxy URL has been specified.\nReally use these settings?"
601
              )
602
            )
603
              next
×
604
            end
605
          else
606
            password_inside = UrlContainPassword(@http) ||
×
607
              UrlContainPassword(@https) ||
608
              UrlContainPassword(@ftp)
609

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

703
          break if ret == :next
×
704

705
          TestProxySettings() if ret == "test_proxy"
×
706
        else
707
          Builtins.y2error("unexpected retcode: %1", ret)
×
708
          next
×
709
        end
710
      end
711

712
      if ret == :next
×
713
        if !modified
×
714
          Builtins.y2debug("not modified")
×
715
          return deep_copy(ret)
×
716
        end
717

718
        Proxy.enabled = @enabled
×
719
        if @enabled
×
720
          Proxy.http = @http
×
721
          Proxy.https = @https
×
722
          Proxy.ftp = @ftp
×
723
          Proxy.no = @no
×
724
          Proxy.user = @user
×
725
          Proxy.pass = @pass
×
726
        end
727

728
        Proxy.SetModified
×
729
      end
730

731
      deep_copy(ret)
×
732
    end
733

734
  private
1✔
735

736
    # Sets OK/Cancel wizard buttons
737
    def adjust_wizard_buttons
1✔
738
      Wizard.SetNextButton(:next, Label.OKButton)
×
739
      Wizard.SetAbortButton(:abort, Label.CancelButton)
×
740
      Wizard.HideBackButton
×
741
    end
742

743
    # Determines whether running in installation mode
744
    #
745
    # We do not use Stage.initial because of firstboot, which runs in 'installation' mode
746
    # but in 'firstboot' stage.
747
    #
748
    # @return [Boolean] Boolean if running in installation or update mode
749
    def installation?
1✔
750
      Mode.installation || Mode.update
×
751
    end
752
  end
753
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