Skip to content

Commit 9083209

Browse files
Merge pull request #427 from okta/prep-release-v4
prep release v4
2 parents d58f63b + 662d39e commit 9083209

15 files changed

+21392
-6217
lines changed

.circleci/config.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,16 @@ jobs:
2020
name: "test stage"
2121
command: make test
2222

23-
test-v3:
23+
test-v4:
2424
docker:
2525
- image: cimg/go:1.19.4
2626
steps:
2727
- checkout
2828
- run: go version
29+
- platform-orb/step-load-dependencies
2930
- run:
3031
name: "test stage"
31-
command: |
32-
cd okta/v3
33-
go mod download
34-
go test -failfast -race ./ -test.v
32+
command: make v4-test
3533

3634
# Invoke jobs via workflows
3735
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
@@ -44,7 +42,7 @@ workflows:
4442
- test-v2:
4543
requires:
4644
- cache-secrets
47-
# - test-v3:
45+
# - test-v4:
4846
# requires:
4947
# - cache-secrets
5048
# See OKTA-624790

.generator/config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
generatorName: go
22
templateDir: ./.generator/templates
3-
outputDir: ./okta/v3
3+
outputDir: ./okta/v4
44
gitUserId: okta
55
gitRepoId: okta-sdk-golang
6-
versionName: v3
6+
versionName: v4
77
additionalProperties:
88
enumClassPrefix: true
99
generateInterfaces: true
1010
packageName: okta
11-
packageVersion: 3.0.19
11+
packageVersion: 4.0.0
1212
useOneOfDiscriminatorLookup: true
1313
disallowAdditionalPropertiesIfNotPresent: false
1414
files:

.generator/okta-management-APIs-oasv3-enum-inheritance.yaml

Lines changed: 2318 additions & 128 deletions
Large diffs are not rendered by default.

.generator/okta-management-APIs-oasv3-noEnums-inheritance.yaml

Lines changed: 19019 additions & 6005 deletions
Large diffs are not rendered by default.

