Skip to content

Commit

Permalink
Merge pull request #1006 from Justin-Holmes/jholmes/fix-app-bools
Browse files Browse the repository at this point in the history
Use pointers for boolean fields in Access Applications
  • Loading branch information
jacobbednarz committed Jul 26, 2022
2 parents 2e1008c + cd82560 commit 503c956
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 42 deletions.
3 changes: 3 additions & 0 deletions .changelog/1006.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
access_application: fix inability to set bool values to false
```
10 changes: 5 additions & 5 deletions access_application.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ type AccessApplication struct {
CreatedAt *time.Time `json:"created_at,omitempty"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`
SaasApplication *SaasApplication `json:"saas_app,omitempty"`
AutoRedirectToIdentity bool `json:"auto_redirect_to_identity,omitempty"`
SkipInterstitial bool `json:"skip_interstitial,omitempty"`
AppLauncherVisible bool `json:"app_launcher_visible,omitempty"`
EnableBindingCookie bool `json:"enable_binding_cookie,omitempty"`
AutoRedirectToIdentity *bool `json:"auto_redirect_to_identity,omitempty"`
SkipInterstitial *bool `json:"skip_interstitial,omitempty"`
AppLauncherVisible *bool `json:"app_launcher_visible,omitempty"`
EnableBindingCookie *bool `json:"enable_binding_cookie,omitempty"`
HttpOnlyCookieAttribute *bool `json:"http_only_cookie_attribute,omitempty"`
ServiceAuth401Redirect bool `json:"service_auth_401_redirect,omitempty"`
ServiceAuth401Redirect *bool `json:"service_auth_401_redirect,omitempty"`
}

type AccessApplicationGatewayRule struct {
Expand Down
60 changes: 30 additions & 30 deletions access_application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@ func TestAccessApplications(t *testing.T) {
Type: "self_hosted",
SessionDuration: "24h",
AllowedIdps: []string{"f174e90a-fafe-4643-bbbc-4a0ed4fc8415"},
AutoRedirectToIdentity: false,
EnableBindingCookie: false,
AppLauncherVisible: true,
ServiceAuth401Redirect: true,
AutoRedirectToIdentity: BoolPtr(false),
EnableBindingCookie: BoolPtr(false),
AppLauncherVisible: BoolPtr(true),
ServiceAuth401Redirect: BoolPtr(true),
CustomDenyMessage: "denied!",
CustomDenyURL: "https://www.example.com",
SameSiteCookieAttribute: "strict",
HttpOnlyCookieAttribute: BoolPtr(true),
LogoURL: "https://www.example.com/example.png",
SkipInterstitial: true,
SkipInterstitial: BoolPtr(true),
}}

mux.HandleFunc("/accounts/"+testAccountID+"/access/apps", handler)
Expand Down Expand Up @@ -144,14 +144,14 @@ func TestAccessApplication(t *testing.T) {
Type: "self_hosted",
SessionDuration: "24h",
AllowedIdps: []string{"f174e90a-fafe-4643-bbbc-4a0ed4fc8415"},
AutoRedirectToIdentity: false,
EnableBindingCookie: false,
AppLauncherVisible: true,
ServiceAuth401Redirect: true,
AutoRedirectToIdentity: BoolPtr(false),
EnableBindingCookie: BoolPtr(false),
AppLauncherVisible: BoolPtr(true),
ServiceAuth401Redirect: BoolPtr(true),
CustomDenyMessage: "denied!",
CustomDenyURL: "https://www.example.com",
LogoURL: "https://www.example.com/example.png",
SkipInterstitial: true,
SkipInterstitial: BoolPtr(true),
HttpOnlyCookieAttribute: BoolPtr(false),
}

Expand Down Expand Up @@ -216,14 +216,14 @@ func TestCreateAccessApplications(t *testing.T) {
SessionDuration: "24h",
AUD: "737646a56ab1df6ec9bddc7e5ca84eaf3b0768850f3ffb5d74f1534911fe3893",
AllowedIdps: []string{"f174e90a-fafe-4643-bbbc-4a0ed4fc8415"},
AutoRedirectToIdentity: false,
EnableBindingCookie: false,
AppLauncherVisible: true,
ServiceAuth401Redirect: true,
AutoRedirectToIdentity: BoolPtr(false),
EnableBindingCookie: BoolPtr(false),
AppLauncherVisible: BoolPtr(true),
ServiceAuth401Redirect: BoolPtr(true),
CustomDenyMessage: "denied!",
CustomDenyURL: "https://www.example.com",
LogoURL: "https://www.example.com/example.png",
SkipInterstitial: true,
SkipInterstitial: BoolPtr(true),
CreatedAt: &createdAt,
UpdatedAt: &updatedAt,
}
Expand Down Expand Up @@ -297,14 +297,14 @@ func TestUpdateAccessApplication(t *testing.T) {
SessionDuration: "24h",
AUD: "737646a56ab1df6ec9bddc7e5ca84eaf3b0768850f3ffb5d74f1534911fe3893",
AllowedIdps: []string{"f174e90a-fafe-4643-bbbc-4a0ed4fc8415"},
AutoRedirectToIdentity: false,
EnableBindingCookie: false,
AppLauncherVisible: true,
ServiceAuth401Redirect: true,
AutoRedirectToIdentity: BoolPtr(false),
EnableBindingCookie: BoolPtr(false),
AppLauncherVisible: BoolPtr(true),
ServiceAuth401Redirect: BoolPtr(true),
CustomDenyMessage: "denied!",
CustomDenyURL: "https://www.example.com",
LogoURL: "https://www.example.com/example.png",
SkipInterstitial: true,
SkipInterstitial: BoolPtr(true),
CreatedAt: &createdAt,
UpdatedAt: &updatedAt,
}
Expand Down Expand Up @@ -518,14 +518,14 @@ func TestCreatePrivateAccessApplication(t *testing.T) {
SessionDuration: "24h",
AUD: "737646a56ab1df6ec9bddc7e5ca84eaf3b0768850f3ffb5d74f1534911fe3893",
AllowedIdps: []string{"f174e90a-fafe-4643-bbbc-4a0ed4fc8415"},
AutoRedirectToIdentity: false,
EnableBindingCookie: false,
AppLauncherVisible: false,
ServiceAuth401Redirect: false,
AutoRedirectToIdentity: BoolPtr(false),
EnableBindingCookie: BoolPtr(false),
AppLauncherVisible: BoolPtr(false),
ServiceAuth401Redirect: BoolPtr(false),
CustomDenyMessage: "denied!",
CustomDenyURL: "https://www.example.com",
LogoURL: "https://www.example.com/example.png",
SkipInterstitial: true,
SkipInterstitial: BoolPtr(true),
CreatedAt: &createdAt,
UpdatedAt: &updatedAt,
}
Expand Down Expand Up @@ -616,14 +616,14 @@ func TestCreateSaasAccessApplications(t *testing.T) {
SessionDuration: "24h",
AUD: "737646a56ab1df6ec9bddc7e5ca84eaf3b0768850f3ffb5d74f1534911fe3893",
AllowedIdps: []string{},
AutoRedirectToIdentity: false,
EnableBindingCookie: false,
AppLauncherVisible: true,
ServiceAuth401Redirect: true,
AutoRedirectToIdentity: BoolPtr(false),
EnableBindingCookie: BoolPtr(false),
AppLauncherVisible: BoolPtr(true),
ServiceAuth401Redirect: BoolPtr(true),
CustomDenyMessage: "denied!",
CustomDenyURL: "https://www.example.com",
LogoURL: "https://www.example.com/example.png",
SkipInterstitial: true,
SkipInterstitial: BoolPtr(true),
SaasApplication: &SaasApplication{
ConsumerServiceUrl: "https://saas.example.com",
SPEntityID: "dash.example.com",
Expand Down
2 changes: 1 addition & 1 deletion access_bookmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type AccessBookmark struct {
Domain string `json:"domain"`
Name string `json:"name"`
LogoURL string `json:"logo_url,omitempty"`
AppLauncherVisible bool `json:"app_launcher_visible,omitempty"`
AppLauncherVisible *bool `json:"app_launcher_visible,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`
}
Expand Down
12 changes: 6 additions & 6 deletions access_bookmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestAccessBookmarks(t *testing.T) {
Name: "Example Site",
Domain: "example.com",
LogoURL: "https://www.example.com/example.png",
AppLauncherVisible: true,
AppLauncherVisible: BoolPtr(true),
CreatedAt: &createdAt,
UpdatedAt: &updatedAt,
}}
Expand Down Expand Up @@ -104,7 +104,7 @@ func TestAccessBookmark(t *testing.T) {
Name: "Example Site",
Domain: "example.com",
LogoURL: "https://www.example.com/example.png",
AppLauncherVisible: true,
AppLauncherVisible: BoolPtr(true),
CreatedAt: &createdAt,
UpdatedAt: &updatedAt,
}
Expand Down Expand Up @@ -157,7 +157,7 @@ func TestCreateAccessBookmarks(t *testing.T) {
Name: "Example Site",
Domain: "example.com",
LogoURL: "https://www.example.com/example.png",
AppLauncherVisible: true,
AppLauncherVisible: BoolPtr(true),
CreatedAt: &createdAt,
UpdatedAt: &updatedAt,
}
Expand All @@ -168,7 +168,7 @@ func TestCreateAccessBookmarks(t *testing.T) {
Name: "Example Site",
Domain: "example.com",
LogoURL: "https://www.example.com/example.png",
AppLauncherVisible: true,
AppLauncherVisible: BoolPtr(true),
})

if assert.NoError(t, err) {
Expand All @@ -181,7 +181,7 @@ func TestCreateAccessBookmarks(t *testing.T) {
Name: "Example Site",
Domain: "example.com",
LogoURL: "https://www.example.com/example.png",
AppLauncherVisible: true,
AppLauncherVisible: BoolPtr(true),
})

if assert.NoError(t, err) {
Expand Down Expand Up @@ -220,7 +220,7 @@ func TestUpdateAccessBookmark(t *testing.T) {
Name: "Example Site",
Domain: "example.com",
LogoURL: "https://www.example.com/example.png",
AppLauncherVisible: true,
AppLauncherVisible: BoolPtr(true),
CreatedAt: &createdAt,
UpdatedAt: &updatedAt,
}
Expand Down

0 comments on commit 503c956

Please sign in to comment.