Other: Fix force-update test after version bump

This commit is contained in:
James Houlahan
2022-10-12 17:17:22 +02:00
parent d330000c8d
commit 6ee71d238b
3 changed files with 13 additions and 11 deletions

View File

@ -34,11 +34,17 @@ func withBridge(
cookieJar http.CookieJar, cookieJar http.CookieJar,
fn func(*bridge.Bridge) error, fn func(*bridge.Bridge) error,
) error { ) error {
// Get the current bridge version.
version, err := semver.NewVersion(constants.Version)
if err != nil {
return fmt.Errorf("could not create version: %w", err)
}
// Create the underlying dialer used by the bridge. // Create the underlying dialer used by the bridge.
// It only connects to trusted servers and reports any untrusted servers it finds. // It only connects to trusted servers and reports any untrusted servers it finds.
pinningDialer := dialer.NewPinningTLSDialer( pinningDialer := dialer.NewPinningTLSDialer(
dialer.NewBasicTLSDialer(constants.APIHost), dialer.NewBasicTLSDialer(constants.APIHost),
dialer.NewTLSReporter(constants.APIHost, constants.AppVersion, identifier, dialer.TrustedAPIPins), dialer.NewTLSReporter(constants.APIHost, constants.AppVersion(version.Original()), identifier, dialer.TrustedAPIPins),
dialer.NewTLSPinChecker(dialer.TrustedAPIPins), dialer.NewTLSPinChecker(dialer.TrustedAPIPins),
) )
@ -57,12 +63,6 @@ func withBridge(
return fmt.Errorf("could not create updater: %w", err) return fmt.Errorf("could not create updater: %w", err)
} }
// Get the current bridge version.
version, err := semver.NewVersion(constants.Version)
if err != nil {
return fmt.Errorf("could not create version: %w", err)
}
// Create a new bridge. // Create a new bridge.
bridge, err := bridge.New( bridge, err := bridge.New(
// The app stuff. // The app stuff.

View File

@ -98,7 +98,7 @@ func New(
) (*Bridge, error) { ) (*Bridge, error) {
api := liteapi.New( api := liteapi.New(
liteapi.WithHostURL(apiURL), liteapi.WithHostURL(apiURL),
liteapi.WithAppVersion(constants.AppVersion), liteapi.WithAppVersion(constants.AppVersion(curVersion.Original())),
liteapi.WithCookieJar(cookieJar), liteapi.WithCookieJar(cookieJar),
liteapi.WithTransport(roundTripper), liteapi.WithTransport(roundTripper),
) )

View File

@ -45,9 +45,6 @@ var (
// Version of the build. // Version of the build.
Version = "2.4.1+git" Version = "2.4.1+git"
// AppVersion is the full rendered version of the app (to be used in request headers).
AppVersion = getAPIOS() + cases.Title(language.Und).String(ConfigName) + "_" + Version
// Revision is current hash of the build. // Revision is current hash of the build.
Revision = "" Revision = ""
@ -67,6 +64,11 @@ var (
Host = "127.0.0.1" Host = "127.0.0.1"
) )
// AppVersion returns the full rendered version of the app (to be used in request headers).
func AppVersion(version string) string {
return getAPIOS() + cases.Title(language.Und).String(ConfigName) + "_" + version
}
func getAPIOS() string { func getAPIOS() string {
switch runtime.GOOS { switch runtime.GOOS {
case "darwin": case "darwin":