Skip to content

Commit 8d335ca

Browse files
authored
Merge pull request #272 from okta/prepare_2_9_2
Release v2.9.2
2 parents 8b91031 + a49bc87 commit 8d335ca

8 files changed

Lines changed: 142 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Changelog
22
Running changelog of releases since `2.0.0-rc.4`
33

4+
## v2.9.2
5+
6+
### Updates
7+
- Adjustments were made the attributes on the `DeviceAccessPolicyRuleCondition` type.
8+
- Adding `GroupProfileMap` attribute to `GroupProfile` struct to support additional properties. See #268
9+
10+
411
## v2.9.1
512

613
### New Types / Models

okta/deviceAccessPolicyRuleCondition.go

Lines changed: 6 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

okta/groupProfile.go

Lines changed: 43 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

okta/okta.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

openapi/generator/createdFiles.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

openapi/generator/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@ function getImports(object) {
225225
imports.splice(imports.indexOf("fmt"), 1);
226226
}
227227

228+
if (object.model.modelName === "GroupProfile") {
229+
imports.push("encoding/json");
230+
}
231+
228232
return imports;
229233
}
230234

openapi/generator/templates/model.go.hbs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ type {{model.modelName}}Resource resource
3636
)}}
3737
type {{model.modelName}}Resource resource
3838

