(t *testing.T)
| 33 | } |
| 34 | |
| 35 | func TestCheckInvalidOptions(t *testing.T) { |
| 36 | cfg := ini.Empty() |
| 37 | _, _ = cfg.Section("mailer").NewKey("ENABLED", "true") |
| 38 | _, _ = cfg.Section("service").NewKey("START_TYPE", "true") |
| 39 | _, _ = cfg.Section("security").NewKey("REVERSE_PROXY_AUTHENTICATION_USER", "true") |
| 40 | _, _ = cfg.Section("auth").NewKey("ACTIVE_CODE_LIVE_MINUTES", "10") |
| 41 | _, _ = cfg.Section("auth").NewKey("RESET_PASSWD_CODE_LIVE_MINUTES", "10") |
| 42 | _, _ = cfg.Section("auth").NewKey("ENABLE_CAPTCHA", "true") |
| 43 | _, _ = cfg.Section("auth").NewKey("ENABLE_NOTIFY_MAIL", "true") |
| 44 | _, _ = cfg.Section("auth").NewKey("REGISTER_EMAIL_CONFIRM", "true") |
| 45 | _, _ = cfg.Section("session").NewKey("GC_INTERVAL_TIME", "10") |
| 46 | _, _ = cfg.Section("session").NewKey("SESSION_LIFE_TIME", "10") |
| 47 | _, _ = cfg.Section("server").NewKey("ROOT_URL", "true") |
| 48 | _, _ = cfg.Section("server").NewKey("LANDING_PAGE", "true") |
| 49 | _, _ = cfg.Section("database").NewKey("DB_TYPE", "true") |
| 50 | _, _ = cfg.Section("database").NewKey("PASSWD", "true") |
| 51 | _, _ = cfg.Section("other").NewKey("SHOW_FOOTER_BRANDING", "true") |
| 52 | _, _ = cfg.Section("other").NewKey("SHOW_FOOTER_TEMPLATE_LOAD_TIME", "true") |
| 53 | _, _ = cfg.Section("email").NewKey("ENABLED", "true") |
| 54 | _, _ = cfg.Section("server").NewKey("NONEXISTENT_OPTION", "true") |
| 55 | |
| 56 | wantWarnings := []string{ |
| 57 | "option [auth] ACTIVE_CODE_LIVE_MINUTES is invalid, use [auth] ACTIVATE_CODE_LIVES instead", |
| 58 | "option [auth] ENABLE_CAPTCHA is invalid, use [auth] ENABLE_REGISTRATION_CAPTCHA instead", |
| 59 | "option [auth] ENABLE_NOTIFY_MAIL is invalid, use [user] ENABLE_EMAIL_NOTIFICATION instead", |
| 60 | "option [auth] REGISTER_EMAIL_CONFIRM is invalid, use [auth] REQUIRE_EMAIL_CONFIRMATION instead", |
| 61 | "option [auth] RESET_PASSWD_CODE_LIVE_MINUTES is invalid, use [auth] RESET_PASSWORD_CODE_LIVES instead", |
| 62 | "option [database] DB_TYPE is invalid, use [database] TYPE instead", |
| 63 | "option [database] PASSWD is invalid, use [database] PASSWORD instead", |
| 64 | "option [security] REVERSE_PROXY_AUTHENTICATION_USER is invalid, use [auth] REVERSE_PROXY_AUTHENTICATION_HEADER instead", |
| 65 | "option [session] GC_INTERVAL_TIME is invalid, use [session] GC_INTERVAL instead", |
| 66 | "option [session] SESSION_LIFE_TIME is invalid, use [session] MAX_LIFE_TIME instead", |
| 67 | "section [mailer] is invalid, use [email] instead", |
| 68 | "section [service] is invalid, use [auth] instead", |
| 69 | "option [server] ROOT_URL is invalid, use [server] EXTERNAL_URL instead", |
| 70 | "option [server] LANDING_PAGE is invalid, use [server] LANDING_URL instead", |
| 71 | "option [server] NONEXISTENT_OPTION is invalid", |
| 72 | } |
| 73 | |
| 74 | gotWarnings := checkInvalidOptions(cfg) |
| 75 | sort.Strings(wantWarnings) |
| 76 | sort.Strings(gotWarnings) |
| 77 | assert.Equal(t, wantWarnings, gotWarnings) |
| 78 | } |
nothing calls this directly
no test coverage detected