.generator/templates/api_application_test.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,15 @@ func Test_Activate_Application(t *testing.T) {
106106
app, _, err := apiClient.ApplicationAPI.GetApplication(apiClient.cfg.Context, createdApp.BasicAuthApplication.GetId()).Execute()
107107
require.NoError(t, err, "Could not get app by ID")
108108
assert.Equal(t, createdApp.BasicAuthApplication.GetId(), app.BasicAuthApplication.GetId())
109-
assert.Equal(t, APPLICATIONLIFECYCLESTATUS_INACTIVE, app.BasicAuthApplication.GetStatus())
109+
assert.Equal(t, "INACTIVE", app.BasicAuthApplication.GetStatus())
110110
})
111111
t.Run("activate applications", func(t *testing.T) {
112112
_, err = apiClient.ApplicationAPI.ActivateApplication(apiClient.cfg.Context, createdApp.BasicAuthApplication.GetId()).Execute()
113113
require.NoError(t, err, "Could not activate the app")
114114
newapp, _, err := apiClient.ApplicationAPI.GetApplication(apiClient.cfg.Context, createdApp.BasicAuthApplication.GetId()).Execute()
115115
require.NoError(t, err, "Could not get app by ID")
116116
assert.Equal(t, createdApp.BasicAuthApplication.GetId(), newapp.BasicAuthApplication.GetId())
117-
assert.Equal(t, APPLICATIONLIFECYCLESTATUS_ACTIVE, newapp.BasicAuthApplication.GetStatus())
117+
assert.Equal(t, "ACTIVE", newapp.BasicAuthApplication.GetStatus())
118118
})
119119
err = cleanUpApplication(createdApp.BasicAuthApplication.GetId())
120120
require.NoError(t, err, "Clean up app should not error")
@@ -279,17 +279,18 @@ func TestGetDefaultProvisioningConnectionForApplication(t *testing.T) {
279279
t.Run("get provisioning", func(t *testing.T) {
280280
conn, _, err := apiClient.ApplicationConnectionsAPI.GetDefaultProvisioningConnectionForApplication(apiClient.cfg.Context, createdApp.SamlApplication.GetId()).Execute()
281281
require.NoError(t, err, "getting default provisioning connection for application should not error.")
282-
assert.NotEmpty(t, conn.GetAuthScheme())
283-
assert.NotEmpty(t, conn.GetStatus())
282+
assert.NotEmpty(t, conn.ProvisioningConnectionToken.GetAuthScheme())
283+
assert.NotEmpty(t, conn.ProvisioningConnectionToken.GetStatus())
284284
})
285285
t.Run("set provisioning", func(t *testing.T) {
286-
profile := ProvisioningConnectionProfile{}
286+
profile := ProvisioningConnectionProfileToken{}
287287
profile.SetAuthScheme("TOKEN")
288288
profile.SetToken("TEST")
289-
payload := ProvisioningConnectionRequest{Profile: profile}
290-
conn, _, err := apiClient.ApplicationConnectionsAPI.UpdateDefaultProvisioningConnectionForApplication(apiClient.cfg.Context, createdApp.SamlApplication.GetId()).ProvisioningConnectionRequest(payload).Activate(false).Execute()
289+
request := NewProvisioningConnectionTokenRequest(profile)
290+
payload := UpdateDefaultProvisioningConnectionForApplicationRequest{ProvisioningConnectionTokenRequest: request}
291+
conn, _, err := apiClient.ApplicationConnectionsAPI.UpdateDefaultProvisioningConnectionForApplication(apiClient.cfg.Context, createdApp.SamlApplication.GetId()).UpdateDefaultProvisioningConnectionForApplicationRequest(payload).Activate(false).Execute()
291292
require.NoError(t, err, "setting default provisioning connection for application should not error.")
292-
assert.Equal(t, PROVISIONINGCONNECTIONAUTHSCHEME_TOKEN, conn.GetAuthScheme())
293+
assert.Equal(t, "TOKEN", conn.GetAuthScheme())
293294
})
294295
err = cleanUpApplication(createdApp.SamlApplication.GetId())
295296
require.NoError(t, err, "Clean up app should not error")

.generator/templates/api_idp_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,16 @@ func Test_Get_Identity_Provider(t *testing.T) {
5050
func Test_Activate_Identity_Provider(t *testing.T) {
5151
createdIdp, _, err := setupIdp(randomTestString())
5252
require.NoError(t, err, "Creating a new idp should not error")
53-
assert.Equal(t, LIFECYCLESTATUS_ACTIVE, createdIdp.GetStatus())
53+
assert.Equal(t, "ACTIVE", createdIdp.GetStatus())
5454
t.Run("deactivate idp", func(t *testing.T) {
5555
didp, _, err := apiClient.IdentityProviderAPI.DeactivateIdentityProvider(apiClient.cfg.Context, createdIdp.GetId()).Execute()
5656
require.NoError(t, err, "Could not deactivate idp")
57-
assert.Equal(t, LIFECYCLESTATUS_INACTIVE, didp.GetStatus())
57+
assert.Equal(t, "INACTIVE", didp.GetStatus())
5858
})
5959
t.Run("activate idp", func(t *testing.T) {
6060
aidp, _, err := apiClient.IdentityProviderAPI.ActivateIdentityProvider(apiClient.cfg.Context, createdIdp.GetId()).Execute()
6161
require.NoError(t, err, "Could not activate idp")
62-
assert.Equal(t, LIFECYCLESTATUS_ACTIVE, aidp.GetStatus())
62+
assert.Equal(t, "ACTIVE", aidp.GetStatus())
6363
})
6464
err = cleanUpIdp(createdIdp.GetId())
6565
require.NoError(t, err, "Clean up idp should not error")

.generator/templates/api_policy_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,15 @@ func Test_Activate_Policy(t *testing.T) {
9898
policy, _, err := apiClient.PolicyAPI.GetPolicy(apiClient.cfg.Context, createdPolicy.AccessPolicy.GetId()).Execute()
9999
require.NoError(t, err, "Could not get policy by ID")
100100
assert.Equal(t, createdPolicy.AccessPolicy.GetId(), policy.AccessPolicy.GetId())
101-
assert.Equal(t, LIFECYCLESTATUS_INACTIVE, policy.AccessPolicy.GetStatus())
101+
assert.Equal(t, "INACTIVE", policy.AccessPolicy.GetStatus())
102102
})
103103
t.Run("activate policy", func(t *testing.T) {
104104
_, err = apiClient.PolicyAPI.ActivatePolicy(apiClient.cfg.Context, createdPolicy.AccessPolicy.GetId()).Execute()
105105
require.NoError(t, err, "Could not activate the policy")
106106
policy, _, err := apiClient.PolicyAPI.GetPolicy(apiClient.cfg.Context, createdPolicy.AccessPolicy.GetId()).Execute()
107107
require.NoError(t, err, "Could not get policy by ID")
108108
assert.Equal(t, createdPolicy.AccessPolicy.GetId(), policy.AccessPolicy.GetId())
109-
assert.Equal(t, LIFECYCLESTATUS_ACTIVE, policy.AccessPolicy.GetStatus())
109+
assert.Equal(t, "ACTIVE", policy.AccessPolicy.GetStatus())
110110
})
111111
err = cleanUpPolicy(createdPolicy.AccessPolicy.GetId())
112112
require.NoError(t, err, "Clean up policy should not error")
@@ -115,6 +115,7 @@ func Test_Activate_Policy(t *testing.T) {
115115
// ACCESS/AUTHENTICATION POLICY ONLY
116116
// TODO Used to work, now fail with 401
117117
func Test_Clone_Policy(t *testing.T) {
118+
t.Skip("Will failed due to change in API authz")
118119
createdPolicy, _, err := setupAccessPolicy(randomTestString())
119120
require.NoError(t, err, "Creating a new policy should not error")
120121
var policyID string
@@ -141,7 +142,7 @@ func Test_Policy_Rules_Operation(t *testing.T) {
141142
configuration.Debug = true
142143
proxyClient := NewAPIClient(configuration)
143144
accessPolicyRule := &AccessPolicyRule{}
144-
accessPolicyRule.SetType(POLICYRULETYPE_ACCESS_POLICY)
145+
accessPolicyRule.SetType("ACCESS_POLICY")
145146
name := randomTestString()
146147
accessPolicyRule.SetName(name)
147148
payload := ListPolicyRules200ResponseInner{AccessPolicyRule: accessPolicyRule}
@@ -176,15 +177,15 @@ func Test_Policy_Rules_Operation(t *testing.T) {
176177
require.NoError(t, err, "Could not deactivate policy rule")
177178
rpolicyRule, _, err := apiClient.PolicyAPI.GetPolicyRule(apiClient.cfg.Context, createdPolicy.AccessPolicy.GetId(), createdPolicyRule.AccessPolicyRule.GetId()).Execute()
178179
require.NoError(t, err, "Could not get policy rule by ID")
179-
assert.Equal(t, LIFECYCLESTATUS_INACTIVE, rpolicyRule.AccessPolicyRule.GetStatus())
180+
assert.Equal(t, "INACTIVE", rpolicyRule.AccessPolicyRule.GetStatus())
180181
})
181182

182183
t.Run("activate policy rule", func(t *testing.T) {
183184
_, err = apiClient.PolicyAPI.ActivatePolicyRule(apiClient.cfg.Context, createdPolicy.AccessPolicy.GetId(), createdPolicyRule.AccessPolicyRule.GetId()).Execute()
184185
require.NoError(t, err, "Could not activate policy rule")
185186
rpolicyRule, _, err := apiClient.PolicyAPI.GetPolicyRule(apiClient.cfg.Context, createdPolicy.AccessPolicy.GetId(), createdPolicyRule.AccessPolicyRule.GetId()).Execute()
186187
require.NoError(t, err, "Could not get policy rule by ID")
187-
assert.Equal(t, LIFECYCLESTATUS_ACTIVE, rpolicyRule.AccessPolicyRule.GetStatus())
188+
assert.Equal(t, "ACTIVE", rpolicyRule.AccessPolicyRule.GetStatus())
188189
})
189190
err = cleanUpPolicyRule(createdPolicy.AccessPolicy.GetId(), createdPolicyRule.AccessPolicyRule.GetId())
190191
require.NoError(t, err, "Clean up policy rule should not error")

.generator/templates/api_user_schema_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func Test_Get_User_Schema(t *testing.T) {
1414
assert.NotEmpty(t, schema, "User schema is empty")
1515
assert.Equal(t, "Username", schema.Definitions.Base.Properties.Login.GetTitle())
1616
assert.Equal(t, "READ_WRITE", schema.Definitions.Base.Properties.Login.GetMutability())
17-
assert.Equal(t, USERSCHEMAATTRIBUTESCOPE_NONE, schema.Definitions.Base.Properties.Login.GetScope())
17+
assert.Equal(t, "NONE", schema.Definitions.Base.Properties.Login.GetScope())
1818
assert.Equal(t, int32(5), schema.Definitions.Base.Properties.Login.GetMinLength())
1919
assert.Equal(t, int32(100), schema.Definitions.Base.Properties.Login.GetMaxLength())
2020
assert.NotEmpty(t, schema.Definitions.Base.Properties.Login.GetPermissions())
@@ -31,7 +31,7 @@ func Test_Update_Property_To_User_Schema(t *testing.T) {
3131
customAttributeName := testPrefix + randomTestString()
3232
customAttributeDetail := UserSchemaAttribute{}
3333
customAttributeDetail.SetTitle(customAttributeName)
34-
customAttributeDetail.SetType(USERSCHEMAATTRIBUTETYPE_STRING)
34+
customAttributeDetail.SetType("string")
3535
customAttributeDetail.SetMinLength(1)
3636
customAttributeDetail.SetMaxLength(20)
3737
customAttribute := make(map[string]UserSchemaAttribute)

.generator/templates/api_user_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func Test_Update_User_Profile(t *testing.T) {
8080
nickName := "Batman"
8181
t.Run("update user", func(t *testing.T) {
8282
newProfile := user.Profile
83-
newProfile.NickName = &nickName
83+
newProfile.NickName = NullableString{value: &nickName, isSet: true}
8484
req := apiClient.UserAPI.UpdateUser(apiClient.cfg.Context, user.GetId())
8585
body := UpdateUserRequest{Profile: newProfile}
8686
req = req.User(body)
@@ -90,7 +90,7 @@ func Test_Update_User_Profile(t *testing.T) {
9090
t.Run("get user", func(t *testing.T) {
9191
updatedUser, _, err := apiClient.UserAPI.GetUser(apiClient.cfg.Context, user.GetId()).Execute()
9292
require.NoError(t, err, "Could not get user by ID")
93-
assert.Equal(t, nickName, *updatedUser.Profile.NickName)
93+
assert.Equal(t, nickName, updatedUser.Profile.GetNickName())
9494
})
9595
err = cleanUpUser(user.GetId())
9696
require.NoError(t, err, "Clean up user should not error")
@@ -224,7 +224,7 @@ func Test_Assign_User_To_A_Role(t *testing.T) {
224224
user, _, _, err := setupUser(true)
225225
require.NoError(t, err, "Creating a new user should not error")
226226
var roleId string
227-
role := ROLETYPE_USER_ADMIN
227+
role := "USER_ADMIN"
228228
t.Run("add role to user", func(t *testing.T) {
229229
req := apiClient.RoleAssignmentAPI.AssignRoleToUser(apiClient.cfg.Context, user.GetId())
230230
payload := AssignRoleRequest{
@@ -348,9 +348,9 @@ func Test_List_User_Subscriptions(t *testing.T) {
348348
assert.True(t, len(subscriptions) > 0, "User should have subscriptions")
349349
})
350350
t.Run("get user subscription by notification type", func(t *testing.T) {
351-
subscription, _, err := apiClient.SubscriptionAPI.GetSubscriptionsNotificationTypeUser(apiClient.cfg.Context, NOTIFICATIONTYPE_OKTA_ANNOUNCEMENT, user.GetId()).Execute()
351+
subscription, _, err := apiClient.SubscriptionAPI.GetSubscriptionsNotificationTypeUser(apiClient.cfg.Context, "OKTA_ANNOUNCEMENT", user.GetId()).Execute()
352352
require.NoError(t, err, "Should not error getting user subscription by notification types")
353-
assert.Equal(t, subscription.GetNotificationType(), NOTIFICATIONTYPE_OKTA_ANNOUNCEMENT, "User should have subscription notification type %q, got %q", NOTIFICATIONTYPE_OKTA_ANNOUNCEMENT, subscription.NotificationType)
353+
assert.Equal(t, subscription.GetNotificationType(), "OKTA_ANNOUNCEMENT", "User should have subscription notification type %q, got %q", "OKTA_ANNOUNCEMENT", subscription.NotificationType)
354354
})
355355
}
356356

.generator/templates/test_helpers.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func (t *TestFactory) NewValidTestRecoveryQuestionCredential() *RecoveryQuestion
9696

9797
func (t *TestFactory) NewValidTestIdentityProvider() *IdentityProvider {
9898
res := IdentityProvider{}
99-
res.SetType(IDENTITYPROVIDERTYPE_OIDC)
99+
res.SetType("OIDC")
100100
res.SetName(randomTestString())
101101
res.SetProtocol(*t.NewValidTestProtocol())
102102
res.SetPolicy(*t.NewValidTestIdentityProviderPolicy())
@@ -245,7 +245,7 @@ func (t *TestFactory) NewValidTestCSRMetadata() *CsrMetadata {
245245
func (t *TestFactory) NewValidAccessPolicy(name string) *AccessPolicy {
246246
policyRule := NewPolicyRuleConditions()
247247
res := AccessPolicy{}
248-
res.SetType(POLICYTYPE_ACCESS_POLICY)
248+
res.SetType("ACCESS_POLICY")
249249
res.SetDescription(randomTestString())
250250
res.SetPriority(int32(1))
251251
res.SetConditions(*policyRule)
@@ -262,7 +262,7 @@ func (t *TestFactory) NewValidBasicAuthApplication(label string) *BasicAuthAppli
262262
res := BasicAuthApplication{}
263263
res.SetSettings(*setting)
264264
res.SetName("template_basic_auth")
265-
res.SetSignOnMode(APPLICATIONSIGNONMODE_BASIC_AUTH)
265+
res.SetSignOnMode("BASIC_AUTH")
266266
res.SetLabel(label)
267267
return &res
268268
}
@@ -276,7 +276,7 @@ func (t *TestFactory) NewValidBookmarkApplication(label string) *BookmarkApplica
276276
res := BookmarkApplication{}
277277
res.SetSettings(*setting)
278278
res.SetName("bookmark")
279-
res.SetSignOnMode(APPLICATIONSIGNONMODE_BOOKMARK)
279+
res.SetSignOnMode("BOOKMARK")
280280
res.SetLabel(label)
281281
return &res
282282
}
@@ -291,7 +291,7 @@ func (t *TestFactory) NewValidOrg2OrgApplication(label string) *SamlApplication
291291
res := SamlApplication{}
292292
res.SetSettings(*setting)
293293
res.SetName("okta_org2org")
294-
res.SetSignOnMode(APPLICATIONSIGNONMODE_SAML_2_0)
294+
res.SetSignOnMode("SAML_2_0")
295295
res.SetLabel(label)
296296
return &res
297297
}
@@ -300,17 +300,17 @@ func (t *TestFactory) NewValidOIDCApplication(label string) *OpenIdConnectApplic
300300
settingClient := NewOpenIdConnectApplicationSettingsClient()
301301
settingClient.SetClientUri("https://example.com/client")
302302
settingClient.SetLogoUri("https://example.com/assets/images/logo-new.png")
303-
settingClient.SetResponseTypes([]OAuthResponseType{OAUTHRESPONSETYPE_TOKEN, OAUTHRESPONSETYPE_ID_TOKEN, OAUTHRESPONSETYPE_CODE})
303+
settingClient.SetResponseTypes([]string{"token", "id_token", "code"})
304304
settingClient.SetRedirectUris([]string{"https://example.com/oauth2/callback", "myapp://callback"})
305305
settingClient.SetPostLogoutRedirectUris([]string{"https://example.com/postlogout", "myapp://postlogoutcallback"})
306-
settingClient.SetGrantTypes([]OAuthGrantType{OAUTHGRANTTYPE_IMPLICIT, OAUTHGRANTTYPE_AUTHORIZATION_CODE})
307-
settingClient.SetApplicationType(OPENIDCONNECTAPPLICATIONTYPE_NATIVE)
306+
settingClient.SetGrantTypes([]string{"implicit", "authorization_code"})
307+
settingClient.SetApplicationType("native")
308308
settingClient.SetTosUri("https://example.com/client/tos")
309309
settingClient.SetPolicyUri("https://example.com/client/policy")
310310
setting := NewOpenIdConnectApplicationSettings()
311311
setting.SetOauthClient(*settingClient)
312312
credClient := NewApplicationCredentialsOAuthClient()
313-
credClient.SetTokenEndpointAuthMethod(OAUTHENDPOINTAUTHENTICATIONMETHOD_CLIENT_SECRET_POST)
313+
credClient.SetTokenEndpointAuthMethod("client_secret_post")
314314
credClient.SetClientId(randomTestString())
315315
credClient.SetAutoKeyRotation(true)
316316
credentials := NewOAuthApplicationCredentials()
@@ -319,7 +319,7 @@ func (t *TestFactory) NewValidOIDCApplication(label string) *OpenIdConnectApplic
319319
res.SetSettings(*setting)
320320
res.SetCredentials(*credentials)
321321
res.SetName("oidc_client")
322-
res.SetSignOnMode(APPLICATIONSIGNONMODE_OPENID_CONNECT)
322+
res.SetSignOnMode("OPENID_CONNECT")
323323
res.SetLabel(label)
324324
return &res
325325
}

0 commit comments

Comments
 (0)