39+
{{/if}}
40+
{{#if (eq model.modelName "GroupProfile")}}
41+
type {{model.modelName}}Map map[string]interface{}
42+
3943
{{/if}}
4044
{{#if (eq model.modelName "ApplicationSettingsApplication")}}
4145
type {{model.modelName}} map[string]interface{}
@@ -44,6 +48,9 @@ type {{model.modelName}} string
4448
{{else}}
4549
type {{model.modelName}} struct {
4650
{{{buildModelProperties model}}}
51+
{{#if (eq model.modelName "GroupProfile")}}
52+
{{model.modelName}}Map
53+
{{/if}}
4754
}
4855
{{/if}}
4956
{{#if model.enum}}
@@ -72,3 +79,42 @@ func (a *{{model.modelName}}) Is{{model.tags.[0]}}Instance() bool {
7279
{{> model.defaultMethod operation=operation alias=alias modelName=../model.modelName}}
7380
{{/each}}
7481
{{/if}}
82+
83+
{{#if (eq model.modelName "GroupProfile")}}
84+
func (a *{{model.modelName}}) UnmarshalJSON(data []byte) error {
85+
if string(data) == "null" || string(data) == `""` {
86+
return nil
87+
}
88+
var profile map[string]interface{}
89+
err := json.Unmarshal(data, &profile)
90+
if err != nil {
91+
return err
92+
}
93+
a.Name, _ = profile["name"].(string)
94+
a.Description, _ = profile["description"].(string)
95+
delete(profile, "name")
96+
delete(profile, "description")
97+
a.{{model.modelName}}Map = profile
98+
return nil
99+
}
100+
101+
func (a {{model.modelName}}) MarshalJSON() ([]byte, error) {
102+
if len(a.{{model.modelName}}Map) == 0 {
103+
return json.Marshal(&struct {
104+
Name string `json:"name"`
105+
Description string `json:"description"`
106+
}{
107+
Name: a.Name,
108+
Description: a.Description,
109+
})
110+
}
111+
if a.Name != "" {
112+
a.{{model.modelName}}Map["name"] = a.Name
113+
}
114+
if a.Description != "" {
115+
a.{{model.modelName}}Map["description"] = a.Description
116+
}
117+
return json.Marshal(a.{{model.modelName}}Map)
118+
}
119+
120+
{{/if}}

tests/integration/group_test.go

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package integration
1818

1919
import (
2020
"context"
21+
"encoding/json"
2122
"net/http"
2223
"testing"
2324
"time"
@@ -29,7 +30,7 @@ import (
2930
"github.com/stretchr/testify/require"
3031
)
3132

32-
func Test_can_get_a_group(t *testing.T) {
33+
func TestCanGetAGroup(t *testing.T) {
3334
ctx, client, err := tests.NewClient(context.TODO())
3435
require.NoError(t, err)
3536
// Create a new group → POST /api/v1/groups
@@ -59,7 +60,7 @@ func Test_can_get_a_group(t *testing.T) {
5960
"Should have resulted in a 404 when finding a deleted group")
6061
}
6162

62-
func Test_can_list_groups(t *testing.T) {
63+
func TestCanListGroups(t *testing.T) {
6364
ctx, client, err := tests.NewClient(context.TODO())
6465
require.NoError(t, err)
6566
// Create a new group → POST /api/v1/groups
@@ -89,7 +90,7 @@ func Test_can_list_groups(t *testing.T) {
8990
require.NoError(t, err, "Should not error when deleting a group")
9091
}
9192

92-
func Test_can_search_for_a_group(t *testing.T) {
93+
func TestCanSearchForAGroup(t *testing.T) {
9394
ctx, client, err := tests.NewClient(context.TODO())
9495
require.NoError(t, err)
9596
// Create a new group → POST /api/v1/groups
@@ -121,7 +122,7 @@ func Test_can_search_for_a_group(t *testing.T) {
121122
require.NoError(t, err, "Should not error when deleting a group")
122123
}
123124

124-
func Test_can_update_a_group(t *testing.T) {
125+
func TestCanUpdateAGroup(t *testing.T) {
125126
ctx, client, err := tests.NewClient(context.TODO())
126127
require.NoError(t, err)
127128
// Create a new group → POST /api/v1/groups
@@ -153,7 +154,7 @@ func Test_can_update_a_group(t *testing.T) {
153154
require.NoError(t, err, "Should not error when deleting a group")
154155
}
155156

156-
func Test_group_user_operations(t *testing.T) {
157+
func TestGroupUserOperations(t *testing.T) {
157158
ctx, client, err := tests.NewClient(context.TODO())
158159
require.NoError(t, err)
159160
// Create a user with credentials → POST /api/v1/users?activate=false
@@ -218,7 +219,7 @@ func Test_group_user_operations(t *testing.T) {
218219
require.NoError(t, err, "Should not error when deleting a group")
219220
}
220221

221-
func Test_group_rule_operations(t *testing.T) {
222+
func TestGroupRuleOperations(t *testing.T) {
222223
t.Skip("does not work properly in test org")
223224
ctx, client, err := tests.NewClient(context.TODO(), okta.WithCache(false))
224225
// Create a user with credentials, activated by default → POST /api/v1/users?activate=true
@@ -364,3 +365,30 @@ func Test_group_rule_operations(t *testing.T) {
364365
_, err = client.Group.DeleteGroupRule(ctx, groupRule.Id, &query.Params{})
365366
require.NoError(t, err, "Should not error when deleting Rule")
366367
}
368+
369+
func TestGroupProfileSerialization(t *testing.T) {
370+
gp := okta.GroupProfile{
371+
Name: "test",
372+
Description: "tester",
373+
GroupProfileMap: okta.GroupProfileMap{
374+
"custom": "value",
375+
},
376+
}
377+
378+
gpExpected := okta.GroupProfile{
379+
Name: "test",
380+
Description: "tester",
381+
GroupProfileMap: okta.GroupProfileMap{
382+
"custom": "value",
383+
},
384+
}
385+
386+
b, err := json.Marshal(&gp)
387+
require.NoError(t, err)
388+
389+
var gpCopy okta.GroupProfile
390+
err = json.Unmarshal(b, &gpCopy)
391+
require.NoError(t, err)
392+
393+
assert.Equal(t, gpExpected, gpCopy, "expected marshal to unmarshal to produce exact copy of group profile")
394+
}

0 commit comments

Comments
 (0)