diff --git a/README.md b/README.md index a69cb43ecb..91d2176533 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ $foundUser = $user->get('email@example.com'); dump($foundUser); ``` -### Craeating a User +### Creating a User ```php $user = new \Okta\Users\User(); $profile = new \Okta\Users\Profile(); diff --git a/composer.json b/composer.json index 7346e794c0..afbd41fbb5 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ }, "autoload": { "psr-4": { - "Okta\\": "src/" + "Okta\\": "src" } }, "scripts": { @@ -44,11 +44,7 @@ "@fix-code" ], "delete-resources": [ - "rm -rf ./src/Apps", - "rm -rf ./src/Groups", - "rm -rf ./src/GroupRules", - "rm -rf ./src/Shared", - "rm -rf ./src/Users" + "rm -rf ./src/Generated" ], "generate-resources": "cd ./openapi && npm run generator", "fix-code": "phpcbf ." diff --git a/openapi/generator/index.js b/openapi/generator/index.js index c75ec2d0c1..86b9a09a5c 100644 --- a/openapi/generator/index.js +++ b/openapi/generator/index.js @@ -1,14 +1,64 @@ const _ = require('lodash'); _.mixin(require('lodash-inflection')); +const fs = require('fs'); const php = module.exports; -function getType(obj) { +function getType(obj, model) { switch (obj.commonType) { case 'dateTime': return String.raw`\Carbon\Carbon|null`; case 'object': - return obj.model; + switch (obj.model) { + case 'CallFactorProfile': + case 'EmailFactorProfile': + case 'HardwareFactorProfile': + case 'PushFactorProfile': + case 'SecurityQuestionFactorProfile': + case 'SmsFactorProfile': + case 'TokenFactorProfile': + case 'TotpFactorProfile': + case 'WebFactorProfile': + case 'FactorProfile': + return '\\Okta\\UserFactors\\FactorProfile'; + case 'AutoLoginApplicationSettings': + case 'BasicAuthApplicationSettings': + case 'BasicApplicationSettings': + case 'BookmarkApplicationSettings': + case 'BrowserPluginApplicationSettings': + case 'OpenIdConnectApplicationSettings': + case 'SamlApplicationSettings': + case 'SecurePasswordStoreApplicationSettings': + case 'SwaApplicationSettings': + case 'SwaThreeFieldApplicationSettings': + case 'WsFederationApplicationSettings': + return '\\Okta\\Applications\\ApplicationSettings'; + case 'AutoLoginApplicationSettingsApplication': + case 'BasicAuthApplicationSettingsApplication': + case 'BasicApplicationSettingsApplication': + case 'BookmarkApplicationSettingsApplication': + case 'BrowserPluginApplicationSettingsApplication': + case 'OpenIdConnectApplicationSettingsApplication': + case 'SamlApplicationSettingsApplication': + case 'SecurePasswordStoreApplicationSettingsApplication': + case 'SwaApplicationSettingsApplication': + case 'SwaThreeFieldApplicationSettingsApplication': + case 'WsFederationApplicationSettingsApplication': + return '\\Okta\\Applications\\ApplicationSettingsApplication'; + case 'AutoLoginApplicationCredentials': + case 'BasicAuthApplicationCredentials': + case 'BookmarkApplicationCredentials': + case 'BrowserPluginApplicationCredentials': + case 'OAuthApplicationCredentials': + case 'OpenIdConnectApplicationCredentials': + case 'SamlApplicationCredentials': + case 'SchemeApplicationCredentials': + case 'SecurePasswordStoreApplicationCredentials': + case 'WsFederationApplicationCredentials': + return '\\Okta\\Applications\\ApplicationCredentials'; + default: + return `\\Okta\\` + getFirstTagFromReference(obj.reference) + `\\${obj.model}`; + } case 'hash': return String.raw`\stdClass`; case 'boolean': @@ -22,12 +72,61 @@ function getType(obj) { } } -function getSafeType(obj) { +function getSafeType(obj, model) { switch (obj.commonType) { case 'dateTime': return ``; case 'object': - return `: ${obj.model}`; + switch (obj.model) { + case 'CallFactorProfile': + case 'EmailFactorProfile': + case 'HardwareFactorProfile': + case 'PushFactorProfile': + case 'SecurityQuestionFactorProfile': + case 'SmsFactorProfile': + case 'TokenFactorProfile': + case 'TotpFactorProfile': + case 'WebFactorProfile': + case 'FactorProfile': + return ': \\Okta\\UserFactors\\FactorProfile'; + case 'AutoLoginApplicationSettings': + case 'BasicAuthApplicationSettings': + case 'BasicApplicationSettings': + case 'BookmarkApplicationSettings': + case 'BrowserPluginApplicationSettings': + case 'OpenIdConnectApplicationSettings': + case 'SamlApplicationSettings': + case 'SecurePasswordStoreApplicationSettings': + case 'SwaApplicationSettings': + case 'SwaThreeFieldApplicationSettings': + case 'WsFederationApplicationSettings': + return ': \\Okta\\Applications\\ApplicationSettings'; + case 'AutoLoginApplicationCredentials': + case 'BasicAuthApplicationCredentials': + case 'BookmarkApplicationCredentials': + case 'BrowserPluginApplicationCredentials': + case 'OAuthApplicationCredentials': + case 'OpenIdConnectApplicationCredentials': + case 'SamlApplicationCredentials': + case 'SchemeApplicationCredentials': + case 'SecurePasswordStoreApplicationCredentials': + case 'WsFederationApplicationCredentials': + return ': \\Okta\\Applications\\ApplicationCredentials'; + case 'AutoLoginApplicationSettingsApplication': + case 'BasicAuthApplicationSettingsApplication': + case 'BasicApplicationSettingsApplication': + case 'BookmarkApplicationSettingsApplication': + case 'BrowserPluginApplicationSettingsApplication': + case 'OpenIdConnectApplicationSettingsApplication': + case 'SamlApplicationSettingsApplication': + case 'SecurePasswordStoreApplicationSettingsApplication': + case 'SwaApplicationSettingsApplication': + case 'SwaThreeFieldApplicationSettingsApplication': + case 'WsFederationApplicationSettingsApplication': + return ': \\Okta\\Applications\\ApplicationSettingsApplication'; + default: + return `: \\Okta\\` + getFirstTagFromReference(obj.reference) + `\\${obj.model}`; + } case 'hash': return String.raw`: \stdClass`; case 'boolean': @@ -44,6 +143,133 @@ function getSafeType(obj) { } } +function getTypeHint(obj) { + switch(obj.model) { + case 'CallFactorProfile': + case 'EmailFactorProfile': + case 'HardwareFactorProfile': + case 'PushFactorProfile': + case 'SecurityQuestionFactorProfile': + case 'SmsFactorProfile': + case 'TokenFactorProfile': + case 'TotpFactorProfile': + case 'WebFactorProfile': + case 'FactorProfile': + return '\\Okta\\UserFactors\\FactorProfile'; + case 'AutoLoginApplicationSettings': + case 'BasicAuthApplicationSettings': + case 'BasicApplicationSettings': + case 'BookmarkApplicationSettings': + case 'BrowserPluginApplicationSettings': + case 'OpenIdConnectApplicationSettings': + case 'SamlApplicationSettings': + case 'SecurePasswordStoreApplicationSettings': + case 'SwaApplicationSettings': + case 'SwaThreeFieldApplicationSettings': + case 'WsFederationApplicationSettings': + return '\\Okta\\Applications\\ApplicationSettings'; + case 'AutoLoginApplicationCredentials': + case 'BasicAuthApplicationCredentials': + case 'BookmarkApplicationCredentials': + case 'BrowserPluginApplicationCredentials': + case 'OAuthApplicationCredentials': + case 'OpenIdConnectApplicationCredentials': + case 'SamlApplicationCredentials': + case 'SchemeApplicationCredentials': + case 'SecurePasswordStoreApplicationCredentials': + case 'WsFederationApplicationCredentials': + return '\\Okta\\Applications\\ApplicationCredentials'; + case 'AutoLoginApplicationSettingsApplication': + case 'BasicAuthApplicationSettingsApplication': + case 'BasicApplicationSettingsApplication': + case 'BookmarkApplicationSettingsApplication': + case 'BrowserPluginApplicationSettingsApplication': + case 'OpenIdConnectApplicationSettingsApplication': + case 'SamlApplicationSettingsApplication': + case 'SecurePasswordStoreApplicationSettingsApplication': + case 'SwaApplicationSettingsApplication': + case 'SwaThreeFieldApplicationSettingsApplication': + case 'WsFederationApplicationSettingsApplication': + return '\\Okta\\Applications\\ApplicationSettingsApplication'; + default: + return `\\Okta\\` + getFirstTagFromReference(obj.reference) + `\\${obj.model}`; + } +} + +function getExtends(modelName) { + switch (modelName) { + case 'CallFactor': + case 'EmailFactor': + case 'HardwareFactor': + case 'PushFactor': + case 'SecurityQuestionFactor': + case 'SmsFactor': + case 'TokenFactor': + case 'TotpFactor': + case 'WebFactor': + return '\\Okta\\UserFactors\\Factor'; + case 'AutoLoginApplication': + case 'BasicAuthApplication': + case 'BookmarkApplication': + case 'BrowserPluginApplication': + case 'OpenIdConnectApplication': + case 'SamlApplication': + case 'SecurePasswordStoreApplication': + case 'WsFederationApplication': + return '\\Okta\\Applications\\Application'; + case 'AutoLoginApplicationSettings': + case 'BasicAuthApplicationSettings': + case 'BasicApplicationSettings': + case 'BookmarkApplicationSettings': + case 'BrowserPluginApplicationSettings': + case 'OpenIdConnectApplicationSettings': + case 'SamlApplicationSettings': + case 'SecurePasswordStoreApplicationSettings': + case 'SwaApplicationSettings': + case 'SwaThreeFieldApplicationSettings': + case 'WsFederationApplicationSettings': + return '\\Okta\\Applications\\ApplicationSettings'; + case 'AutoLoginApplicationCredentials': + case 'BasicAuthApplicationCredentials': + case 'BookmarkApplicationCredentials': + case 'BrowserPluginApplicationCredentials': + case 'OAuthApplicationCredentials': + case 'OpenIdConnectApplicationCredentials': + case 'SamlApplicationCredentials': + case 'SchemeApplicationCredentials': + case 'SecurePasswordStoreApplicationCredentials': + case 'WsFederationApplicationCredentials': + return '\\Okta\\Applications\\ApplicationCredentials'; + case 'AutoLoginApplicationSettingsApplication': + case 'BasicAuthApplicationSettingsApplication': + case 'BasicApplicationSettingsApplication': + case 'BookmarkApplicationSettingsApplication': + case 'BrowserPluginApplicationSettingsApplication': + case 'OpenIdConnectApplicationSettingsApplication': + case 'SamlApplicationSettingsApplication': + case 'SecurePasswordStoreApplicationSettingsApplication': + case 'SwaApplicationSettingsApplication': + case 'SwaThreeFieldApplicationSettingsApplication': + case 'WsFederationApplicationSettingsApplication': + return '\\Okta\\Applications\\ApplicationSettingsApplication'; + case 'SwaApplication': + case 'SwaThreeFieldApplication': + return '\\Okta\\Applications\\BrowserPluginApplication'; + case 'CallFactorProfile': + case 'EmailFactorProfile': + case 'HardwareFactorProfile': + case 'PushFactorProfile': + case 'SecurityQuestionFactorProfile': + case 'SmsFactorProfile': + case 'TokenFactorProfile': + case 'TotpFactorProfile': + case 'WebFactorProfile': + return '\\Okta\\UserFactors\\FactorProfile'; + default: + return '\\Okta\\Resource\\AbstractResource'; + } +} + function getAccessMethodType(obj) { switch (obj.commonType) { case 'dateTime': @@ -97,7 +323,7 @@ function getParams(method) { function getMethodParams(method) { const params = getParams(method); const pathParams = params.requiredPathParams.map(param => `$${param.name}`); - const queryParams = params.defaultQueryParams.map(param => `$${param.name} = ${param.default}`); + const queryParams = params.defaultQueryParams.map(param => `$${param.name} = ` + (param.default !== '' ? `${param.default}` : `''`)); let methodParams = [].concat(pathParams); if (params.bodyModel) { @@ -199,12 +425,82 @@ function getCrudMethodName(alias) { } } +function getClassNameForCollection(obj) { + switch(obj.operation.operationId) { + case 'listUserGroups': + case 'listGroupTargetsForRole': + return '\\Okta\\Groups\\Group'; + case 'listGroupUsers': + return '\\Okta\\Users\\User'; + case 'listFactors': + case 'listSupportedFactors': + return '\\Okta\\UserFactors\\Factor'; + case 'listSupportedSecurityQuestions': + return `\\Okta\\UserFactors\\SecurityQuestion`; + default: + return `\\${obj.baseClass}\\${obj.operation.responseModel}`; + } + +} + +function getCollectionName(obj) { + switch(obj.operation.operationId) { + case 'listUserGroups': + case 'listGroupTargetsForRole': + return '\\Okta\\Groups\\Collection'; + case 'listGroupUsers': + return '\\Okta\\Users\\Collection'; + case 'listFactors': + case 'listSupportedFactors': + return '\\Okta\\UserFactors\\Collection'; + case 'listSupportedSecurityQuestions': + return `\\Okta\\UserFactors\\SecurityQuestionsCollection`; + default: + return `\\${obj.baseClass}\\Collection`; + } +} + function getCrudOperationPath(method) { let parts = _.split(method.operation.path, '/'); + if(method.operation.operationId === 'getFactor') { + return '/' + parts[3] + '/{$userId}/' + parts[5] + '/{$factorId}'; + } return '/' + parts[3]; } +function pluralize(string) { + return _.pluralize(string); +} + +function customLog(toLog) { + console.log(toLog); +} + +function buildGetResourceParams(model) { + + switch(model.operation.operationId) { + case 'getFactor': + return String.raw`"factors/{$factorId}", \Okta\UserFactors\Factor::class, "/users/{$this->id}", []`; + } + +} + +function lookUpRef(model) { + const ref = model['$ref'].split("/").pop(); + return php.spec.definitions[ref]; +} + +function getRefTag(ref) { + return ref['x-okta-tags'][0] +} + +function getFirstTagFromReference(reference) { + return pluralize(reference['x-okta-tags'][0]); +} + + php.process = ({ spec, operations, models, handlebars }) => { + php.spec = spec; const templates = []; const modelMap = {}; @@ -219,6 +515,18 @@ php.process = ({ spec, operations, models, handlebars }) => { namespaces.push(model.namespace); } + for (let property of model.properties) { + property.baseClass = `Okta\\${model.namespace}`; + property.reference = php.spec.definitions[property.model]; + } + + if (model.methods) { + for(let method of model.methods) { + method.reference = php.spec.definitions[method.operation.responseModel]; + method.baseClass = `Okta\\${model.namespace}`; + } + } + // Build modelMap modelMap[model.modelName] = model; } @@ -228,8 +536,11 @@ php.process = ({ spec, operations, models, handlebars }) => { model.namespacedModels = []; model.crudOperations = []; + + if (model.methods) { for (let method of model.methods) { + const responseModel = method.operation.responseModel; if (modelMap[responseModel] && model.namespace !== modelMap[responseModel].namespace) { model.namespacedModels.push(modelMap[responseModel]); @@ -246,15 +557,25 @@ php.process = ({ spec, operations, models, handlebars }) => { if (model.crud) { for (let crud of model.crud) { + crud.defaultReturnType = `Okta\\${model.namespace}\\${model.modelName}` model.crudOperations.push(crud); } } - templates.push({ - src: 'templates/model.php.hbs', - dest: `${model.namespace}/${model.modelName}.php`, - context: model - }); + if(model.enum) { + model.enum = _.sortBy(model.enum); + templates.push({ + src: 'templates/enum.php.hbs', + dest: `${model.namespace}/${model.modelName}.php`, + context: model + }); + } else { + templates.push({ + src: 'templates/model.php.hbs', + dest: `${model.namespace}/${model.modelName}.php`, + context: model + }); + } } for (let namespace of _.uniqBy(namespaces)) { @@ -268,17 +589,32 @@ php.process = ({ spec, operations, models, handlebars }) => { handlebars.registerHelper({ getType, getSafeType, + getTypeHint, getAccessMethodType, getMethodPath, getMethodParams, + getExtends, getCollectionMethodParams, getMethodRequestParams, getMethodArrayName, getOperationReturnType, getMethodParamsComment, getCrudMethodName, - getCrudOperationPath + getCrudOperationPath, + pluralize, + customLog, + getClassNameForCollection, + getCollectionName, + buildGetResourceParams, + lookUpRef, + getRefTag, + getFirstTagFromReference + }); + handlebars.registerPartial('updateApplicationUser', fs.readFileSync('generator/templates/updateApplicationUser.php.hbs', 'utf8')) + handlebars.registerPartial('deleteApplicationUser', fs.readFileSync('generator/templates/deleteApplicationUser.php.hbs', 'utf8')) + handlebars.registerPartial('deleteApplicationGroupAssignment', fs.readFileSync('generator/templates/deleteApplicationGroupAssignment.php.hbs', 'utf8')) + return templates; }; diff --git a/openapi/generator/templates/collection.php.hbs b/openapi/generator/templates/collection.php.hbs index dc5662c6d7..21e5c66032 100644 --- a/openapi/generator/templates/collection.php.hbs +++ b/openapi/generator/templates/collection.php.hbs @@ -15,7 +15,7 @@ * limitations under the License. ******************************************************************************/ -namespace Okta\\{{namespace}}; +namespace Okta\Generated\\{{namespace}}; use Okta\Resource\AbstractCollection; diff --git a/openapi/generator/templates/deleteApplicationGroupAssignment.php.hbs b/openapi/generator/templates/deleteApplicationGroupAssignment.php.hbs new file mode 100644 index 0000000000..c3f7fa53e5 --- /dev/null +++ b/openapi/generator/templates/deleteApplicationGroupAssignment.php.hbs @@ -0,0 +1,10 @@ +public function delete( $appId ) +{ + return \Okta\Client::getInstance() + ->getDataStore() + ->deleteResource( + "/apps/{$appId}/group", + $this + ); +} + diff --git a/openapi/generator/templates/deleteApplicationUser.php.hbs b/openapi/generator/templates/deleteApplicationUser.php.hbs new file mode 100644 index 0000000000..1b69fed2be --- /dev/null +++ b/openapi/generator/templates/deleteApplicationUser.php.hbs @@ -0,0 +1,10 @@ +public function delete( $appId ) +{ + return \Okta\Client::getInstance() + ->getDataStore() + ->deleteResource( + "/apps/{$appId}/users", + $this + ); +} + diff --git a/openapi/generator/templates/enum.php.hbs b/openapi/generator/templates/enum.php.hbs new file mode 100644 index 0000000000..59ef4e7f98 --- /dev/null +++ b/openapi/generator/templates/enum.php.hbs @@ -0,0 +1,30 @@ +getDataStore() + ->getResource( + $query, + \\{{this.defaultReturnType}}::class, + "{{getCrudOperationPath this}}" + ); + return $factor->convertFromGenericFactor(); + } + {{else if (eq this.operation.operationId "getApplication")}} + public function get($query) + { + $application = \Okta\Client::getInstance() + ->getDataStore() + ->getResource( + $query, + \\{{this.defaultReturnType}}::class, + "{{getCrudOperationPath this}}" + ); + return $application->convertFromGenericApplication(); + } + {{else}} public function get($query) { return \Okta\Client::getInstance() ->getDataStore() ->getResource( $query, - self::class, - '{{getCrudOperationPath this}}' + \\{{this.defaultReturnType}}::class, + "{{getCrudOperationPath this}}" ); } - + {{/if}} {{/if}} {{#if (eq alias "create")}} public function create() @@ -48,51 +78,62 @@ class {{modelName}} extends AbstractResource return \Okta\Client::getInstance() ->getDataStore() ->createResource( - '{{getCrudOperationPath this}}', + "{{getCrudOperationPath this}}", $this, - self::class + \\{{this.defaultReturnType}}::class ); } {{/if}} {{#if (eq alias "update")}} + {{#if (eq this.operation.operationId "updateApplicationUser")}} + {{> updateApplicationUser }} + {{else}} public function save() { return \Okta\Client::getInstance() ->getDataStore() ->saveResource( - '{{getCrudOperationPath this}}', + "{{getCrudOperationPath this}}", $this, - self::class + \\{{this.defaultReturnType}}::class ); } - + {{/if}} {{/if}} {{#if (eq alias "delete")}} + {{#if (eq this.operation.operationId "deleteApplicationUser")}} + {{> deleteApplicationUser }} + {{else if (eq this.operation.operationId "deleteApplicationGroupAssignment")}} + {{> deleteApplicationGroupAssignment }} + {{else}} + {{#unless (eq this.operation.operationId "deleteFactor")}} public function delete() { return \Okta\Client::getInstance() ->getDataStore() ->deleteResource( - '{{getCrudOperationPath this}}', + "{{getCrudOperationPath this}}", $this ); } - + {{/unless}} + {{/if}} {{/if}} {{/each}} {{#each properties}} + {{#unless this.default}} /** * Get the {{propertyName}}. * - * @return {{getType this}} + * @return {{getType this baseClass}} */ {{#if isObject}} - public function get{{pascalCase propertyName}}(array $options = []){{getSafeType this}} + public function get{{pascalCase propertyName}}(array $options = []){{getSafeType this baseClass}} { return $this->getResourceProperty( self::{{upperSnakeCase propertyName}}, - {{model}}::class, + \Okta\\{{getFirstTagFromReference this.reference}}\\{{model}}::class, $options ); } @@ -101,10 +142,10 @@ class {{modelName}} extends AbstractResource /** * Set the {{propertyName}}. * - * @param {{model}} ${{propertyName}} The {{model}} instance. + * @param {{getTypeHint this}} ${{propertyName}} The {{model}} instance. * @return self */ - public function set{{pascalCase propertyName}}({{model}} ${{propertyName}}) + public function set{{pascalCase propertyName}}({{getTypeHint this}} ${{propertyName}}) { $this->setResourceProperty( self::{{upperSnakeCase propertyName}}, @@ -115,7 +156,7 @@ class {{modelName}} extends AbstractResource } {{/unless}} {{else}} - public function get{{pascalCase propertyName}}(){{getSafeType this}} + public function get{{pascalCase propertyName}}(){{getSafeType this baseClass}} { return $this->{{getAccessMethodType this}}(self::{{upperCase (snakeCase propertyName)}}); } @@ -137,29 +178,33 @@ class {{modelName}} extends AbstractResource } {{/unless}} {{/if}} + {{/unless}} {{/each}} {{#each methods}} + {{#if operation.isArray}} /** * Get the {{operation.responseModel}} object. * * @param array $options The options for the request. - * @return Collection + * @return {{getCollectionName this}} */ - public function {{getMethodArrayName alias}}({{{getCollectionMethodParams this}}}): Collection + public function {{getMethodArrayName alias}}({{{getCollectionMethodParams this}}}): {{getCollectionName this}} { + return $this ->getDataStore() ->getCollection( "{{{getMethodPath this}}}", - {{operation.responseModel}}::class, - Collection::class, + {{getClassNameForCollection this}}::class, + {{getCollectionName this}}::class, $options ); } {{else}} + /** - * Sends a request to the {{camelCase alias}} endpoint. + * {{this.operation.description}} * {{getMethodParamsComment this}} * @return mixed|null @@ -170,9 +215,20 @@ class {{modelName}} extends AbstractResource $uri = $this->getDataStore()->buildUri( $this->getDataStore()->getOrganizationUrl() . $uri ); - return $this + $body = $this ->getDataStore() ->executeRequest({{{getMethodRequestParams this}}}{{path}}); + + {{#if this.operation.responseModel}} + {{#if (eq this.operation.responseModel "Factor")}} + $response = new \Okta\\{{{pluralize this.operation.tags.[0] }}}\\{{this.operation.responseModel}}(null, $body); + return $response->convertFromGenericFactor(); + {{else}} + return new \Okta\\{{{pluralize this.operation.tags.[0] }}}\\{{this.operation.responseModel}}(null, $body); + {{/if}} + {{else}} + return $body; + {{/if}} } {{/if}} {{/each}} diff --git a/openapi/generator/templates/updateApplicationUser.php.hbs b/openapi/generator/templates/updateApplicationUser.php.hbs new file mode 100644 index 0000000000..cc3905803c --- /dev/null +++ b/openapi/generator/templates/updateApplicationUser.php.hbs @@ -0,0 +1,11 @@ +public function save( $appId ) +{ + return \Okta\Client::getInstance() + ->getDataStore() + ->saveResource( + "/apps/{$appId}/users", + $this, + \\{{this.defaultReturnType}}::class + ); +} + diff --git a/openapi/package-lock.json b/openapi/package-lock.json new file mode 100644 index 0000000000..2f73ea4b07 --- /dev/null +++ b/openapi/package-lock.json @@ -0,0 +1,295 @@ +{ + "name": "okta-sdk-php-openapi", + "version": "0.2.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@okta/openapi": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@okta/openapi/-/openapi-0.3.0.tgz", + "integrity": "sha1-FycTtv1lk/svzvWsYLPcqNZvjMA=", + "dev": true, + "requires": { + "commander": "2.9.0", + "fs-extra": "3.0.1", + "handlebars": "4.0.8" + } + }, + "align-text": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", + "integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=", + "dev": true, + "requires": { + "kind-of": "3.2.2", + "longest": "1.0.1", + "repeat-string": "1.6.1" + } + }, + "amdefine": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", + "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", + "dev": true + }, + "async": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", + "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", + "dev": true + }, + "camelcase": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", + "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=", + "dev": true, + "optional": true + }, + "center-align": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz", + "integrity": "sha1-qg0yYptu6XIgBBHL1EYckHvCt60=", + "dev": true, + "optional": true, + "requires": { + "align-text": "0.1.4", + "lazy-cache": "1.0.4" + } + }, + "cliui": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz", + "integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=", + "dev": true, + "optional": true, + "requires": { + "center-align": "0.1.3", + "right-align": "0.1.3", + "wordwrap": "0.0.2" + }, + "dependencies": { + "wordwrap": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz", + "integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=", + "dev": true, + "optional": true + } + } + }, + "commander": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz", + "integrity": "sha1-nJkJQXbhIkDLItbFFGCYQA/g99Q=", + "dev": true, + "requires": { + "graceful-readlink": "1.0.1" + } + }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "dev": true, + "optional": true + }, + "fs-extra": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-3.0.1.tgz", + "integrity": "sha1-N5TzeMWLNC6n27sjCVEJxLO2IpE=", + "dev": true, + "requires": { + "graceful-fs": "4.1.11", + "jsonfile": "3.0.1", + "universalify": "0.1.1" + } + }, + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "dev": true + }, + "graceful-readlink": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz", + "integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=", + "dev": true + }, + "handlebars": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.0.8.tgz", + "integrity": "sha1-Irh1zT8ObL6jAxTxROgrx6cv9CA=", + "dev": true, + "requires": { + "async": "1.5.2", + "optimist": "0.6.1", + "source-map": "0.4.4", + "uglify-js": "2.8.29" + } + }, + "is-buffer": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.5.tgz", + "integrity": "sha1-Hzsm72E7IUuIy8ojzGwB2Hlh7sw=", + "dev": true + }, + "json-stable-stringify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", + "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", + "requires": { + "jsonify": "0.0.0" + } + }, + "jsonfile": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-3.0.1.tgz", + "integrity": "sha1-pezG9l9T9mLEQVx2daAzHQmS7GY=", + "dev": true, + "requires": { + "graceful-fs": "4.1.11" + } + }, + "jsonify": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", + "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=" + }, + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "1.1.5" + } + }, + "lazy-cache": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz", + "integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4=", + "dev": true, + "optional": true + }, + "lodash": { + "version": "4.17.4", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", + "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", + "dev": true + }, + "lodash-inflection": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/lodash-inflection/-/lodash-inflection-1.5.0.tgz", + "integrity": "sha1-NE5agDCILVGvmODWE7sFR8i33cc=", + "dev": true + }, + "longest": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", + "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=", + "dev": true + }, + "minimist": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", + "integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=", + "dev": true + }, + "optimist": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", + "integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=", + "dev": true, + "requires": { + "minimist": "0.0.10", + "wordwrap": "0.0.3" + } + }, + "repeat-string": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", + "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", + "dev": true + }, + "right-align": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz", + "integrity": "sha1-YTObci/mo1FWiSENJOFMlhSGE+8=", + "dev": true, + "optional": true, + "requires": { + "align-text": "0.1.4" + } + }, + "source-map": { + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", + "integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=", + "dev": true, + "requires": { + "amdefine": "1.0.1" + } + }, + "uglify-js": { + "version": "2.8.29", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.29.tgz", + "integrity": "sha1-KcVzMUgFe7Th913zW3qcty5qWd0=", + "dev": true, + "optional": true, + "requires": { + "source-map": "0.5.7", + "uglify-to-browserify": "1.0.2", + "yargs": "3.10.0" + }, + "dependencies": { + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "dev": true, + "optional": true + } + } + }, + "uglify-to-browserify": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz", + "integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc=", + "dev": true, + "optional": true + }, + "universalify": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.1.tgz", + "integrity": "sha1-+nG63UQ3r0wUiEHjs7Fl+enlkLc=", + "dev": true + }, + "window-size": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", + "integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0=", + "dev": true, + "optional": true + }, + "wordwrap": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", + "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=", + "dev": true + }, + "yargs": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", + "integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=", + "dev": true, + "optional": true, + "requires": { + "camelcase": "1.2.1", + "cliui": "2.1.0", + "decamelize": "1.2.0", + "window-size": "0.1.0" + } + } + } +} diff --git a/openapi/package.json b/openapi/package.json index b702ddabf8..11546b55ac 100644 --- a/openapi/package.json +++ b/openapi/package.json @@ -3,10 +3,10 @@ "private": true, "version": "0.2.0", "scripts": { - "generator": "okta-sdk-generator -t generator -o ../src" + "generator": "okta-sdk-generator -t generator -o ../src/Generated" }, "devDependencies": { - "@okta/openapi": "^0.2.0", + "@okta/openapi": "^0.10.0", "lodash": "^4.17.4", "lodash-inflection": "^1.5.0" }, diff --git a/src/Applications/AppUser.php b/src/Applications/AppUser.php new file mode 100644 index 0000000000..2722df9270 --- /dev/null +++ b/src/Applications/AppUser.php @@ -0,0 +1,23 @@ +getSignOnMode()) { + case "BOOKMARK": + $appClass = \Okta\Applications\BookmarkApplication::class; + break; + case "BASIC_AUTH": + $appClass = \Okta\Applications\BasicAuthApplication::class; + break; + case "BROWSER_PLUGIN": + switch ($this->getName()) { + case "template_swa": + $appClass = \Okta\Applications\SwaApplication::class; + break; + case "template_swa3field": + $appClass = \Okta\Applications\SwaThreeFieldApplication::class; + break; + } + break; + case "SECURE_PASSWORD_STORE": + $appClass = \Okta\Applications\SecurePasswordStoreApplication::class; + break; + case "AUTO_LOGIN": + $appClass = \Okta\Applications\AutoLoginApplication::class; + break; + case "WS_FEDERATION": + $appClass = \Okta\Applications\WsFederationApplication::class; + break; + case "SAML_2_0": + $appClass = \Okta\Applications\SamlApplication::class; + break; + case "OPENID_CONNECT": + $appClass = \Okta\Applications\OpenIdConnectApplication::class; + break; + } + + $properties = new \stdClass(); + foreach ($this->getPropertyNames() as $name) { + $properties->$name = $this->getProperty($name); + } + + return new $appClass(null, $properties); + } +} diff --git a/src/Applications/ApplicationAccessibility.php b/src/Applications/ApplicationAccessibility.php new file mode 100644 index 0000000000..312718b767 --- /dev/null +++ b/src/Applications/ApplicationAccessibility.php @@ -0,0 +1,23 @@ +getDataStore() + ->saveResource( + "/apps/{$appId}/users", + $this, + \Okta\Applications\AppUser::class + ); + } + + public function delete($appId) + { + return \Okta\Client::getInstance() + ->getDataStore() + ->deleteResource( + "/apps/{$appId}/users", + $this + ); + } + + /** + * Get the id. + * + * @return string + */ + public function getId(): string + { + return $this->getProperty(self::ID); + } + /** + * Set the id. + * + * @param mixed $id The value to set. + * @return self + */ + public function setId($id) + { + $this->setProperty( + self::ID, + $id + ); + + return $this; + } + /** + * Get the scope. + * + * @return string + */ + public function getScope(): string + { + return $this->getProperty(self::SCOPE); + } + /** + * Set the scope. + * + * @param mixed $scope The value to set. + * @return self + */ + public function setScope($scope) + { + $this->setProperty( + self::SCOPE, + $scope + ); + + return $this; + } + /** + * Get the _links. + * + * @return \stdClass + */ + public function getLinks(): \stdClass + { + return $this->getProperty(self::LINKS); + } + /** + * Get the status. + * + * @return string + */ + public function getStatus(): string + { + return $this->getProperty(self::STATUS); + } + /** + * Get the created. + * + * @return \Carbon\Carbon|null + */ + public function getCreated() + { + return $this->getDateProperty(self::CREATED); + } + /** + * Get the profile. + * + * @return \stdClass + */ + public function getProfile(): \stdClass + { + return $this->getProperty(self::PROFILE); + } + /** + * Get the lastSync. + * + * @return \Carbon\Carbon|null + */ + public function getLastSync() + { + return $this->getDateProperty(self::LAST_SYNC); + } + /** + * Get the _embedded. + * + * @return \stdClass + */ + public function getEmbedded(): \stdClass + { + return $this->getProperty(self::EMBEDDED); + } + /** + * Get the syncState. + * + * @return string + */ + public function getSyncState(): string + { + return $this->getProperty(self::SYNC_STATE); + } + /** + * Get the externalId. + * + * @return string + */ + public function getExternalId(): string + { + return $this->getProperty(self::EXTERNAL_ID); + } + /** + * Get the credentials. + * + * @return \Okta\Applications\AppUserCredentials + */ + public function getCredentials(array $options = []): \Okta\Applications\AppUserCredentials + { + return $this->getResourceProperty( + self::CREDENTIALS, + \Okta\Applications\AppUserCredentials::class, + $options + ); + } + + /** + * Set the credentials. + * + * @param \Okta\Applications\AppUserCredentials $credentials The AppUserCredentials instance. + * @return self + */ + public function setCredentials(\Okta\Applications\AppUserCredentials $credentials) + { + $this->setResourceProperty( + self::CREDENTIALS, + $credentials + ); + + return $this; + } + /** + * Get the lastUpdated. + * + * @return \Carbon\Carbon|null + */ + public function getLastUpdated() + { + return $this->getDateProperty(self::LAST_UPDATED); + } + /** + * Get the statusChanged. + * + * @return \Carbon\Carbon|null + */ + public function getStatusChanged() + { + return $this->getDateProperty(self::STATUS_CHANGED); + } + /** + * Get the passwordChanged. + * + * @return \Carbon\Carbon|null + */ + public function getPasswordChanged() + { + return $this->getDateProperty(self::PASSWORD_CHANGED); + } +} diff --git a/src/Generated/Applications/AppUserCredentials.php b/src/Generated/Applications/AppUserCredentials.php new file mode 100644 index 0000000000..ec3c41a397 --- /dev/null +++ b/src/Generated/Applications/AppUserCredentials.php @@ -0,0 +1,79 @@ +getResourceProperty( + self::PASSWORD, + \Okta\Applications\AppUserPasswordCredential::class, + $options + ); + } + + /** + * Set the password. + * + * @param \Okta\Applications\AppUserPasswordCredential $password The AppUserPasswordCredential instance. + * @return self + */ + public function setPassword(\Okta\Applications\AppUserPasswordCredential $password) + { + $this->setResourceProperty( + self::PASSWORD, + $password + ); + + return $this; + } + /** + * Get the userName. + * + * @return string + */ + public function getUserName(): string + { + return $this->getProperty(self::USER_NAME); + } + /** + * Set the userName. + * + * @param mixed $userName The value to set. + * @return self + */ + public function setUserName($userName) + { + $this->setProperty( + self::USER_NAME, + $userName + ); + + return $this; + } +} diff --git a/src/Generated/Applications/AppUserPasswordCredential.php b/src/Generated/Applications/AppUserPasswordCredential.php new file mode 100644 index 0000000000..faafb66ae5 --- /dev/null +++ b/src/Generated/Applications/AppUserPasswordCredential.php @@ -0,0 +1,49 @@ +getProperty(self::VALUE); + } + /** + * Set the value. + * + * @param mixed $value The value to set. + * @return self + */ + public function setValue($value) + { + $this->setProperty( + self::VALUE, + $value + ); + + return $this; + } +} diff --git a/src/Generated/Applications/Application.php b/src/Generated/Applications/Application.php new file mode 100644 index 0000000000..f190703dc0 --- /dev/null +++ b/src/Generated/Applications/Application.php @@ -0,0 +1,586 @@ +getDataStore() + ->getResource( + $query, + \Okta\Applications\Application::class, + "/apps" + ); + return $application->convertFromGenericApplication(); + } + public function save() + { + return \Okta\Client::getInstance() + ->getDataStore() + ->saveResource( + "/apps", + $this, + \Okta\Applications\Application::class + ); + } + public function delete() + { + return \Okta\Client::getInstance() + ->getDataStore() + ->deleteResource( + "/apps", + $this + ); + } + /** + * Get the id. + * + * @return string + */ + public function getId(): string + { + return $this->getProperty(self::ID); + } + /** + * Get the name. + * + * @return string + */ + public function getName(): string + { + return $this->getProperty(self::NAME); + } + /** + * Get the label. + * + * @return string + */ + public function getLabel(): string + { + return $this->getProperty(self::LABEL); + } + /** + * Set the label. + * + * @param mixed $label The value to set. + * @return self + */ + public function setLabel($label) + { + $this->setProperty( + self::LABEL, + $label + ); + + return $this; + } + /** + * Get the _links. + * + * @return \stdClass + */ + public function getLinks(): \stdClass + { + return $this->getProperty(self::LINKS); + } + /** + * Get the status. + * + * @return string + */ + public function getStatus(): string + { + return $this->getProperty(self::STATUS); + } + /** + * Get the created. + * + * @return \Carbon\Carbon|null + */ + public function getCreated() + { + return $this->getDateProperty(self::CREATED); + } + /** + * Get the features. + * + * @return array + */ + public function getFeatures(): array + { + return $this->getProperty(self::FEATURES); + } + /** + * Set the features. + * + * @param mixed $features The value to set. + * @return self + */ + public function setFeatures($features) + { + $this->setProperty( + self::FEATURES, + $features + ); + + return $this; + } + /** + * Get the settings. + * + * @return \Okta\Applications\ApplicationSettings + */ + public function getSettings(array $options = []): \Okta\Applications\ApplicationSettings + { + return $this->getResourceProperty( + self::SETTINGS, + \Okta\Applications\ApplicationSettings::class, + $options + ); + } + + /** + * Set the settings. + * + * @param \Okta\Applications\ApplicationSettings $settings The ApplicationSettings instance. + * @return self + */ + public function setSettings(\Okta\Applications\ApplicationSettings $settings) + { + $this->setResourceProperty( + self::SETTINGS, + $settings + ); + + return $this; + } + /** + * Get the _embedded. + * + * @return \stdClass + */ + public function getEmbedded(): \stdClass + { + return $this->getProperty(self::EMBEDDED); + } + /** + * Get the licensing. + * + * @return \Okta\Applications\ApplicationLicensing + */ + public function getLicensing(array $options = []): \Okta\Applications\ApplicationLicensing + { + return $this->getResourceProperty( + self::LICENSING, + \Okta\Applications\ApplicationLicensing::class, + $options + ); + } + + /** + * Set the licensing. + * + * @param \Okta\Applications\ApplicationLicensing $licensing The ApplicationLicensing instance. + * @return self + */ + public function setLicensing(\Okta\Applications\ApplicationLicensing $licensing) + { + $this->setResourceProperty( + self::LICENSING, + $licensing + ); + + return $this; + } + /** + * Get the signOnMode. + * + * @return string + */ + public function getSignOnMode(): string + { + return $this->getProperty(self::SIGN_ON_MODE); + } + /** + * Set the signOnMode. + * + * @param mixed $signOnMode The value to set. + * @return self + */ + public function setSignOnMode($signOnMode) + { + $this->setProperty( + self::SIGN_ON_MODE, + $signOnMode + ); + + return $this; + } + /** + * Get the visibility. + * + * @return \Okta\Applications\ApplicationVisibility + */ + public function getVisibility(array $options = []): \Okta\Applications\ApplicationVisibility + { + return $this->getResourceProperty( + self::VISIBILITY, + \Okta\Applications\ApplicationVisibility::class, + $options + ); + } + + /** + * Set the visibility. + * + * @param \Okta\Applications\ApplicationVisibility $visibility The ApplicationVisibility instance. + * @return self + */ + public function setVisibility(\Okta\Applications\ApplicationVisibility $visibility) + { + $this->setResourceProperty( + self::VISIBILITY, + $visibility + ); + + return $this; + } + /** + * Get the credentials. + * + * @return \Okta\Applications\ApplicationCredentials + */ + public function getCredentials(array $options = []): \Okta\Applications\ApplicationCredentials + { + return $this->getResourceProperty( + self::CREDENTIALS, + \Okta\Applications\ApplicationCredentials::class, + $options + ); + } + + /** + * Set the credentials. + * + * @param \Okta\Applications\ApplicationCredentials $credentials The ApplicationCredentials instance. + * @return self + */ + public function setCredentials(\Okta\Applications\ApplicationCredentials $credentials) + { + $this->setResourceProperty( + self::CREDENTIALS, + $credentials + ); + + return $this; + } + /** + * Get the lastUpdated. + * + * @return \Carbon\Carbon|null + */ + public function getLastUpdated() + { + return $this->getDateProperty(self::LAST_UPDATED); + } + /** + * Get the accessibility. + * + * @return \Okta\Applications\ApplicationAccessibility + */ + public function getAccessibility(array $options = []): \Okta\Applications\ApplicationAccessibility + { + return $this->getResourceProperty( + self::ACCESSIBILITY, + \Okta\Applications\ApplicationAccessibility::class, + $options + ); + } + + /** + * Set the accessibility. + * + * @param \Okta\Applications\ApplicationAccessibility $accessibility The ApplicationAccessibility instance. + * @return self + */ + public function setAccessibility(\Okta\Applications\ApplicationAccessibility $accessibility) + { + $this->setResourceProperty( + self::ACCESSIBILITY, + $accessibility + ); + + return $this; + } + + + /** + * Activates an inactive application. + * + * + * @return mixed|null + */ + public function activate() + { + $uri = "/api/v1/apps/{$this->getId()}/lifecycle/activate"; + $uri = $this->getDataStore()->buildUri( + $this->getDataStore()->getOrganizationUrl() . $uri + ); + $body = $this + ->getDataStore() + ->executeRequest('POST', $uri); + + return $body; + } + + + /** + * Deactivates an active application. + * + * + * @return mixed|null + */ + public function deactivate() + { + $uri = "/api/v1/apps/{$this->getId()}/lifecycle/deactivate"; + $uri = $this->getDataStore()->buildUri( + $this->getDataStore()->getOrganizationUrl() . $uri + ); + $body = $this + ->getDataStore() + ->executeRequest('POST', $uri); + + return $body; + } + + /** + * Get the AppUser object. + * + * @param array $options The options for the request. + * @return \Okta\Applications\Collection + */ + public function getApplicationUsers(array $options = []): \Okta\Applications\Collection + { + + return $this + ->getDataStore() + ->getCollection( + "/api/v1/apps/{$this->getId()}/users", + \Okta\Applications\AppUser::class, + \Okta\Applications\Collection::class, + $options + ); + } + + + /** + * Assigns an user to an application with [credentials](#application-user-credentials-object) and an app-specific [profile](#application-user-profile-object). Profile mappings defined for the application are first applied before applying any profile properties specified in the request. + * + * + * @return mixed|null + */ + public function assignUserToApplication(AppUser $appUser) + { + $uri = "/api/v1/apps/{$this->getId()}/users"; + $uri = $this->getDataStore()->buildUri( + $this->getDataStore()->getOrganizationUrl() . $uri + ); + $body = $this + ->getDataStore() + ->executeRequest('POST', $uri, $appUser); + + return new \Okta\Applications\AppUser(null, $body); + } + + + /** + * Fetches a specific user assignment for application by `id`. + * + * + * @return mixed|null + */ + public function getApplicationUser($userId) + { + $uri = "/api/v1/apps/{$this->getId()}/users/{$userId}"; + $uri = $this->getDataStore()->buildUri( + $this->getDataStore()->getOrganizationUrl() . $uri + ); + $body = $this + ->getDataStore() + ->executeRequest('GET', $uri); + + return new \Okta\Applications\AppUser(null, $body); + } + + + /** + * Assigns a group to an application + * + * + * @return mixed|null + */ + public function createApplicationGroupAssignment($groupId, ApplicationGroupAssignment $applicationGroupAssignment) + { + $uri = "/api/v1/apps/{$this->getId()}/groups/{$groupId}"; + $uri = $this->getDataStore()->buildUri( + $this->getDataStore()->getOrganizationUrl() . $uri + ); + $body = $this + ->getDataStore() + ->executeRequest('PUT', $uri, $applicationGroupAssignment); + + return new \Okta\Applications\ApplicationGroupAssignment(null, $body); + } + + + /** + * Fetches an application group assignment + * + * + * @return mixed|null + */ + public function getApplicationGroupAssignment($groupId) + { + $uri = "/api/v1/apps/{$this->getId()}/groups/{$groupId}"; + $uri = $this->getDataStore()->buildUri( + $this->getDataStore()->getOrganizationUrl() . $uri + ); + $body = $this + ->getDataStore() + ->executeRequest('GET', $uri); + + return new \Okta\Applications\ApplicationGroupAssignment(null, $body); + } + + + /** + * Generates a new X.509 certificate for an application key credential + * + * + * @return mixed|null + */ + public function generateApplicationKey() + { + $uri = "/api/v1/apps/{$this->getId()}/credentials/keys/generate"; + $uri = $this->getDataStore()->buildUri( + $this->getDataStore()->getOrganizationUrl() . $uri + ); + $body = $this + ->getDataStore() + ->executeRequest('POST', $uri); + + return new \Okta\Applications\JsonWebKey(null, $body); + } + + + /** + * Clones a X.509 certificate for an application key credential from a source application to target application. + * + * + * @return mixed|null + */ + public function cloneApplicationKey($keyId) + { + $uri = "/api/v1/apps/{$this->getId()}/credentials/keys/{$keyId}/clone"; + $uri = $this->getDataStore()->buildUri( + $this->getDataStore()->getOrganizationUrl() . $uri + ); + $body = $this + ->getDataStore() + ->executeRequest('POST', $uri); + + return new \Okta\Applications\JsonWebKey(null, $body); + } + + + /** + * Gets a specific [application key credential](#application-key-credential-model) by `kid` + * + * + * @return mixed|null + */ + public function getApplicationKey($keyId) + { + $uri = "/api/v1/apps/{$this->getId()}/credentials/keys/{$keyId}"; + $uri = $this->getDataStore()->buildUri( + $this->getDataStore()->getOrganizationUrl() . $uri + ); + $body = $this + ->getDataStore() + ->executeRequest('GET', $uri); + + return new \Okta\Applications\JsonWebKey(null, $body); + } + + /** + * Get the ApplicationGroupAssignment object. + * + * @param array $options The options for the request. + * @return \Okta\Applications\Collection + */ + public function getGroupAssignments(array $options = []): \Okta\Applications\Collection + { + + return $this + ->getDataStore() + ->getCollection( + "/api/v1/apps/{$this->getId()}/groups", + \Okta\Applications\ApplicationGroupAssignment::class, + \Okta\Applications\Collection::class, + $options + ); + } + + /** + * Get the JsonWebKey object. + * + * @param array $options The options for the request. + * @return \Okta\Applications\Collection + */ + public function getKeys(array $options = []): \Okta\Applications\Collection + { + + return $this + ->getDataStore() + ->getCollection( + "/api/v1/apps/{$this->getId()}/credentials/keys", + \Okta\Applications\JsonWebKey::class, + \Okta\Applications\Collection::class, + $options + ); + } +} diff --git a/src/Generated/Applications/ApplicationAccessibility.php b/src/Generated/Applications/ApplicationAccessibility.php new file mode 100644 index 0000000000..a0b4acf3e7 --- /dev/null +++ b/src/Generated/Applications/ApplicationAccessibility.php @@ -0,0 +1,99 @@ +getProperty(self::SELF_SERVICE); + } + /** + * Set the selfService. + * + * @param mixed $selfService The value to set. + * @return self + */ + public function setSelfService($selfService) + { + $this->setProperty( + self::SELF_SERVICE, + $selfService + ); + + return $this; + } + /** + * Get the errorRedirectUrl. + * + * @return string + */ + public function getErrorRedirectUrl(): string + { + return $this->getProperty(self::ERROR_REDIRECT_URL); + } + /** + * Set the errorRedirectUrl. + * + * @param mixed $errorRedirectUrl The value to set. + * @return self + */ + public function setErrorRedirectUrl($errorRedirectUrl) + { + $this->setProperty( + self::ERROR_REDIRECT_URL, + $errorRedirectUrl + ); + + return $this; + } + /** + * Get the loginRedirectUrl. + * + * @return string + */ + public function getLoginRedirectUrl(): string + { + return $this->getProperty(self::LOGIN_REDIRECT_URL); + } + /** + * Set the loginRedirectUrl. + * + * @param mixed $loginRedirectUrl The value to set. + * @return self + */ + public function setLoginRedirectUrl($loginRedirectUrl) + { + $this->setProperty( + self::LOGIN_REDIRECT_URL, + $loginRedirectUrl + ); + + return $this; + } +} diff --git a/src/Generated/Applications/ApplicationCredentials.php b/src/Generated/Applications/ApplicationCredentials.php new file mode 100644 index 0000000000..9016b87c32 --- /dev/null +++ b/src/Generated/Applications/ApplicationCredentials.php @@ -0,0 +1,84 @@ +getResourceProperty( + self::SIGNING, + \Okta\Applications\ApplicationCredentialsSigning::class, + $options + ); + } + + /** + * Set the signing. + * + * @param \Okta\Applications\ApplicationCredentialsSigning $signing The ApplicationCredentialsSigning instance. + * @return self + */ + public function setSigning(\Okta\Applications\ApplicationCredentialsSigning $signing) + { + $this->setResourceProperty( + self::SIGNING, + $signing + ); + + return $this; + } + /** + * Get the userNameTemplate. + * + * @return \Okta\Applications\ApplicationCredentialsUsernameTemplate + */ + public function getUserNameTemplate(array $options = []): \Okta\Applications\ApplicationCredentialsUsernameTemplate + { + return $this->getResourceProperty( + self::USER_NAME_TEMPLATE, + \Okta\Applications\ApplicationCredentialsUsernameTemplate::class, + $options + ); + } + + /** + * Set the userNameTemplate. + * + * @param \Okta\Applications\ApplicationCredentialsUsernameTemplate $userNameTemplate The ApplicationCredentialsUsernameTemplate instance. + * @return self + */ + public function setUserNameTemplate(\Okta\Applications\ApplicationCredentialsUsernameTemplate $userNameTemplate) + { + $this->setResourceProperty( + self::USER_NAME_TEMPLATE, + $userNameTemplate + ); + + return $this; + } +} diff --git a/src/Generated/Applications/ApplicationCredentialsOAuthClient.php b/src/Generated/Applications/ApplicationCredentialsOAuthClient.php new file mode 100644 index 0000000000..6f82ab880e --- /dev/null +++ b/src/Generated/Applications/ApplicationCredentialsOAuthClient.php @@ -0,0 +1,124 @@ +getProperty(self::CLIENT_ID); + } + /** + * Set the client_id. + * + * @param mixed $client_id The value to set. + * @return self + */ + public function setClientId($client_id) + { + $this->setProperty( + self::CLIENT_ID, + $client_id + ); + + return $this; + } + /** + * Get the client_secret. + * + * @return string + */ + public function getClientSecret(): string + { + return $this->getProperty(self::CLIENT_SECRET); + } + /** + * Set the client_secret. + * + * @param mixed $client_secret The value to set. + * @return self + */ + public function setClientSecret($client_secret) + { + $this->setProperty( + self::CLIENT_SECRET, + $client_secret + ); + + return $this; + } + /** + * Get the autoKeyRotation. + * + * @return bool + */ + public function getAutoKeyRotation(): bool + { + return $this->getProperty(self::AUTO_KEY_ROTATION); + } + /** + * Set the autoKeyRotation. + * + * @param mixed $autoKeyRotation The value to set. + * @return self + */ + public function setAutoKeyRotation($autoKeyRotation) + { + $this->setProperty( + self::AUTO_KEY_ROTATION, + $autoKeyRotation + ); + + return $this; + } + /** + * Get the token_endpoint_auth_method. + * + * @return string + */ + public function getTokenEndpointAuthMethod(): string + { + return $this->getProperty(self::TOKEN_ENDPOINT_AUTH_METHOD); + } + /** + * Set the token_endpoint_auth_method. + * + * @param mixed $token_endpoint_auth_method The value to set. + * @return self + */ + public function setTokenEndpointAuthMethod($token_endpoint_auth_method) + { + $this->setProperty( + self::TOKEN_ENDPOINT_AUTH_METHOD, + $token_endpoint_auth_method + ); + + return $this; + } +} diff --git a/src/Generated/Applications/ApplicationCredentialsScheme.php b/src/Generated/Applications/ApplicationCredentialsScheme.php new file mode 100644 index 0000000000..bcb299a81b --- /dev/null +++ b/src/Generated/Applications/ApplicationCredentialsScheme.php @@ -0,0 +1,29 @@ +getProperty(self::KID); + } + /** + * Set the kid. + * + * @param mixed $kid The value to set. + * @return self + */ + public function setKid($kid) + { + $this->setProperty( + self::KID, + $kid + ); + + return $this; + } + /** + * Get the lastRotated. + * + * @return \Carbon\Carbon|null + */ + public function getLastRotated() + { + return $this->getDateProperty(self::LAST_ROTATED); + } + /** + * Get the nextRotation. + * + * @return \Carbon\Carbon|null + */ + public function getNextRotation() + { + return $this->getDateProperty(self::NEXT_ROTATION); + } + /** + * Get the rotationMode. + * + * @return string + */ + public function getRotationMode(): string + { + return $this->getProperty(self::ROTATION_MODE); + } + /** + * Set the rotationMode. + * + * @param mixed $rotationMode The value to set. + * @return self + */ + public function setRotationMode($rotationMode) + { + $this->setProperty( + self::ROTATION_MODE, + $rotationMode + ); + + return $this; + } +} diff --git a/src/Generated/Applications/ApplicationCredentialsUsernameTemplate.php b/src/Generated/Applications/ApplicationCredentialsUsernameTemplate.php new file mode 100644 index 0000000000..6df0d9f9a2 --- /dev/null +++ b/src/Generated/Applications/ApplicationCredentialsUsernameTemplate.php @@ -0,0 +1,99 @@ +getProperty(self::TYPE); + } + /** + * Set the type. + * + * @param mixed $type The value to set. + * @return self + */ + public function setType($type) + { + $this->setProperty( + self::TYPE, + $type + ); + + return $this; + } + /** + * Get the suffix. + * + * @return string + */ + public function getSuffix(): string + { + return $this->getProperty(self::SUFFIX); + } + /** + * Set the suffix. + * + * @param mixed $suffix The value to set. + * @return self + */ + public function setSuffix($suffix) + { + $this->setProperty( + self::SUFFIX, + $suffix + ); + + return $this; + } + /** + * Get the template. + * + * @return string + */ + public function getTemplate(): string + { + return $this->getProperty(self::TEMPLATE); + } + /** + * Set the template. + * + * @param mixed $template The value to set. + * @return self + */ + public function setTemplate($template) + { + $this->setProperty( + self::TEMPLATE, + $template + ); + + return $this; + } +} diff --git a/src/Generated/Applications/ApplicationGroupAssignment.php b/src/Generated/Applications/ApplicationGroupAssignment.php new file mode 100644 index 0000000000..e83aed1f67 --- /dev/null +++ b/src/Generated/Applications/ApplicationGroupAssignment.php @@ -0,0 +1,124 @@ +getDataStore() + ->deleteResource( + "/apps/{$appId}/group", + $this + ); + } + + /** + * Get the id. + * + * @return string + */ + public function getId(): string + { + return $this->getProperty(self::ID); + } + /** + * Get the _links. + * + * @return \stdClass + */ + public function getLinks(): \stdClass + { + return $this->getProperty(self::LINKS); + } + /** + * Get the profile. + * + * @return \stdClass + */ + public function getProfile(): \stdClass + { + return $this->getProperty(self::PROFILE); + } + /** + * Set the profile. + * + * @param mixed $profile The value to set. + * @return self + */ + public function setProfile($profile) + { + $this->setProperty( + self::PROFILE, + $profile + ); + + return $this; + } + /** + * Get the priority. + * + * @return int + */ + public function getPriority(): int + { + return $this->getProperty(self::PRIORITY); + } + /** + * Set the priority. + * + * @param mixed $priority The value to set. + * @return self + */ + public function setPriority($priority) + { + $this->setProperty( + self::PRIORITY, + $priority + ); + + return $this; + } + /** + * Get the _embedded. + * + * @return \stdClass + */ + public function getEmbedded(): \stdClass + { + return $this->getProperty(self::EMBEDDED); + } + /** + * Get the lastUpdated. + * + * @return \Carbon\Carbon|null + */ + public function getLastUpdated() + { + return $this->getDateProperty(self::LAST_UPDATED); + } +} diff --git a/src/Generated/Applications/ApplicationLicensing.php b/src/Generated/Applications/ApplicationLicensing.php new file mode 100644 index 0000000000..15bd5ee171 --- /dev/null +++ b/src/Generated/Applications/ApplicationLicensing.php @@ -0,0 +1,49 @@ +getProperty(self::SEAT_COUNT); + } + /** + * Set the seatCount. + * + * @param mixed $seatCount The value to set. + * @return self + */ + public function setSeatCount($seatCount) + { + $this->setProperty( + self::SEAT_COUNT, + $seatCount + ); + + return $this; + } +} diff --git a/src/Generated/Applications/ApplicationSettings.php b/src/Generated/Applications/ApplicationSettings.php new file mode 100644 index 0000000000..5c97cb0030 --- /dev/null +++ b/src/Generated/Applications/ApplicationSettings.php @@ -0,0 +1,84 @@ +getResourceProperty( + self::APP, + \Okta\Applications\ApplicationSettingsApplication::class, + $options + ); + } + + /** + * Set the app. + * + * @param \Okta\Applications\ApplicationSettingsApplication $app The ApplicationSettingsApplication instance. + * @return self + */ + public function setApp(\Okta\Applications\ApplicationSettingsApplication $app) + { + $this->setResourceProperty( + self::APP, + $app + ); + + return $this; + } + /** + * Get the notifications. + * + * @return \Okta\Applications\ApplicationSettingsNotifications + */ + public function getNotifications(array $options = []): \Okta\Applications\ApplicationSettingsNotifications + { + return $this->getResourceProperty( + self::NOTIFICATIONS, + \Okta\Applications\ApplicationSettingsNotifications::class, + $options + ); + } + + /** + * Set the notifications. + * + * @param \Okta\Applications\ApplicationSettingsNotifications $notifications The ApplicationSettingsNotifications instance. + * @return self + */ + public function setNotifications(\Okta\Applications\ApplicationSettingsNotifications $notifications) + { + $this->setResourceProperty( + self::NOTIFICATIONS, + $notifications + ); + + return $this; + } +} diff --git a/src/Generated/Applications/ApplicationSettingsApplication.php b/src/Generated/Applications/ApplicationSettingsApplication.php new file mode 100644 index 0000000000..9a68e7f2cc --- /dev/null +++ b/src/Generated/Applications/ApplicationSettingsApplication.php @@ -0,0 +1,24 @@ +getResourceProperty( + self::VPN, + \Okta\Applications\ApplicationSettingsNotificationsVpn::class, + $options + ); + } + + /** + * Set the vpn. + * + * @param \Okta\Applications\ApplicationSettingsNotificationsVpn $vpn The ApplicationSettingsNotificationsVpn instance. + * @return self + */ + public function setVpn(\Okta\Applications\ApplicationSettingsNotificationsVpn $vpn) + { + $this->setResourceProperty( + self::VPN, + $vpn + ); + + return $this; + } +} diff --git a/src/Generated/Applications/ApplicationSettingsNotificationsVpn.php b/src/Generated/Applications/ApplicationSettingsNotificationsVpn.php new file mode 100644 index 0000000000..8a7df15153 --- /dev/null +++ b/src/Generated/Applications/ApplicationSettingsNotificationsVpn.php @@ -0,0 +1,104 @@ +getProperty(self::HELP_URL); + } + /** + * Set the helpUrl. + * + * @param mixed $helpUrl The value to set. + * @return self + */ + public function setHelpUrl($helpUrl) + { + $this->setProperty( + self::HELP_URL, + $helpUrl + ); + + return $this; + } + /** + * Get the message. + * + * @return string + */ + public function getMessage(): string + { + return $this->getProperty(self::MESSAGE); + } + /** + * Set the message. + * + * @param mixed $message The value to set. + * @return self + */ + public function setMessage($message) + { + $this->setProperty( + self::MESSAGE, + $message + ); + + return $this; + } + /** + * Get the network. + * + * @return \Okta\Applications\ApplicationSettingsNotificationsVpnNetwork + */ + public function getNetwork(array $options = []): \Okta\Applications\ApplicationSettingsNotificationsVpnNetwork + { + return $this->getResourceProperty( + self::NETWORK, + \Okta\Applications\ApplicationSettingsNotificationsVpnNetwork::class, + $options + ); + } + + /** + * Set the network. + * + * @param \Okta\Applications\ApplicationSettingsNotificationsVpnNetwork $network The ApplicationSettingsNotificationsVpnNetwork instance. + * @return self + */ + public function setNetwork(\Okta\Applications\ApplicationSettingsNotificationsVpnNetwork $network) + { + $this->setResourceProperty( + self::NETWORK, + $network + ); + + return $this; + } +} diff --git a/src/Generated/Applications/ApplicationSettingsNotificationsVpnNetwork.php b/src/Generated/Applications/ApplicationSettingsNotificationsVpnNetwork.php new file mode 100644 index 0000000000..14d3ca48c6 --- /dev/null +++ b/src/Generated/Applications/ApplicationSettingsNotificationsVpnNetwork.php @@ -0,0 +1,99 @@ +getProperty(self::EXCLUDE); + } + /** + * Set the exclude. + * + * @param mixed $exclude The value to set. + * @return self + */ + public function setExclude($exclude) + { + $this->setProperty( + self::EXCLUDE, + $exclude + ); + + return $this; + } + /** + * Get the include. + * + * @return array + */ + public function getInclude(): array + { + return $this->getProperty(self::INCLUDE); + } + /** + * Set the include. + * + * @param mixed $include The value to set. + * @return self + */ + public function setInclude($include) + { + $this->setProperty( + self::INCLUDE, + $include + ); + + return $this; + } + /** + * Get the connection. + * + * @return string + */ + public function getConnection(): string + { + return $this->getProperty(self::CONNECTION); + } + /** + * Set the connection. + * + * @param mixed $connection The value to set. + * @return self + */ + public function setConnection($connection) + { + $this->setProperty( + self::CONNECTION, + $connection + ); + + return $this; + } +} diff --git a/src/Generated/Applications/ApplicationSignOnMode.php b/src/Generated/Applications/ApplicationSignOnMode.php new file mode 100644 index 0000000000..6c5dadd90a --- /dev/null +++ b/src/Generated/Applications/ApplicationSignOnMode.php @@ -0,0 +1,32 @@ +getResourceProperty( + self::HIDE, + \Okta\Applications\ApplicationVisibilityHide::class, + $options + ); + } + + /** + * Set the hide. + * + * @param \Okta\Applications\ApplicationVisibilityHide $hide The ApplicationVisibilityHide instance. + * @return self + */ + public function setHide(\Okta\Applications\ApplicationVisibilityHide $hide) + { + $this->setResourceProperty( + self::HIDE, + $hide + ); + + return $this; + } + /** + * Get the appLinks. + * + * @return \stdClass + */ + public function getAppLinks(): \stdClass + { + return $this->getProperty(self::APP_LINKS); + } + /** + * Set the appLinks. + * + * @param mixed $appLinks The value to set. + * @return self + */ + public function setAppLinks($appLinks) + { + $this->setProperty( + self::APP_LINKS, + $appLinks + ); + + return $this; + } + /** + * Get the autoSubmitToolbar. + * + * @return bool + */ + public function getAutoSubmitToolbar(): bool + { + return $this->getProperty(self::AUTO_SUBMIT_TOOLBAR); + } + /** + * Set the autoSubmitToolbar. + * + * @param mixed $autoSubmitToolbar The value to set. + * @return self + */ + public function setAutoSubmitToolbar($autoSubmitToolbar) + { + $this->setProperty( + self::AUTO_SUBMIT_TOOLBAR, + $autoSubmitToolbar + ); + + return $this; + } +} diff --git a/src/Generated/Applications/ApplicationVisibilityHide.php b/src/Generated/Applications/ApplicationVisibilityHide.php new file mode 100644 index 0000000000..9e2cfa6c3d --- /dev/null +++ b/src/Generated/Applications/ApplicationVisibilityHide.php @@ -0,0 +1,74 @@ +getProperty(self::I_OS); + } + /** + * Set the iOS. + * + * @param mixed $iOS The value to set. + * @return self + */ + public function setIOs($iOS) + { + $this->setProperty( + self::I_OS, + $iOS + ); + + return $this; + } + /** + * Get the web. + * + * @return bool + */ + public function getWeb(): bool + { + return $this->getProperty(self::WEB); + } + /** + * Set the web. + * + * @param mixed $web The value to set. + * @return self + */ + public function setWeb($web) + { + $this->setProperty( + self::WEB, + $web + ); + + return $this; + } +} diff --git a/src/Generated/Applications/AutoLoginApplication.php b/src/Generated/Applications/AutoLoginApplication.php new file mode 100644 index 0000000000..e03e1b0118 --- /dev/null +++ b/src/Generated/Applications/AutoLoginApplication.php @@ -0,0 +1,84 @@ +getResourceProperty( + self::SETTINGS, + \Okta\Applications\AutoLoginApplicationSettings::class, + $options + ); + } + + /** + * Set the settings. + * + * @param \Okta\Applications\ApplicationSettings $settings The AutoLoginApplicationSettings instance. + * @return self + */ + public function setSettings(\Okta\Applications\ApplicationSettings $settings) + { + $this->setResourceProperty( + self::SETTINGS, + $settings + ); + + return $this; + } + /** + * Get the credentials. + * + * @return \Okta\Applications\ApplicationCredentials + */ + public function getCredentials(array $options = []): \Okta\Applications\ApplicationCredentials + { + return $this->getResourceProperty( + self::CREDENTIALS, + \Okta\Applications\SchemeApplicationCredentials::class, + $options + ); + } + + /** + * Set the credentials. + * + * @param \Okta\Applications\ApplicationCredentials $credentials The SchemeApplicationCredentials instance. + * @return self + */ + public function setCredentials(\Okta\Applications\ApplicationCredentials $credentials) + { + $this->setResourceProperty( + self::CREDENTIALS, + $credentials + ); + + return $this; + } +} diff --git a/src/Generated/Applications/AutoLoginApplicationSettings.php b/src/Generated/Applications/AutoLoginApplicationSettings.php new file mode 100644 index 0000000000..1c966f3374 --- /dev/null +++ b/src/Generated/Applications/AutoLoginApplicationSettings.php @@ -0,0 +1,54 @@ +getResourceProperty( + self::SIGN_ON, + \Okta\Applications\AutoLoginApplicationSettingsSignOn::class, + $options + ); + } + + /** + * Set the signOn. + * + * @param \Okta\Applications\AutoLoginApplicationSettingsSignOn $signOn The AutoLoginApplicationSettingsSignOn instance. + * @return self + */ + public function setSignOn(\Okta\Applications\AutoLoginApplicationSettingsSignOn $signOn) + { + $this->setResourceProperty( + self::SIGN_ON, + $signOn + ); + + return $this; + } +} diff --git a/src/Generated/Applications/AutoLoginApplicationSettingsSignOn.php b/src/Generated/Applications/AutoLoginApplicationSettingsSignOn.php new file mode 100644 index 0000000000..aa58d1e13f --- /dev/null +++ b/src/Generated/Applications/AutoLoginApplicationSettingsSignOn.php @@ -0,0 +1,74 @@ +getProperty(self::LOGIN_URL); + } + /** + * Set the loginUrl. + * + * @param mixed $loginUrl The value to set. + * @return self + */ + public function setLoginUrl($loginUrl) + { + $this->setProperty( + self::LOGIN_URL, + $loginUrl + ); + + return $this; + } + /** + * Get the redirectUrl. + * + * @return string + */ + public function getRedirectUrl(): string + { + return $this->getProperty(self::REDIRECT_URL); + } + /** + * Set the redirectUrl. + * + * @param mixed $redirectUrl The value to set. + * @return self + */ + public function setRedirectUrl($redirectUrl) + { + $this->setProperty( + self::REDIRECT_URL, + $redirectUrl + ); + + return $this; + } +} diff --git a/src/Generated/Applications/BasicApplicationSettings.php b/src/Generated/Applications/BasicApplicationSettings.php new file mode 100644 index 0000000000..a3457812da --- /dev/null +++ b/src/Generated/Applications/BasicApplicationSettings.php @@ -0,0 +1,54 @@ +getResourceProperty( + self::APP, + \Okta\Applications\BasicApplicationSettingsApplication::class, + $options + ); + } + + /** + * Set the app. + * + * @param \Okta\Applications\ApplicationSettingsApplication $app The BasicApplicationSettingsApplication instance. + * @return self + */ + public function setApp(\Okta\Applications\ApplicationSettingsApplication $app) + { + $this->setResourceProperty( + self::APP, + $app + ); + + return $this; + } +} diff --git a/src/Generated/Applications/BasicApplicationSettingsApplication.php b/src/Generated/Applications/BasicApplicationSettingsApplication.php new file mode 100644 index 0000000000..55cd2c589b --- /dev/null +++ b/src/Generated/Applications/BasicApplicationSettingsApplication.php @@ -0,0 +1,74 @@ +getProperty(self::URL); + } + /** + * Set the url. + * + * @param mixed $url The value to set. + * @return self + */ + public function setUrl($url) + { + $this->setProperty( + self::URL, + $url + ); + + return $this; + } + /** + * Get the authURL. + * + * @return string + */ + public function getAuthUrl(): string + { + return $this->getProperty(self::AUTH_URL); + } + /** + * Set the authURL. + * + * @param mixed $authURL The value to set. + * @return self + */ + public function setAuthUrl($authURL) + { + $this->setProperty( + self::AUTH_URL, + $authURL + ); + + return $this; + } +} diff --git a/src/Generated/Applications/BasicAuthApplication.php b/src/Generated/Applications/BasicAuthApplication.php new file mode 100644 index 0000000000..e7cc13158e --- /dev/null +++ b/src/Generated/Applications/BasicAuthApplication.php @@ -0,0 +1,86 @@ +getResourceProperty( + self::SETTINGS, + \Okta\Applications\BasicApplicationSettings::class, + $options + ); + } + + /** + * Set the settings. + * + * @param \Okta\Applications\ApplicationSettings $settings The BasicApplicationSettings instance. + * @return self + */ + public function setSettings(\Okta\Applications\ApplicationSettings $settings) + { + $this->setResourceProperty( + self::SETTINGS, + $settings + ); + + return $this; + } + /** + * Get the credentials. + * + * @return \Okta\Applications\ApplicationCredentials + */ + public function getCredentials(array $options = []): \Okta\Applications\ApplicationCredentials + { + return $this->getResourceProperty( + self::CREDENTIALS, + \Okta\Applications\SchemeApplicationCredentials::class, + $options + ); + } + + /** + * Set the credentials. + * + * @param \Okta\Applications\ApplicationCredentials $credentials The SchemeApplicationCredentials instance. + * @return self + */ + public function setCredentials(\Okta\Applications\ApplicationCredentials $credentials) + { + $this->setResourceProperty( + self::CREDENTIALS, + $credentials + ); + + return $this; + } +} diff --git a/src/Generated/Applications/BookmarkApplication.php b/src/Generated/Applications/BookmarkApplication.php new file mode 100644 index 0000000000..12f4c99657 --- /dev/null +++ b/src/Generated/Applications/BookmarkApplication.php @@ -0,0 +1,56 @@ +getResourceProperty( + self::SETTINGS, + \Okta\Applications\BookmarkApplicationSettings::class, + $options + ); + } + + /** + * Set the settings. + * + * @param \Okta\Applications\ApplicationSettings $settings The BookmarkApplicationSettings instance. + * @return self + */ + public function setSettings(\Okta\Applications\ApplicationSettings $settings) + { + $this->setResourceProperty( + self::SETTINGS, + $settings + ); + + return $this; + } +} diff --git a/src/Generated/Applications/BookmarkApplicationSettings.php b/src/Generated/Applications/BookmarkApplicationSettings.php new file mode 100644 index 0000000000..ea40df96b2 --- /dev/null +++ b/src/Generated/Applications/BookmarkApplicationSettings.php @@ -0,0 +1,54 @@ +getResourceProperty( + self::APP, + \Okta\Applications\BookmarkApplicationSettingsApplication::class, + $options + ); + } + + /** + * Set the app. + * + * @param \Okta\Applications\ApplicationSettingsApplication $app The BookmarkApplicationSettingsApplication instance. + * @return self + */ + public function setApp(\Okta\Applications\ApplicationSettingsApplication $app) + { + $this->setResourceProperty( + self::APP, + $app + ); + + return $this; + } +} diff --git a/src/Generated/Applications/BookmarkApplicationSettingsApplication.php b/src/Generated/Applications/BookmarkApplicationSettingsApplication.php new file mode 100644 index 0000000000..088b148ced --- /dev/null +++ b/src/Generated/Applications/BookmarkApplicationSettingsApplication.php @@ -0,0 +1,74 @@ +getProperty(self::URL); + } + /** + * Set the url. + * + * @param mixed $url The value to set. + * @return self + */ + public function setUrl($url) + { + $this->setProperty( + self::URL, + $url + ); + + return $this; + } + /** + * Get the requestIntegration. + * + * @return bool + */ + public function getRequestIntegration(): bool + { + return $this->getProperty(self::REQUEST_INTEGRATION); + } + /** + * Set the requestIntegration. + * + * @param mixed $requestIntegration The value to set. + * @return self + */ + public function setRequestIntegration($requestIntegration) + { + $this->setProperty( + self::REQUEST_INTEGRATION, + $requestIntegration + ); + + return $this; + } +} diff --git a/src/Generated/Applications/BrowserPluginApplication.php b/src/Generated/Applications/BrowserPluginApplication.php new file mode 100644 index 0000000000..9e3c217ddb --- /dev/null +++ b/src/Generated/Applications/BrowserPluginApplication.php @@ -0,0 +1,54 @@ +getResourceProperty( + self::CREDENTIALS, + \Okta\Applications\SchemeApplicationCredentials::class, + $options + ); + } + + /** + * Set the credentials. + * + * @param \Okta\Applications\ApplicationCredentials $credentials The SchemeApplicationCredentials instance. + * @return self + */ + public function setCredentials(\Okta\Applications\ApplicationCredentials $credentials) + { + $this->setResourceProperty( + self::CREDENTIALS, + $credentials + ); + + return $this; + } +} diff --git a/src/Generated/Applications/Collection.php b/src/Generated/Applications/Collection.php new file mode 100644 index 0000000000..2f3c6c759f --- /dev/null +++ b/src/Generated/Applications/Collection.php @@ -0,0 +1,25 @@ +getProperty(self::E); + } + /** + * Get the n. + * + * @return string + */ + public function getN(): string + { + return $this->getProperty(self::N); + } + /** + * Get the alg. + * + * @return string + */ + public function getAlg(): string + { + return $this->getProperty(self::ALG); + } + /** + * Get the kid. + * + * @return string + */ + public function getKid(): string + { + return $this->getProperty(self::KID); + } + /** + * Get the kty. + * + * @return string + */ + public function getKty(): string + { + return $this->getProperty(self::KTY); + } + /** + * Get the use. + * + * @return string + */ + public function getUse(): string + { + return $this->getProperty(self::USE); + } + /** + * Get the x5c. + * + * @return array + */ + public function getX5C(): array + { + return $this->getProperty(self::X_5_C); + } + /** + * Get the x5t. + * + * @return string + */ + public function getX5T(): string + { + return $this->getProperty(self::X_5_T); + } + /** + * Get the x5u. + * + * @return string + */ + public function getX5U(): string + { + return $this->getProperty(self::X_5_U); + } + /** + * Get the status. + * + * @return string + */ + public function getStatus(): string + { + return $this->getProperty(self::STATUS); + } + /** + * Get the created. + * + * @return \Carbon\Carbon|null + */ + public function getCreated() + { + return $this->getDateProperty(self::CREATED); + } + /** + * Get the key_ops. + * + * @return array + */ + public function getKeyOps(): array + { + return $this->getProperty(self::KEY_OPS); + } + /** + * Get the x5t#S256. + * + * @return string + */ + public function getX5TS256(): string + { + return $this->getProperty(self::X_5_T_S_256); + } + /** + * Get the expiresAt. + * + * @return \Carbon\Carbon|null + */ + public function getExpiresAt() + { + return $this->getDateProperty(self::EXPIRES_AT); + } + /** + * Get the lastUpdated. + * + * @return \Carbon\Carbon|null + */ + public function getLastUpdated() + { + return $this->getDateProperty(self::LAST_UPDATED); + } +} diff --git a/src/Generated/Applications/OAuthApplicationCredentials.php b/src/Generated/Applications/OAuthApplicationCredentials.php new file mode 100644 index 0000000000..25832c149e --- /dev/null +++ b/src/Generated/Applications/OAuthApplicationCredentials.php @@ -0,0 +1,54 @@ +getResourceProperty( + self::OAUTH_CLIENT, + \Okta\Applications\ApplicationCredentialsOAuthClient::class, + $options + ); + } + + /** + * Set the oauthClient. + * + * @param \Okta\Applications\ApplicationCredentialsOAuthClient $oauthClient The ApplicationCredentialsOAuthClient instance. + * @return self + */ + public function setOauthClient(\Okta\Applications\ApplicationCredentialsOAuthClient $oauthClient) + { + $this->setResourceProperty( + self::OAUTH_CLIENT, + $oauthClient + ); + + return $this; + } +} diff --git a/src/Generated/Applications/OAuthEndpointAuthenticationMethod.php b/src/Generated/Applications/OAuthEndpointAuthenticationMethod.php new file mode 100644 index 0000000000..28ed0a6167 --- /dev/null +++ b/src/Generated/Applications/OAuthEndpointAuthenticationMethod.php @@ -0,0 +1,28 @@ +getResourceProperty( + self::SETTINGS, + \Okta\Applications\OpenIdConnectApplicationSettings::class, + $options + ); + } + + /** + * Set the settings. + * + * @param \Okta\Applications\ApplicationSettings $settings The OpenIdConnectApplicationSettings instance. + * @return self + */ + public function setSettings(\Okta\Applications\ApplicationSettings $settings) + { + $this->setResourceProperty( + self::SETTINGS, + $settings + ); + + return $this; + } + /** + * Get the credentials. + * + * @return \Okta\Applications\ApplicationCredentials + */ + public function getCredentials(array $options = []): \Okta\Applications\ApplicationCredentials + { + return $this->getResourceProperty( + self::CREDENTIALS, + \Okta\Applications\OAuthApplicationCredentials::class, + $options + ); + } + + /** + * Set the credentials. + * + * @param \Okta\Applications\ApplicationCredentials $credentials The OAuthApplicationCredentials instance. + * @return self + */ + public function setCredentials(\Okta\Applications\ApplicationCredentials $credentials) + { + $this->setResourceProperty( + self::CREDENTIALS, + $credentials + ); + + return $this; + } +} diff --git a/src/Generated/Applications/OpenIdConnectApplicationConsentMethod.php b/src/Generated/Applications/OpenIdConnectApplicationConsentMethod.php new file mode 100644 index 0000000000..c50354e2e5 --- /dev/null +++ b/src/Generated/Applications/OpenIdConnectApplicationConsentMethod.php @@ -0,0 +1,26 @@ +getResourceProperty( + self::OAUTH_CLIENT, + \Okta\Applications\OpenIdConnectApplicationSettingsClient::class, + $options + ); + } + + /** + * Set the oauthClient. + * + * @param \Okta\Applications\OpenIdConnectApplicationSettingsClient $oauthClient The OpenIdConnectApplicationSettingsClient instance. + * @return self + */ + public function setOauthClient(\Okta\Applications\OpenIdConnectApplicationSettingsClient $oauthClient) + { + $this->setResourceProperty( + self::OAUTH_CLIENT, + $oauthClient + ); + + return $this; + } +} diff --git a/src/Generated/Applications/OpenIdConnectApplicationSettingsClient.php b/src/Generated/Applications/OpenIdConnectApplicationSettingsClient.php new file mode 100644 index 0000000000..78781c526e --- /dev/null +++ b/src/Generated/Applications/OpenIdConnectApplicationSettingsClient.php @@ -0,0 +1,249 @@ +getProperty(self::TOS_URI); + } + /** + * Set the tos_uri. + * + * @param mixed $tos_uri The value to set. + * @return self + */ + public function setTosUri($tos_uri) + { + $this->setProperty( + self::TOS_URI, + $tos_uri + ); + + return $this; + } + /** + * Get the logo_uri. + * + * @return string + */ + public function getLogoUri(): string + { + return $this->getProperty(self::LOGO_URI); + } + /** + * Set the logo_uri. + * + * @param mixed $logo_uri The value to set. + * @return self + */ + public function setLogoUri($logo_uri) + { + $this->setProperty( + self::LOGO_URI, + $logo_uri + ); + + return $this; + } + /** + * Get the client_uri. + * + * @return string + */ + public function getClientUri(): string + { + return $this->getProperty(self::CLIENT_URI); + } + /** + * Set the client_uri. + * + * @param mixed $client_uri The value to set. + * @return self + */ + public function setClientUri($client_uri) + { + $this->setProperty( + self::CLIENT_URI, + $client_uri + ); + + return $this; + } + /** + * Get the policy_uri. + * + * @return string + */ + public function getPolicyUri(): string + { + return $this->getProperty(self::POLICY_URI); + } + /** + * Set the policy_uri. + * + * @param mixed $policy_uri The value to set. + * @return self + */ + public function setPolicyUri($policy_uri) + { + $this->setProperty( + self::POLICY_URI, + $policy_uri + ); + + return $this; + } + /** + * Get the grant_types. + * + * @return array + */ + public function getGrantTypes(): array + { + return $this->getProperty(self::GRANT_TYPES); + } + /** + * Set the grant_types. + * + * @param mixed $grant_types The value to set. + * @return self + */ + public function setGrantTypes($grant_types) + { + $this->setProperty( + self::GRANT_TYPES, + $grant_types + ); + + return $this; + } + /** + * Get the redirect_uris. + * + * @return array + */ + public function getRedirectUris(): array + { + return $this->getProperty(self::REDIRECT_URIS); + } + /** + * Set the redirect_uris. + * + * @param mixed $redirect_uris The value to set. + * @return self + */ + public function setRedirectUris($redirect_uris) + { + $this->setProperty( + self::REDIRECT_URIS, + $redirect_uris + ); + + return $this; + } + /** + * Get the consent_method. + * + * @return string + */ + public function getConsentMethod(): string + { + return $this->getProperty(self::CONSENT_METHOD); + } + /** + * Set the consent_method. + * + * @param mixed $consent_method The value to set. + * @return self + */ + public function setConsentMethod($consent_method) + { + $this->setProperty( + self::CONSENT_METHOD, + $consent_method + ); + + return $this; + } + /** + * Get the response_types. + * + * @return array + */ + public function getResponseTypes(): array + { + return $this->getProperty(self::RESPONSE_TYPES); + } + /** + * Set the response_types. + * + * @param mixed $response_types The value to set. + * @return self + */ + public function setResponseTypes($response_types) + { + $this->setProperty( + self::RESPONSE_TYPES, + $response_types + ); + + return $this; + } + /** + * Get the application_type. + * + * @return string + */ + public function getApplicationType(): string + { + return $this->getProperty(self::APPLICATION_TYPE); + } + /** + * Set the application_type. + * + * @param mixed $application_type The value to set. + * @return self + */ + public function setApplicationType($application_type) + { + $this->setProperty( + self::APPLICATION_TYPE, + $application_type + ); + + return $this; + } +} diff --git a/src/Generated/Applications/OpenIdConnectApplicationType.php b/src/Generated/Applications/OpenIdConnectApplicationType.php new file mode 100644 index 0000000000..df2289768e --- /dev/null +++ b/src/Generated/Applications/OpenIdConnectApplicationType.php @@ -0,0 +1,28 @@ +getResourceProperty( + self::SETTINGS, + \Okta\Applications\SamlApplicationSettings::class, + $options + ); + } + + /** + * Set the settings. + * + * @param \Okta\Applications\ApplicationSettings $settings The SamlApplicationSettings instance. + * @return self + */ + public function setSettings(\Okta\Applications\ApplicationSettings $settings) + { + $this->setResourceProperty( + self::SETTINGS, + $settings + ); + + return $this; + } +} diff --git a/src/Generated/Applications/SamlApplicationSettings.php b/src/Generated/Applications/SamlApplicationSettings.php new file mode 100644 index 0000000000..3f05965953 --- /dev/null +++ b/src/Generated/Applications/SamlApplicationSettings.php @@ -0,0 +1,54 @@ +getResourceProperty( + self::SIGN_ON, + \Okta\Applications\SamlApplicationSettingsSignOn::class, + $options + ); + } + + /** + * Set the signOn. + * + * @param \Okta\Applications\SamlApplicationSettingsSignOn $signOn The SamlApplicationSettingsSignOn instance. + * @return self + */ + public function setSignOn(\Okta\Applications\SamlApplicationSettingsSignOn $signOn) + { + $this->setResourceProperty( + self::SIGN_ON, + $signOn + ); + + return $this; + } +} diff --git a/src/Generated/Applications/SamlApplicationSettingsSignOn.php b/src/Generated/Applications/SamlApplicationSettingsSignOn.php new file mode 100644 index 0000000000..32d6357181 --- /dev/null +++ b/src/Generated/Applications/SamlApplicationSettingsSignOn.php @@ -0,0 +1,549 @@ +getProperty(self::AUDIENCE); + } + /** + * Set the audience. + * + * @param mixed $audience The value to set. + * @return self + */ + public function setAudience($audience) + { + $this->setProperty( + self::AUDIENCE, + $audience + ); + + return $this; + } + /** + * Get the spIssuer. + * + * @return string + */ + public function getSpIssuer(): string + { + return $this->getProperty(self::SP_ISSUER); + } + /** + * Set the spIssuer. + * + * @param mixed $spIssuer The value to set. + * @return self + */ + public function setSpIssuer($spIssuer) + { + $this->setProperty( + self::SP_ISSUER, + $spIssuer + ); + + return $this; + } + /** + * Get the idpIssuer. + * + * @return string + */ + public function getIdpIssuer(): string + { + return $this->getProperty(self::IDP_ISSUER); + } + /** + * Set the idpIssuer. + * + * @param mixed $idpIssuer The value to set. + * @return self + */ + public function setIdpIssuer($idpIssuer) + { + $this->setProperty( + self::IDP_ISSUER, + $idpIssuer + ); + + return $this; + } + /** + * Get the recipient. + * + * @return string + */ + public function getRecipient(): string + { + return $this->getProperty(self::RECIPIENT); + } + /** + * Set the recipient. + * + * @param mixed $recipient The value to set. + * @return self + */ + public function setRecipient($recipient) + { + $this->setProperty( + self::RECIPIENT, + $recipient + ); + + return $this; + } + /** + * Get the ssoAcsUrl. + * + * @return string + */ + public function getSsoAcsUrl(): string + { + return $this->getProperty(self::SSO_ACS_URL); + } + /** + * Set the ssoAcsUrl. + * + * @param mixed $ssoAcsUrl The value to set. + * @return self + */ + public function setSsoAcsUrl($ssoAcsUrl) + { + $this->setProperty( + self::SSO_ACS_URL, + $ssoAcsUrl + ); + + return $this; + } + /** + * Get the destination. + * + * @return string + */ + public function getDestination(): string + { + return $this->getProperty(self::DESTINATION); + } + /** + * Set the destination. + * + * @param mixed $destination The value to set. + * @return self + */ + public function setDestination($destination) + { + $this->setProperty( + self::DESTINATION, + $destination + ); + + return $this; + } + /** + * Get the responseSigned. + * + * @return bool + */ + public function getResponseSigned(): bool + { + return $this->getProperty(self::RESPONSE_SIGNED); + } + /** + * Set the responseSigned. + * + * @param mixed $responseSigned The value to set. + * @return self + */ + public function setResponseSigned($responseSigned) + { + $this->setProperty( + self::RESPONSE_SIGNED, + $responseSigned + ); + + return $this; + } + /** + * Get the assertionSigned. + * + * @return bool + */ + public function getAssertionSigned(): bool + { + return $this->getProperty(self::ASSERTION_SIGNED); + } + /** + * Set the assertionSigned. + * + * @param mixed $assertionSigned The value to set. + * @return self + */ + public function setAssertionSigned($assertionSigned) + { + $this->setProperty( + self::ASSERTION_SIGNED, + $assertionSigned + ); + + return $this; + } + /** + * Get the digestAlgorithm. + * + * @return string + */ + public function getDigestAlgorithm(): string + { + return $this->getProperty(self::DIGEST_ALGORITHM); + } + /** + * Set the digestAlgorithm. + * + * @param mixed $digestAlgorithm The value to set. + * @return self + */ + public function setDigestAlgorithm($digestAlgorithm) + { + $this->setProperty( + self::DIGEST_ALGORITHM, + $digestAlgorithm + ); + + return $this; + } + /** + * Get the honorForceAuthn. + * + * @return bool + */ + public function getHonorForceAuthn(): bool + { + return $this->getProperty(self::HONOR_FORCE_AUTHN); + } + /** + * Set the honorForceAuthn. + * + * @param mixed $honorForceAuthn The value to set. + * @return self + */ + public function setHonorForceAuthn($honorForceAuthn) + { + $this->setProperty( + self::HONOR_FORCE_AUTHN, + $honorForceAuthn + ); + + return $this; + } + /** + * Get the audienceOverride. + * + * @return string + */ + public function getAudienceOverride(): string + { + return $this->getProperty(self::AUDIENCE_OVERRIDE); + } + /** + * Set the audienceOverride. + * + * @param mixed $audienceOverride The value to set. + * @return self + */ + public function setAudienceOverride($audienceOverride) + { + $this->setProperty( + self::AUDIENCE_OVERRIDE, + $audienceOverride + ); + + return $this; + } + /** + * Get the defaultRelayState. + * + * @return string + */ + public function getDefaultRelayState(): string + { + return $this->getProperty(self::DEFAULT_RELAY_STATE); + } + /** + * Set the defaultRelayState. + * + * @param mixed $defaultRelayState The value to set. + * @return self + */ + public function setDefaultRelayState($defaultRelayState) + { + $this->setProperty( + self::DEFAULT_RELAY_STATE, + $defaultRelayState + ); + + return $this; + } + /** + * Get the recipientOverride. + * + * @return string + */ + public function getRecipientOverride(): string + { + return $this->getProperty(self::RECIPIENT_OVERRIDE); + } + /** + * Set the recipientOverride. + * + * @param mixed $recipientOverride The value to set. + * @return self + */ + public function setRecipientOverride($recipientOverride) + { + $this->setProperty( + self::RECIPIENT_OVERRIDE, + $recipientOverride + ); + + return $this; + } + /** + * Get the requestCompressed. + * + * @return bool + */ + public function getRequestCompressed(): bool + { + return $this->getProperty(self::REQUEST_COMPRESSED); + } + /** + * Set the requestCompressed. + * + * @param mixed $requestCompressed The value to set. + * @return self + */ + public function setRequestCompressed($requestCompressed) + { + $this->setProperty( + self::REQUEST_COMPRESSED, + $requestCompressed + ); + + return $this; + } + /** + * Get the ssoAcsUrlOverride. + * + * @return string + */ + public function getSsoAcsUrlOverride(): string + { + return $this->getProperty(self::SSO_ACS_URL_OVERRIDE); + } + /** + * Set the ssoAcsUrlOverride. + * + * @param mixed $ssoAcsUrlOverride The value to set. + * @return self + */ + public function setSsoAcsUrlOverride($ssoAcsUrlOverride) + { + $this->setProperty( + self::SSO_ACS_URL_OVERRIDE, + $ssoAcsUrlOverride + ); + + return $this; + } + /** + * Get the signatureAlgorithm. + * + * @return string + */ + public function getSignatureAlgorithm(): string + { + return $this->getProperty(self::SIGNATURE_ALGORITHM); + } + /** + * Set the signatureAlgorithm. + * + * @param mixed $signatureAlgorithm The value to set. + * @return self + */ + public function setSignatureAlgorithm($signatureAlgorithm) + { + $this->setProperty( + self::SIGNATURE_ALGORITHM, + $signatureAlgorithm + ); + + return $this; + } + /** + * Get the attributeStatements. + * + * @return array + */ + public function getAttributeStatements(): array + { + return $this->getProperty(self::ATTRIBUTE_STATEMENTS); + } + /** + * Set the attributeStatements. + * + * @param mixed $attributeStatements The value to set. + * @return self + */ + public function setAttributeStatements($attributeStatements) + { + $this->setProperty( + self::ATTRIBUTE_STATEMENTS, + $attributeStatements + ); + + return $this; + } + /** + * Get the destinationOverride. + * + * @return string + */ + public function getDestinationOverride(): string + { + return $this->getProperty(self::DESTINATION_OVERRIDE); + } + /** + * Set the destinationOverride. + * + * @param mixed $destinationOverride The value to set. + * @return self + */ + public function setDestinationOverride($destinationOverride) + { + $this->setProperty( + self::DESTINATION_OVERRIDE, + $destinationOverride + ); + + return $this; + } + /** + * Get the subjectNameIdFormat. + * + * @return string + */ + public function getSubjectNameIdFormat(): string + { + return $this->getProperty(self::SUBJECT_NAME_ID_FORMAT); + } + /** + * Set the subjectNameIdFormat. + * + * @param mixed $subjectNameIdFormat The value to set. + * @return self + */ + public function setSubjectNameIdFormat($subjectNameIdFormat) + { + $this->setProperty( + self::SUBJECT_NAME_ID_FORMAT, + $subjectNameIdFormat + ); + + return $this; + } + /** + * Get the authnContextClassRef. + * + * @return string + */ + public function getAuthnContextClassRef(): string + { + return $this->getProperty(self::AUTHN_CONTEXT_CLASS_REF); + } + /** + * Set the authnContextClassRef. + * + * @param mixed $authnContextClassRef The value to set. + * @return self + */ + public function setAuthnContextClassRef($authnContextClassRef) + { + $this->setProperty( + self::AUTHN_CONTEXT_CLASS_REF, + $authnContextClassRef + ); + + return $this; + } + /** + * Get the subjectNameIdTemplate. + * + * @return string + */ + public function getSubjectNameIdTemplate(): string + { + return $this->getProperty(self::SUBJECT_NAME_ID_TEMPLATE); + } + /** + * Set the subjectNameIdTemplate. + * + * @param mixed $subjectNameIdTemplate The value to set. + * @return self + */ + public function setSubjectNameIdTemplate($subjectNameIdTemplate) + { + $this->setProperty( + self::SUBJECT_NAME_ID_TEMPLATE, + $subjectNameIdTemplate + ); + + return $this; + } +} diff --git a/src/Generated/Applications/SamlAttributeStatement.php b/src/Generated/Applications/SamlAttributeStatement.php new file mode 100644 index 0000000000..4f303ef18c --- /dev/null +++ b/src/Generated/Applications/SamlAttributeStatement.php @@ -0,0 +1,124 @@ +getProperty(self::NAME); + } + /** + * Set the name. + * + * @param mixed $name The value to set. + * @return self + */ + public function setName($name) + { + $this->setProperty( + self::NAME, + $name + ); + + return $this; + } + /** + * Get the type. + * + * @return string + */ + public function getType(): string + { + return $this->getProperty(self::TYPE); + } + /** + * Set the type. + * + * @param mixed $type The value to set. + * @return self + */ + public function setType($type) + { + $this->setProperty( + self::TYPE, + $type + ); + + return $this; + } + /** + * Get the values. + * + * @return array + */ + public function getValues(): array + { + return $this->getProperty(self::VALUES); + } + /** + * Set the values. + * + * @param mixed $values The value to set. + * @return self + */ + public function setValues($values) + { + $this->setProperty( + self::VALUES, + $values + ); + + return $this; + } + /** + * Get the namespace. + * + * @return string + */ + public function getNamespace(): string + { + return $this->getProperty(self::NAMESPACE); + } + /** + * Set the namespace. + * + * @param mixed $namespace The value to set. + * @return self + */ + public function setNamespace($namespace) + { + $this->setProperty( + self::NAMESPACE, + $namespace + ); + + return $this; + } +} diff --git a/src/Generated/Applications/SchemeApplicationCredentials.php b/src/Generated/Applications/SchemeApplicationCredentials.php new file mode 100644 index 0000000000..a1f4aa3307 --- /dev/null +++ b/src/Generated/Applications/SchemeApplicationCredentials.php @@ -0,0 +1,159 @@ +getProperty(self::SCHEME); + } + /** + * Set the scheme. + * + * @param mixed $scheme The value to set. + * @return self + */ + public function setScheme($scheme) + { + $this->setProperty( + self::SCHEME, + $scheme + ); + + return $this; + } + /** + * Get the signing. + * + * @return \Okta\Applications\ApplicationCredentialsSigning + */ + public function getSigning(array $options = []): \Okta\Applications\ApplicationCredentialsSigning + { + return $this->getResourceProperty( + self::SIGNING, + \Okta\Applications\ApplicationCredentialsSigning::class, + $options + ); + } + + /** + * Set the signing. + * + * @param \Okta\Applications\ApplicationCredentialsSigning $signing The ApplicationCredentialsSigning instance. + * @return self + */ + public function setSigning(\Okta\Applications\ApplicationCredentialsSigning $signing) + { + $this->setResourceProperty( + self::SIGNING, + $signing + ); + + return $this; + } + /** + * Get the password. + * + * @return \Okta\Users\PasswordCredential + */ + public function getPassword(array $options = []): \Okta\Users\PasswordCredential + { + return $this->getResourceProperty( + self::PASSWORD, + \Okta\Users\PasswordCredential::class, + $options + ); + } + + /** + * Set the password. + * + * @param \Okta\Users\PasswordCredential $password The PasswordCredential instance. + * @return self + */ + public function setPassword(\Okta\Users\PasswordCredential $password) + { + $this->setResourceProperty( + self::PASSWORD, + $password + ); + + return $this; + } + /** + * Get the userName. + * + * @return string + */ + public function getUserName(): string + { + return $this->getProperty(self::USER_NAME); + } + /** + * Set the userName. + * + * @param mixed $userName The value to set. + * @return self + */ + public function setUserName($userName) + { + $this->setProperty( + self::USER_NAME, + $userName + ); + + return $this; + } + /** + * Get the revealPassword. + * + * @return bool + */ + public function getRevealPassword(): bool + { + return $this->getProperty(self::REVEAL_PASSWORD); + } + /** + * Set the revealPassword. + * + * @param mixed $revealPassword The value to set. + * @return self + */ + public function setRevealPassword($revealPassword) + { + $this->setProperty( + self::REVEAL_PASSWORD, + $revealPassword + ); + + return $this; + } +} diff --git a/src/Generated/Applications/SecurePasswordStoreApplication.php b/src/Generated/Applications/SecurePasswordStoreApplication.php new file mode 100644 index 0000000000..8b147c9ed7 --- /dev/null +++ b/src/Generated/Applications/SecurePasswordStoreApplication.php @@ -0,0 +1,86 @@ +getResourceProperty( + self::SETTINGS, + \Okta\Applications\SecurePasswordStoreApplicationSettings::class, + $options + ); + } + + /** + * Set the settings. + * + * @param \Okta\Applications\ApplicationSettings $settings The SecurePasswordStoreApplicationSettings instance. + * @return self + */ + public function setSettings(\Okta\Applications\ApplicationSettings $settings) + { + $this->setResourceProperty( + self::SETTINGS, + $settings + ); + + return $this; + } + /** + * Get the credentials. + * + * @return \Okta\Applications\ApplicationCredentials + */ + public function getCredentials(array $options = []): \Okta\Applications\ApplicationCredentials + { + return $this->getResourceProperty( + self::CREDENTIALS, + \Okta\Applications\SchemeApplicationCredentials::class, + $options + ); + } + + /** + * Set the credentials. + * + * @param \Okta\Applications\ApplicationCredentials $credentials The SchemeApplicationCredentials instance. + * @return self + */ + public function setCredentials(\Okta\Applications\ApplicationCredentials $credentials) + { + $this->setResourceProperty( + self::CREDENTIALS, + $credentials + ); + + return $this; + } +} diff --git a/src/Generated/Applications/SecurePasswordStoreApplicationSettings.php b/src/Generated/Applications/SecurePasswordStoreApplicationSettings.php new file mode 100644 index 0000000000..f725c0bb8e --- /dev/null +++ b/src/Generated/Applications/SecurePasswordStoreApplicationSettings.php @@ -0,0 +1,54 @@ +getResourceProperty( + self::APP, + \Okta\Applications\SecurePasswordStoreApplicationSettingsApplication::class, + $options + ); + } + + /** + * Set the app. + * + * @param \Okta\Applications\ApplicationSettingsApplication $app The SecurePasswordStoreApplicationSettingsApplication instance. + * @return self + */ + public function setApp(\Okta\Applications\ApplicationSettingsApplication $app) + { + $this->setResourceProperty( + self::APP, + $app + ); + + return $this; + } +} diff --git a/src/Generated/Applications/SecurePasswordStoreApplicationSettingsApplication.php b/src/Generated/Applications/SecurePasswordStoreApplicationSettingsApplication.php new file mode 100644 index 0000000000..974af7b9ce --- /dev/null +++ b/src/Generated/Applications/SecurePasswordStoreApplicationSettingsApplication.php @@ -0,0 +1,249 @@ +getProperty(self::URL); + } + /** + * Set the url. + * + * @param mixed $url The value to set. + * @return self + */ + public function setUrl($url) + { + $this->setProperty( + self::URL, + $url + ); + + return $this; + } + /** + * Get the passwordField. + * + * @return string + */ + public function getPasswordField(): string + { + return $this->getProperty(self::PASSWORD_FIELD); + } + /** + * Set the passwordField. + * + * @param mixed $passwordField The value to set. + * @return self + */ + public function setPasswordField($passwordField) + { + $this->setProperty( + self::PASSWORD_FIELD, + $passwordField + ); + + return $this; + } + /** + * Get the usernameField. + * + * @return string + */ + public function getUsernameField(): string + { + return $this->getProperty(self::USERNAME_FIELD); + } + /** + * Set the usernameField. + * + * @param mixed $usernameField The value to set. + * @return self + */ + public function setUsernameField($usernameField) + { + $this->setProperty( + self::USERNAME_FIELD, + $usernameField + ); + + return $this; + } + /** + * Get the optionalField1. + * + * @return string + */ + public function getOptionalField1(): string + { + return $this->getProperty(self::OPTIONAL_FIELD_1); + } + /** + * Set the optionalField1. + * + * @param mixed $optionalField1 The value to set. + * @return self + */ + public function setOptionalField1($optionalField1) + { + $this->setProperty( + self::OPTIONAL_FIELD_1, + $optionalField1 + ); + + return $this; + } + /** + * Get the optionalField2. + * + * @return string + */ + public function getOptionalField2(): string + { + return $this->getProperty(self::OPTIONAL_FIELD_2); + } + /** + * Set the optionalField2. + * + * @param mixed $optionalField2 The value to set. + * @return self + */ + public function setOptionalField2($optionalField2) + { + $this->setProperty( + self::OPTIONAL_FIELD_2, + $optionalField2 + ); + + return $this; + } + /** + * Get the optionalField3. + * + * @return string + */ + public function getOptionalField3(): string + { + return $this->getProperty(self::OPTIONAL_FIELD_3); + } + /** + * Set the optionalField3. + * + * @param mixed $optionalField3 The value to set. + * @return self + */ + public function setOptionalField3($optionalField3) + { + $this->setProperty( + self::OPTIONAL_FIELD_3, + $optionalField3 + ); + + return $this; + } + /** + * Get the optionalField1Value. + * + * @return string + */ + public function getOptionalField1Value(): string + { + return $this->getProperty(self::OPTIONAL_FIELD_1_VALUE); + } + /** + * Set the optionalField1Value. + * + * @param mixed $optionalField1Value The value to set. + * @return self + */ + public function setOptionalField1Value($optionalField1Value) + { + $this->setProperty( + self::OPTIONAL_FIELD_1_VALUE, + $optionalField1Value + ); + + return $this; + } + /** + * Get the optionalField2Value. + * + * @return string + */ + public function getOptionalField2Value(): string + { + return $this->getProperty(self::OPTIONAL_FIELD_2_VALUE); + } + /** + * Set the optionalField2Value. + * + * @param mixed $optionalField2Value The value to set. + * @return self + */ + public function setOptionalField2Value($optionalField2Value) + { + $this->setProperty( + self::OPTIONAL_FIELD_2_VALUE, + $optionalField2Value + ); + + return $this; + } + /** + * Get the optionalField3Value. + * + * @return string + */ + public function getOptionalField3Value(): string + { + return $this->getProperty(self::OPTIONAL_FIELD_3_VALUE); + } + /** + * Set the optionalField3Value. + * + * @param mixed $optionalField3Value The value to set. + * @return self + */ + public function setOptionalField3Value($optionalField3Value) + { + $this->setProperty( + self::OPTIONAL_FIELD_3_VALUE, + $optionalField3Value + ); + + return $this; + } +} diff --git a/src/Generated/Applications/SwaApplication.php b/src/Generated/Applications/SwaApplication.php new file mode 100644 index 0000000000..20b8c4e5fe --- /dev/null +++ b/src/Generated/Applications/SwaApplication.php @@ -0,0 +1,56 @@ +getResourceProperty( + self::SETTINGS, + \Okta\Applications\SwaApplicationSettings::class, + $options + ); + } + + /** + * Set the settings. + * + * @param \Okta\Applications\ApplicationSettings $settings The SwaApplicationSettings instance. + * @return self + */ + public function setSettings(\Okta\Applications\ApplicationSettings $settings) + { + $this->setResourceProperty( + self::SETTINGS, + $settings + ); + + return $this; + } +} diff --git a/src/Generated/Applications/SwaApplicationSettings.php b/src/Generated/Applications/SwaApplicationSettings.php new file mode 100644 index 0000000000..f57d6894ac --- /dev/null +++ b/src/Generated/Applications/SwaApplicationSettings.php @@ -0,0 +1,54 @@ +getResourceProperty( + self::APP, + \Okta\Applications\SwaApplicationSettingsApplication::class, + $options + ); + } + + /** + * Set the app. + * + * @param \Okta\Applications\ApplicationSettingsApplication $app The SwaApplicationSettingsApplication instance. + * @return self + */ + public function setApp(\Okta\Applications\ApplicationSettingsApplication $app) + { + $this->setResourceProperty( + self::APP, + $app + ); + + return $this; + } +} diff --git a/src/Generated/Applications/SwaApplicationSettingsApplication.php b/src/Generated/Applications/SwaApplicationSettingsApplication.php new file mode 100644 index 0000000000..52cade17e5 --- /dev/null +++ b/src/Generated/Applications/SwaApplicationSettingsApplication.php @@ -0,0 +1,149 @@ +getProperty(self::URL); + } + /** + * Set the url. + * + * @param mixed $url The value to set. + * @return self + */ + public function setUrl($url) + { + $this->setProperty( + self::URL, + $url + ); + + return $this; + } + /** + * Get the buttonField. + * + * @return string + */ + public function getButtonField(): string + { + return $this->getProperty(self::BUTTON_FIELD); + } + /** + * Set the buttonField. + * + * @param mixed $buttonField The value to set. + * @return self + */ + public function setButtonField($buttonField) + { + $this->setProperty( + self::BUTTON_FIELD, + $buttonField + ); + + return $this; + } + /** + * Get the loginUrlRegex. + * + * @return string + */ + public function getLoginUrlRegex(): string + { + return $this->getProperty(self::LOGIN_URL_REGEX); + } + /** + * Set the loginUrlRegex. + * + * @param mixed $loginUrlRegex The value to set. + * @return self + */ + public function setLoginUrlRegex($loginUrlRegex) + { + $this->setProperty( + self::LOGIN_URL_REGEX, + $loginUrlRegex + ); + + return $this; + } + /** + * Get the passwordField. + * + * @return string + */ + public function getPasswordField(): string + { + return $this->getProperty(self::PASSWORD_FIELD); + } + /** + * Set the passwordField. + * + * @param mixed $passwordField The value to set. + * @return self + */ + public function setPasswordField($passwordField) + { + $this->setProperty( + self::PASSWORD_FIELD, + $passwordField + ); + + return $this; + } + /** + * Get the usernameField. + * + * @return string + */ + public function getUsernameField(): string + { + return $this->getProperty(self::USERNAME_FIELD); + } + /** + * Set the usernameField. + * + * @param mixed $usernameField The value to set. + * @return self + */ + public function setUsernameField($usernameField) + { + $this->setProperty( + self::USERNAME_FIELD, + $usernameField + ); + + return $this; + } +} diff --git a/src/Generated/Applications/SwaThreeFieldApplication.php b/src/Generated/Applications/SwaThreeFieldApplication.php new file mode 100644 index 0000000000..be6a72fc7a --- /dev/null +++ b/src/Generated/Applications/SwaThreeFieldApplication.php @@ -0,0 +1,56 @@ +getResourceProperty( + self::SETTINGS, + \Okta\Applications\SwaThreeFieldApplicationSettings::class, + $options + ); + } + + /** + * Set the settings. + * + * @param \Okta\Applications\ApplicationSettings $settings The SwaThreeFieldApplicationSettings instance. + * @return self + */ + public function setSettings(\Okta\Applications\ApplicationSettings $settings) + { + $this->setResourceProperty( + self::SETTINGS, + $settings + ); + + return $this; + } +} diff --git a/src/Generated/Applications/SwaThreeFieldApplicationSettings.php b/src/Generated/Applications/SwaThreeFieldApplicationSettings.php new file mode 100644 index 0000000000..c1e29ec754 --- /dev/null +++ b/src/Generated/Applications/SwaThreeFieldApplicationSettings.php @@ -0,0 +1,54 @@ +getResourceProperty( + self::APP, + \Okta\Applications\SwaThreeFieldApplicationSettingsApplication::class, + $options + ); + } + + /** + * Set the app. + * + * @param \Okta\Applications\ApplicationSettingsApplication $app The SwaThreeFieldApplicationSettingsApplication instance. + * @return self + */ + public function setApp(\Okta\Applications\ApplicationSettingsApplication $app) + { + $this->setResourceProperty( + self::APP, + $app + ); + + return $this; + } +} diff --git a/src/Generated/Applications/SwaThreeFieldApplicationSettingsApplication.php b/src/Generated/Applications/SwaThreeFieldApplicationSettingsApplication.php new file mode 100644 index 0000000000..1d536ecac9 --- /dev/null +++ b/src/Generated/Applications/SwaThreeFieldApplicationSettingsApplication.php @@ -0,0 +1,199 @@ +getProperty(self::TARGET_URL); + } + /** + * Set the targetUrl. + * + * @param mixed $targetUrl The value to set. + * @return self + */ + public function setTargetUrl($targetUrl) + { + $this->setProperty( + self::TARGET_URL, + $targetUrl + ); + + return $this; + } + /** + * Get the loginUrlRegex. + * + * @return string + */ + public function getLoginUrlRegex(): string + { + return $this->getProperty(self::LOGIN_URL_REGEX); + } + /** + * Set the loginUrlRegex. + * + * @param mixed $loginUrlRegex The value to set. + * @return self + */ + public function setLoginUrlRegex($loginUrlRegex) + { + $this->setProperty( + self::LOGIN_URL_REGEX, + $loginUrlRegex + ); + + return $this; + } + /** + * Get the buttonSelector. + * + * @return string + */ + public function getButtonSelector(): string + { + return $this->getProperty(self::BUTTON_SELECTOR); + } + /** + * Set the buttonSelector. + * + * @param mixed $buttonSelector The value to set. + * @return self + */ + public function setButtonSelector($buttonSelector) + { + $this->setProperty( + self::BUTTON_SELECTOR, + $buttonSelector + ); + + return $this; + } + /** + * Get the extraFieldValue. + * + * @return string + */ + public function getExtraFieldValue(): string + { + return $this->getProperty(self::EXTRA_FIELD_VALUE); + } + /** + * Set the extraFieldValue. + * + * @param mixed $extraFieldValue The value to set. + * @return self + */ + public function setExtraFieldValue($extraFieldValue) + { + $this->setProperty( + self::EXTRA_FIELD_VALUE, + $extraFieldValue + ); + + return $this; + } + /** + * Get the passwordSelector. + * + * @return string + */ + public function getPasswordSelector(): string + { + return $this->getProperty(self::PASSWORD_SELECTOR); + } + /** + * Set the passwordSelector. + * + * @param mixed $passwordSelector The value to set. + * @return self + */ + public function setPasswordSelector($passwordSelector) + { + $this->setProperty( + self::PASSWORD_SELECTOR, + $passwordSelector + ); + + return $this; + } + /** + * Get the userNameSelector. + * + * @return string + */ + public function getUserNameSelector(): string + { + return $this->getProperty(self::USER_NAME_SELECTOR); + } + /** + * Set the userNameSelector. + * + * @param mixed $userNameSelector The value to set. + * @return self + */ + public function setUserNameSelector($userNameSelector) + { + $this->setProperty( + self::USER_NAME_SELECTOR, + $userNameSelector + ); + + return $this; + } + /** + * Get the extraFieldSelector. + * + * @return string + */ + public function getExtraFieldSelector(): string + { + return $this->getProperty(self::EXTRA_FIELD_SELECTOR); + } + /** + * Set the extraFieldSelector. + * + * @param mixed $extraFieldSelector The value to set. + * @return self + */ + public function setExtraFieldSelector($extraFieldSelector) + { + $this->setProperty( + self::EXTRA_FIELD_SELECTOR, + $extraFieldSelector + ); + + return $this; + } +} diff --git a/src/Generated/Applications/WsFederationApplication.php b/src/Generated/Applications/WsFederationApplication.php new file mode 100644 index 0000000000..450271ddfe --- /dev/null +++ b/src/Generated/Applications/WsFederationApplication.php @@ -0,0 +1,56 @@ +getResourceProperty( + self::SETTINGS, + \Okta\Applications\WsFederationApplicationSettings::class, + $options + ); + } + + /** + * Set the settings. + * + * @param \Okta\Applications\ApplicationSettings $settings The WsFederationApplicationSettings instance. + * @return self + */ + public function setSettings(\Okta\Applications\ApplicationSettings $settings) + { + $this->setResourceProperty( + self::SETTINGS, + $settings + ); + + return $this; + } +} diff --git a/src/Generated/Applications/WsFederationApplicationSettings.php b/src/Generated/Applications/WsFederationApplicationSettings.php new file mode 100644 index 0000000000..94d6788161 --- /dev/null +++ b/src/Generated/Applications/WsFederationApplicationSettings.php @@ -0,0 +1,54 @@ +getResourceProperty( + self::APP, + \Okta\Applications\WsFederationApplicationSettingsApplication::class, + $options + ); + } + + /** + * Set the app. + * + * @param \Okta\Applications\ApplicationSettingsApplication $app The WsFederationApplicationSettingsApplication instance. + * @return self + */ + public function setApp(\Okta\Applications\ApplicationSettingsApplication $app) + { + $this->setResourceProperty( + self::APP, + $app + ); + + return $this; + } +} diff --git a/src/Generated/Applications/WsFederationApplicationSettingsApplication.php b/src/Generated/Applications/WsFederationApplicationSettingsApplication.php new file mode 100644 index 0000000000..5209756483 --- /dev/null +++ b/src/Generated/Applications/WsFederationApplicationSettingsApplication.php @@ -0,0 +1,324 @@ +getProperty(self::REALM); + } + /** + * Set the realm. + * + * @param mixed $realm The value to set. + * @return self + */ + public function setRealm($realm) + { + $this->setProperty( + self::REALM, + $realm + ); + + return $this; + } + /** + * Get the siteURL. + * + * @return string + */ + public function getSiteUrl(): string + { + return $this->getProperty(self::SITE_URL); + } + /** + * Set the siteURL. + * + * @param mixed $siteURL The value to set. + * @return self + */ + public function setSiteUrl($siteURL) + { + $this->setProperty( + self::SITE_URL, + $siteURL + ); + + return $this; + } + /** + * Get the groupName. + * + * @return string + */ + public function getGroupName(): string + { + return $this->getProperty(self::GROUP_NAME); + } + /** + * Set the groupName. + * + * @param mixed $groupName The value to set. + * @return self + */ + public function setGroupName($groupName) + { + $this->setProperty( + self::GROUP_NAME, + $groupName + ); + + return $this; + } + /** + * Get the wReplyURL. + * + * @return string + */ + public function getWReplyUrl(): string + { + return $this->getProperty(self::W_REPLY_URL); + } + /** + * Set the wReplyURL. + * + * @param mixed $wReplyURL The value to set. + * @return self + */ + public function setWReplyUrl($wReplyURL) + { + $this->setProperty( + self::W_REPLY_URL, + $wReplyURL + ); + + return $this; + } + /** + * Get the groupFilter. + * + * @return string + */ + public function getGroupFilter(): string + { + return $this->getProperty(self::GROUP_FILTER); + } + /** + * Set the groupFilter. + * + * @param mixed $groupFilter The value to set. + * @return self + */ + public function setGroupFilter($groupFilter) + { + $this->setProperty( + self::GROUP_FILTER, + $groupFilter + ); + + return $this; + } + /** + * Get the nameIDFormat. + * + * @return string + */ + public function getNameIdFormat(): string + { + return $this->getProperty(self::NAME_ID_FORMAT); + } + /** + * Set the nameIDFormat. + * + * @param mixed $nameIDFormat The value to set. + * @return self + */ + public function setNameIdFormat($nameIDFormat) + { + $this->setProperty( + self::NAME_ID_FORMAT, + $nameIDFormat + ); + + return $this; + } + /** + * Get the wReplyOverride. + * + * @return bool + */ + public function getWReplyOverride(): bool + { + return $this->getProperty(self::W_REPLY_OVERRIDE); + } + /** + * Set the wReplyOverride. + * + * @param mixed $wReplyOverride The value to set. + * @return self + */ + public function setWReplyOverride($wReplyOverride) + { + $this->setProperty( + self::W_REPLY_OVERRIDE, + $wReplyOverride + ); + + return $this; + } + /** + * Get the groupValueFormat. + * + * @return string + */ + public function getGroupValueFormat(): string + { + return $this->getProperty(self::GROUP_VALUE_FORMAT); + } + /** + * Set the groupValueFormat. + * + * @param mixed $groupValueFormat The value to set. + * @return self + */ + public function setGroupValueFormat($groupValueFormat) + { + $this->setProperty( + self::GROUP_VALUE_FORMAT, + $groupValueFormat + ); + + return $this; + } + /** + * Get the usernameAttribute. + * + * @return string + */ + public function getUsernameAttribute(): string + { + return $this->getProperty(self::USERNAME_ATTRIBUTE); + } + /** + * Set the usernameAttribute. + * + * @param mixed $usernameAttribute The value to set. + * @return self + */ + public function setUsernameAttribute($usernameAttribute) + { + $this->setProperty( + self::USERNAME_ATTRIBUTE, + $usernameAttribute + ); + + return $this; + } + /** + * Get the attributeStatements. + * + * @return string + */ + public function getAttributeStatements(): string + { + return $this->getProperty(self::ATTRIBUTE_STATEMENTS); + } + /** + * Set the attributeStatements. + * + * @param mixed $attributeStatements The value to set. + * @return self + */ + public function setAttributeStatements($attributeStatements) + { + $this->setProperty( + self::ATTRIBUTE_STATEMENTS, + $attributeStatements + ); + + return $this; + } + /** + * Get the audienceRestriction. + * + * @return string + */ + public function getAudienceRestriction(): string + { + return $this->getProperty(self::AUDIENCE_RESTRICTION); + } + /** + * Set the audienceRestriction. + * + * @param mixed $audienceRestriction The value to set. + * @return self + */ + public function setAudienceRestriction($audienceRestriction) + { + $this->setProperty( + self::AUDIENCE_RESTRICTION, + $audienceRestriction + ); + + return $this; + } + /** + * Get the authnContextClassRef. + * + * @return string + */ + public function getAuthnContextClassRef(): string + { + return $this->getProperty(self::AUTHN_CONTEXT_CLASS_REF); + } + /** + * Set the authnContextClassRef. + * + * @param mixed $authnContextClassRef The value to set. + * @return self + */ + public function setAuthnContextClassRef($authnContextClassRef) + { + $this->setProperty( + self::AUTHN_CONTEXT_CLASS_REF, + $authnContextClassRef + ); + + return $this; + } +} diff --git a/src/Generated/GroupRules/Collection.php b/src/Generated/GroupRules/Collection.php new file mode 100644 index 0000000000..da2c344f88 --- /dev/null +++ b/src/Generated/GroupRules/Collection.php @@ -0,0 +1,25 @@ +getDataStore() + ->saveResource( + "/groups", + $this, + \Okta\GroupRules\GroupRule::class + ); + } + public function delete() + { + return \Okta\Client::getInstance() + ->getDataStore() + ->deleteResource( + "/groups", + $this + ); + } + /** + * Get the id. + * + * @return string + */ + public function getId(): string + { + return $this->getProperty(self::ID); + } + /** + * Get the name. + * + * @return string + */ + public function getName(): string + { + return $this->getProperty(self::NAME); + } + /** + * Set the name. + * + * @param mixed $name The value to set. + * @return self + */ + public function setName($name) + { + $this->setProperty( + self::NAME, + $name + ); + + return $this; + } + /** + * Get the type. + * + * @return string + */ + public function getType(): string + { + return $this->getProperty(self::TYPE); + } + /** + * Set the type. + * + * @param mixed $type The value to set. + * @return self + */ + public function setType($type) + { + $this->setProperty( + self::TYPE, + $type + ); + + return $this; + } + /** + * Get the status. + * + * @return string + */ + public function getStatus(): string + { + return $this->getProperty(self::STATUS); + } + /** + * Get the actions. + * + * @return \Okta\GroupRules\GroupRuleAction + */ + public function getActions(array $options = []): \Okta\GroupRules\GroupRuleAction + { + return $this->getResourceProperty( + self::ACTIONS, + \Okta\GroupRules\GroupRuleAction::class, + $options + ); + } + + /** + * Set the actions. + * + * @param \Okta\GroupRules\GroupRuleAction $actions The GroupRuleAction instance. + * @return self + */ + public function setActions(\Okta\GroupRules\GroupRuleAction $actions) + { + $this->setResourceProperty( + self::ACTIONS, + $actions + ); + + return $this; + } + /** + * Get the created. + * + * @return \Carbon\Carbon|null + */ + public function getCreated() + { + return $this->getDateProperty(self::CREATED); + } + /** + * Get the conditions. + * + * @return \Okta\GroupRules\GroupRuleConditions + */ + public function getConditions(array $options = []): \Okta\GroupRules\GroupRuleConditions + { + return $this->getResourceProperty( + self::CONDITIONS, + \Okta\GroupRules\GroupRuleConditions::class, + $options + ); + } + + /** + * Set the conditions. + * + * @param \Okta\GroupRules\GroupRuleConditions $conditions The GroupRuleConditions instance. + * @return self + */ + public function setConditions(\Okta\GroupRules\GroupRuleConditions $conditions) + { + $this->setResourceProperty( + self::CONDITIONS, + $conditions + ); + + return $this; + } + /** + * Get the lastUpdated. + * + * @return \Carbon\Carbon|null + */ + public function getLastUpdated() + { + return $this->getDateProperty(self::LAST_UPDATED); + } + + + /** + * Activates a specific group rule by id from your organization + * + * + * @return mixed|null + */ + public function activate() + { + $uri = "/api/v1/groups/rules/{$this->getId()}/lifecycle/activate"; + $uri = $this->getDataStore()->buildUri( + $this->getDataStore()->getOrganizationUrl() . $uri + ); + $body = $this + ->getDataStore() + ->executeRequest('POST', $uri); + + return $body; + } + + + /** + * Deactivates a specific group rule by id from your organization + * + * + * @return mixed|null + */ + public function deactivate() + { + $uri = "/api/v1/groups/rules/{$this->getId()}/lifecycle/deactivate"; + $uri = $this->getDataStore()->buildUri( + $this->getDataStore()->getOrganizationUrl() . $uri + ); + $body = $this + ->getDataStore() + ->executeRequest('POST', $uri); + + return $body; + } +} diff --git a/src/Generated/GroupRules/GroupRuleAction.php b/src/Generated/GroupRules/GroupRuleAction.php new file mode 100644 index 0000000000..4597415325 --- /dev/null +++ b/src/Generated/GroupRules/GroupRuleAction.php @@ -0,0 +1,54 @@ +getResourceProperty( + self::ASSIGN_USER_TO_GROUPS, + \Okta\GroupRules\GroupRuleGroupAssignment::class, + $options + ); + } + + /** + * Set the assignUserToGroups. + * + * @param \Okta\GroupRules\GroupRuleGroupAssignment $assignUserToGroups The GroupRuleGroupAssignment instance. + * @return self + */ + public function setAssignUserToGroups(\Okta\GroupRules\GroupRuleGroupAssignment $assignUserToGroups) + { + $this->setResourceProperty( + self::ASSIGN_USER_TO_GROUPS, + $assignUserToGroups + ); + + return $this; + } +} diff --git a/src/Generated/GroupRules/GroupRuleConditions.php b/src/Generated/GroupRules/GroupRuleConditions.php new file mode 100644 index 0000000000..9f0a59149d --- /dev/null +++ b/src/Generated/GroupRules/GroupRuleConditions.php @@ -0,0 +1,84 @@ +getResourceProperty( + self::PEOPLE, + \Okta\GroupRules\GroupRulePeopleCondition::class, + $options + ); + } + + /** + * Set the people. + * + * @param \Okta\GroupRules\GroupRulePeopleCondition $people The GroupRulePeopleCondition instance. + * @return self + */ + public function setPeople(\Okta\GroupRules\GroupRulePeopleCondition $people) + { + $this->setResourceProperty( + self::PEOPLE, + $people + ); + + return $this; + } + /** + * Get the expression. + * + * @return \Okta\GroupRules\GroupRuleExpression + */ + public function getExpression(array $options = []): \Okta\GroupRules\GroupRuleExpression + { + return $this->getResourceProperty( + self::EXPRESSION, + \Okta\GroupRules\GroupRuleExpression::class, + $options + ); + } + + /** + * Set the expression. + * + * @param \Okta\GroupRules\GroupRuleExpression $expression The GroupRuleExpression instance. + * @return self + */ + public function setExpression(\Okta\GroupRules\GroupRuleExpression $expression) + { + $this->setResourceProperty( + self::EXPRESSION, + $expression + ); + + return $this; + } +} diff --git a/src/Generated/GroupRules/GroupRuleExpression.php b/src/Generated/GroupRules/GroupRuleExpression.php new file mode 100644 index 0000000000..08185f34ef --- /dev/null +++ b/src/Generated/GroupRules/GroupRuleExpression.php @@ -0,0 +1,74 @@ +getProperty(self::TYPE); + } + /** + * Set the type. + * + * @param mixed $type The value to set. + * @return self + */ + public function setType($type) + { + $this->setProperty( + self::TYPE, + $type + ); + + return $this; + } + /** + * Get the value. + * + * @return string + */ + public function getValue(): string + { + return $this->getProperty(self::VALUE); + } + /** + * Set the value. + * + * @param mixed $value The value to set. + * @return self + */ + public function setValue($value) + { + $this->setProperty( + self::VALUE, + $value + ); + + return $this; + } +} diff --git a/src/Generated/GroupRules/GroupRuleGroupAssignment.php b/src/Generated/GroupRules/GroupRuleGroupAssignment.php new file mode 100644 index 0000000000..c2c015af43 --- /dev/null +++ b/src/Generated/GroupRules/GroupRuleGroupAssignment.php @@ -0,0 +1,49 @@ +getProperty(self::GROUP_IDS); + } + /** + * Set the groupIds. + * + * @param mixed $groupIds The value to set. + * @return self + */ + public function setGroupIds($groupIds) + { + $this->setProperty( + self::GROUP_IDS, + $groupIds + ); + + return $this; + } +} diff --git a/src/Generated/GroupRules/GroupRuleGroupCondition.php b/src/Generated/GroupRules/GroupRuleGroupCondition.php new file mode 100644 index 0000000000..66b6c13f01 --- /dev/null +++ b/src/Generated/GroupRules/GroupRuleGroupCondition.php @@ -0,0 +1,74 @@ +getProperty(self::EXCLUDE); + } + /** + * Set the exclude. + * + * @param mixed $exclude The value to set. + * @return self + */ + public function setExclude($exclude) + { + $this->setProperty( + self::EXCLUDE, + $exclude + ); + + return $this; + } + /** + * Get the include. + * + * @return array + */ + public function getInclude(): array + { + return $this->getProperty(self::INCLUDE); + } + /** + * Set the include. + * + * @param mixed $include The value to set. + * @return self + */ + public function setInclude($include) + { + $this->setProperty( + self::INCLUDE, + $include + ); + + return $this; + } +} diff --git a/src/Generated/GroupRules/GroupRulePeopleCondition.php b/src/Generated/GroupRules/GroupRulePeopleCondition.php new file mode 100644 index 0000000000..4438b0a21a --- /dev/null +++ b/src/Generated/GroupRules/GroupRulePeopleCondition.php @@ -0,0 +1,84 @@ +getResourceProperty( + self::USERS, + \Okta\GroupRules\GroupRuleUserCondition::class, + $options + ); + } + + /** + * Set the users. + * + * @param \Okta\GroupRules\GroupRuleUserCondition $users The GroupRuleUserCondition instance. + * @return self + */ + public function setUsers(\Okta\GroupRules\GroupRuleUserCondition $users) + { + $this->setResourceProperty( + self::USERS, + $users + ); + + return $this; + } + /** + * Get the groups. + * + * @return \Okta\GroupRules\GroupRuleGroupCondition + */ + public function getGroups(array $options = []): \Okta\GroupRules\GroupRuleGroupCondition + { + return $this->getResourceProperty( + self::GROUPS, + \Okta\GroupRules\GroupRuleGroupCondition::class, + $options + ); + } + + /** + * Set the groups. + * + * @param \Okta\GroupRules\GroupRuleGroupCondition $groups The GroupRuleGroupCondition instance. + * @return self + */ + public function setGroups(\Okta\GroupRules\GroupRuleGroupCondition $groups) + { + $this->setResourceProperty( + self::GROUPS, + $groups + ); + + return $this; + } +} diff --git a/src/Generated/GroupRules/GroupRuleStatus.php b/src/Generated/GroupRules/GroupRuleStatus.php new file mode 100644 index 0000000000..3046381363 --- /dev/null +++ b/src/Generated/GroupRules/GroupRuleStatus.php @@ -0,0 +1,27 @@ +getProperty(self::EXCLUDE); + } + /** + * Set the exclude. + * + * @param mixed $exclude The value to set. + * @return self + */ + public function setExclude($exclude) + { + $this->setProperty( + self::EXCLUDE, + $exclude + ); + + return $this; + } + /** + * Get the include. + * + * @return array + */ + public function getInclude(): array + { + return $this->getProperty(self::INCLUDE); + } + /** + * Set the include. + * + * @param mixed $include The value to set. + * @return self + */ + public function setInclude($include) + { + $this->setProperty( + self::INCLUDE, + $include + ); + + return $this; + } +} diff --git a/src/Generated/Groups/Collection.php b/src/Generated/Groups/Collection.php new file mode 100644 index 0000000000..4a66f19d48 --- /dev/null +++ b/src/Generated/Groups/Collection.php @@ -0,0 +1,25 @@ +getDataStore() + ->saveResource( + "/groups", + $this, + \Okta\Groups\Group::class + ); + } + public function delete() + { + return \Okta\Client::getInstance() + ->getDataStore() + ->deleteResource( + "/groups", + $this + ); + } + /** + * Get the id. + * + * @return string + */ + public function getId(): string + { + return $this->getProperty(self::ID); + } + /** + * Get the type. + * + * @return string + */ + public function getType(): string + { + return $this->getProperty(self::TYPE); + } + /** + * Get the _links. + * + * @return \stdClass + */ + public function getLinks(): \stdClass + { + return $this->getProperty(self::LINKS); + } + /** + * Get the created. + * + * @return \Carbon\Carbon|null + */ + public function getCreated() + { + return $this->getDateProperty(self::CREATED); + } + /** + * Get the profile. + * + * @return \Okta\Groups\GroupProfile + */ + public function getProfile(array $options = []): \Okta\Groups\GroupProfile + { + return $this->getResourceProperty( + self::PROFILE, + \Okta\Groups\GroupProfile::class, + $options + ); + } + + /** + * Set the profile. + * + * @param \Okta\Groups\GroupProfile $profile The GroupProfile instance. + * @return self + */ + public function setProfile(\Okta\Groups\GroupProfile $profile) + { + $this->setResourceProperty( + self::PROFILE, + $profile + ); + + return $this; + } + /** + * Get the _embedded. + * + * @return \stdClass + */ + public function getEmbedded(): \stdClass + { + return $this->getProperty(self::EMBEDDED); + } + /** + * Get the lastUpdated. + * + * @return \Carbon\Carbon|null + */ + public function getLastUpdated() + { + return $this->getDateProperty(self::LAST_UPDATED); + } + /** + * Get the objectClass. + * + * @return array + */ + public function getObjectClass(): array + { + return $this->getProperty(self::OBJECT_CLASS); + } + /** + * Get the lastMembershipUpdated. + * + * @return \Carbon\Carbon|null + */ + public function getLastMembershipUpdated() + { + return $this->getDateProperty(self::LAST_MEMBERSHIP_UPDATED); + } + + + /** + * Removes a [user](users.html#user-model) from a group with `OKTA_GROUP` type. + * + * + * @return mixed|null + */ + public function removeUser($userId) + { + $uri = "/api/v1/groups/{$this->getId()}/users/{$userId}"; + $uri = $this->getDataStore()->buildUri( + $this->getDataStore()->getOrganizationUrl() . $uri + ); + $body = $this + ->getDataStore() + ->executeRequest('DELETE', $uri); + + return $body; + } + + /** + * Get the User object. + * + * @param array $options The options for the request. + * @return \Okta\Users\Collection + */ + public function getUsers(array $options = []): \Okta\Users\Collection + { + + return $this + ->getDataStore() + ->getCollection( + "/api/v1/groups/{$this->getId()}/users", + \Okta\Users\User::class, + \Okta\Users\Collection::class, + $options + ); + } +} diff --git a/src/Generated/Groups/GroupProfile.php b/src/Generated/Groups/GroupProfile.php new file mode 100644 index 0000000000..d3b858608d --- /dev/null +++ b/src/Generated/Groups/GroupProfile.php @@ -0,0 +1,74 @@ +getProperty(self::NAME); + } + /** + * Set the name. + * + * @param mixed $name The value to set. + * @return self + */ + public function setName($name) + { + $this->setProperty( + self::NAME, + $name + ); + + return $this; + } + /** + * Get the description. + * + * @return string + */ + public function getDescription(): string + { + return $this->getProperty(self::DESCRIPTION); + } + /** + * Set the description. + * + * @param mixed $description The value to set. + * @return self + */ + public function setDescription($description) + { + $this->setProperty( + self::DESCRIPTION, + $description + ); + + return $this; + } +} diff --git a/src/Generated/Sessions/Collection.php b/src/Generated/Sessions/Collection.php new file mode 100644 index 0000000000..39ad3c16de --- /dev/null +++ b/src/Generated/Sessions/Collection.php @@ -0,0 +1,25 @@ +getProperty(self::SESSION_TOKEN); + } + /** + * Set the sessionToken. + * + * @param mixed $sessionToken The value to set. + * @return self + */ + public function setSessionToken($sessionToken) + { + $this->setProperty( + self::SESSION_TOKEN, + $sessionToken + ); + + return $this; + } +} diff --git a/src/Generated/Sessions/Session.php b/src/Generated/Sessions/Session.php new file mode 100644 index 0000000000..f3f4437b3e --- /dev/null +++ b/src/Generated/Sessions/Session.php @@ -0,0 +1,178 @@ +getDataStore() + ->getResource( + $query, + \Okta\Sessions\Session::class, + "/sessions" + ); + } + public function delete() + { + return \Okta\Client::getInstance() + ->getDataStore() + ->deleteResource( + "/sessions", + $this + ); + } + /** + * Get the id. + * + * @return string + */ + public function getId(): string + { + return $this->getProperty(self::ID); + } + /** + * Get the amr. + * + * @return array + */ + public function getAmr(): array + { + return $this->getProperty(self::AMR); + } + /** + * Get the idp. + * + * @return \Okta\Sessions\SessionIdentityProvider + */ + public function getIdp(array $options = []): \Okta\Sessions\SessionIdentityProvider + { + return $this->getResourceProperty( + self::IDP, + \Okta\Sessions\SessionIdentityProvider::class, + $options + ); + } + + /** + * Get the login. + * + * @return string + */ + public function getLogin(): string + { + return $this->getProperty(self::LOGIN); + } + /** + * Get the _links. + * + * @return \stdClass + */ + public function getLinks(): \stdClass + { + return $this->getProperty(self::LINKS); + } + /** + * Get the status. + * + * @return string + */ + public function getStatus(): string + { + return $this->getProperty(self::STATUS); + } + /** + * Get the userId. + * + * @return string + */ + public function getUserId(): string + { + return $this->getProperty(self::USER_ID); + } + /** + * Get the createdAt. + * + * @return \Carbon\Carbon|null + */ + public function getCreatedAt() + { + return $this->getDateProperty(self::CREATED_AT); + } + /** + * Get the expiresAt. + * + * @return \Carbon\Carbon|null + */ + public function getExpiresAt() + { + return $this->getDateProperty(self::EXPIRES_AT); + } + /** + * Get the lastFactorVerification. + * + * @return \Carbon\Carbon|null + */ + public function getLastFactorVerification() + { + return $this->getDateProperty(self::LAST_FACTOR_VERIFICATION); + } + /** + * Get the lastPasswordVerification. + * + * @return \Carbon\Carbon|null + */ + public function getLastPasswordVerification() + { + return $this->getDateProperty(self::LAST_PASSWORD_VERIFICATION); + } + + + /** + * + * + * + * @return mixed|null + */ + public function refresh() + { + $uri = "/api/v1/sessions/{$this->getId()}/lifecycle/refresh"; + $uri = $this->getDataStore()->buildUri( + $this->getDataStore()->getOrganizationUrl() . $uri + ); + $body = $this + ->getDataStore() + ->executeRequest('POST', $uri); + + return new \Okta\Sessions\Session(null, $body); + } +} diff --git a/src/Generated/Sessions/SessionAuthenticationMethod.php b/src/Generated/Sessions/SessionAuthenticationMethod.php new file mode 100644 index 0000000000..63fde7a68d --- /dev/null +++ b/src/Generated/Sessions/SessionAuthenticationMethod.php @@ -0,0 +1,34 @@ +getProperty(self::ID); + } + /** + * Get the type. + * + * @return string + */ + public function getType(): string + { + return $this->getProperty(self::TYPE); + } +} diff --git a/src/Generated/Sessions/SessionIdentityProviderType.php b/src/Generated/Sessions/SessionIdentityProviderType.php new file mode 100644 index 0000000000..4a0491eae6 --- /dev/null +++ b/src/Generated/Sessions/SessionIdentityProviderType.php @@ -0,0 +1,29 @@ +getResourceProperty( + self::PROFILE, + \Okta\UserFactors\CallFactorProfile::class, + $options + ); + } + + /** + * Set the profile. + * + * @param \Okta\UserFactors\FactorProfile $profile The CallFactorProfile instance. + * @return self + */ + public function setProfile(\Okta\UserFactors\FactorProfile $profile) + { + $this->setResourceProperty( + self::PROFILE, + $profile + ); + + return $this; + } +} diff --git a/src/Generated/UserFactors/CallFactorProfile.php b/src/Generated/UserFactors/CallFactorProfile.php new file mode 100644 index 0000000000..7608e0af45 --- /dev/null +++ b/src/Generated/UserFactors/CallFactorProfile.php @@ -0,0 +1,74 @@ +getProperty(self::PHONE_NUMBER); + } + /** + * Set the phoneNumber. + * + * @param mixed $phoneNumber The value to set. + * @return self + */ + public function setPhoneNumber($phoneNumber) + { + $this->setProperty( + self::PHONE_NUMBER, + $phoneNumber + ); + + return $this; + } + /** + * Get the phoneExtension. + * + * @return string + */ + public function getPhoneExtension(): string + { + return $this->getProperty(self::PHONE_EXTENSION); + } + /** + * Set the phoneExtension. + * + * @param mixed $phoneExtension The value to set. + * @return self + */ + public function setPhoneExtension($phoneExtension) + { + $this->setProperty( + self::PHONE_EXTENSION, + $phoneExtension + ); + + return $this; + } +} diff --git a/src/Generated/UserFactors/Collection.php b/src/Generated/UserFactors/Collection.php new file mode 100644 index 0000000000..cbfc1b9779 --- /dev/null +++ b/src/Generated/UserFactors/Collection.php @@ -0,0 +1,25 @@ +getResourceProperty( + self::PROFILE, + \Okta\UserFactors\EmailFactorProfile::class, + $options + ); + } + + /** + * Set the profile. + * + * @param \Okta\UserFactors\FactorProfile $profile The EmailFactorProfile instance. + * @return self + */ + public function setProfile(\Okta\UserFactors\FactorProfile $profile) + { + $this->setResourceProperty( + self::PROFILE, + $profile + ); + + return $this; + } +} diff --git a/src/Generated/UserFactors/EmailFactorProfile.php b/src/Generated/UserFactors/EmailFactorProfile.php new file mode 100644 index 0000000000..ed55ac0b6d --- /dev/null +++ b/src/Generated/UserFactors/EmailFactorProfile.php @@ -0,0 +1,49 @@ +getProperty(self::EMAIL); + } + /** + * Set the email. + * + * @param mixed $email The value to set. + * @return self + */ + public function setEmail($email) + { + $this->setProperty( + self::EMAIL, + $email + ); + + return $this; + } +} diff --git a/src/Generated/UserFactors/Factor.php b/src/Generated/UserFactors/Factor.php new file mode 100644 index 0000000000..8c67cfb76e --- /dev/null +++ b/src/Generated/UserFactors/Factor.php @@ -0,0 +1,350 @@ +getProperty(self::ID); + } + /** + * Get the _links. + * + * @return \stdClass + */ + public function getLinks(): \stdClass + { + return $this->getProperty(self::LINKS); + } + /** + * Get the device. + * + * @return string + */ + public function getDevice(): string + { + return $this->getProperty(self::DEVICE); + } + /** + * Set the device. + * + * @param mixed $device The value to set. + * @return self + */ + public function setDevice($device) + { + $this->setProperty( + self::DEVICE, + $device + ); + + return $this; + } + /** + * Get the status. + * + * @return string + */ + public function getStatus(): string + { + return $this->getProperty(self::STATUS); + } + /** + * Get the userId. + * + * @return string + */ + public function getUserId(): string + { + return $this->getProperty(self::USER_ID); + } + /** + * Set the userId. + * + * @param mixed $userId The value to set. + * @return self + */ + public function setUserId($userId) + { + $this->setProperty( + self::USER_ID, + $userId + ); + + return $this; + } + /** + * Get the verify. + * + * @return \Okta\UserFactors\VerifyFactorRequest + */ + public function getVerify(array $options = []): \Okta\UserFactors\VerifyFactorRequest + { + return $this->getResourceProperty( + self::VERIFY, + \Okta\UserFactors\VerifyFactorRequest::class, + $options + ); + } + + /** + * Set the verify. + * + * @param \Okta\UserFactors\VerifyFactorRequest $verify The VerifyFactorRequest instance. + * @return self + */ + public function setVerify(\Okta\UserFactors\VerifyFactorRequest $verify) + { + $this->setResourceProperty( + self::VERIFY, + $verify + ); + + return $this; + } + /** + * Get the profile. + * + * @return \Okta\UserFactors\FactorProfile + */ + public function getProfile(array $options = []): \Okta\UserFactors\FactorProfile + { + return $this->getResourceProperty( + self::PROFILE, + \Okta\UserFactors\FactorProfile::class, + $options + ); + } + + /** + * Set the profile. + * + * @param \Okta\UserFactors\FactorProfile $profile The FactorProfile instance. + * @return self + */ + public function setProfile(\Okta\UserFactors\FactorProfile $profile) + { + $this->setResourceProperty( + self::PROFILE, + $profile + ); + + return $this; + } + /** + * Get the provider. + * + * @return string + */ + public function getProvider(): string + { + return $this->getProperty(self::PROVIDER); + } + /** + * Set the provider. + * + * @param mixed $provider The value to set. + * @return self + */ + public function setProvider($provider) + { + $this->setProperty( + self::PROVIDER, + $provider + ); + + return $this; + } + /** + * Get the _embedded. + * + * @return \stdClass + */ + public function getEmbedded(): \stdClass + { + return $this->getProperty(self::EMBEDDED); + } + /** + * Get the sessionId. + * + * @return string + */ + public function getSessionId(): string + { + return $this->getProperty(self::SESSION_ID); + } + /** + * Set the sessionId. + * + * @param mixed $sessionId The value to set. + * @return self + */ + public function setSessionId($sessionId) + { + $this->setProperty( + self::SESSION_ID, + $sessionId + ); + + return $this; + } + /** + * Get the deviceType. + * + * @return string + */ + public function getDeviceType(): string + { + return $this->getProperty(self::DEVICE_TYPE); + } + /** + * Get the factorType. + * + * @return string + */ + public function getFactorType(): string + { + return $this->getProperty(self::FACTOR_TYPE); + } + /** + * Set the factorType. + * + * @param mixed $factorType The value to set. + * @return self + */ + public function setFactorType($factorType) + { + $this->setProperty( + self::FACTOR_TYPE, + $factorType + ); + + return $this; + } + /** + * Get the mfaStateTokenId. + * + * @return string + */ + public function getMfaStateTokenId(): string + { + return $this->getProperty(self::MFA_STATE_TOKEN_ID); + } + /** + * Set the mfaStateTokenId. + * + * @param mixed $mfaStateTokenId The value to set. + * @return self + */ + public function setMfaStateTokenId($mfaStateTokenId) + { + $this->setProperty( + self::MFA_STATE_TOKEN_ID, + $mfaStateTokenId + ); + + return $this; + } + /** + * Get the rechallengeExistingFactor. + * + * @return bool + */ + public function getRechallengeExistingFactor(): bool + { + return $this->getProperty(self::RECHALLENGE_EXISTING_FACTOR); + } + /** + * Set the rechallengeExistingFactor. + * + * @param mixed $rechallengeExistingFactor The value to set. + * @return self + */ + public function setRechallengeExistingFactor($rechallengeExistingFactor) + { + $this->setProperty( + self::RECHALLENGE_EXISTING_FACTOR, + $rechallengeExistingFactor + ); + + return $this; + } + + + /** + * The `sms` and `token:software:totp` [factor types](#factor-type) require activation to complete the enrollment process. + * + * + * @return mixed|null + */ + public function activate(VerifyFactorRequest $verifyFactorRequest) + { + $uri = "/api/v1/users/{$this->get()}/factors/{$this->getId()}/lifecycle/activate"; + $uri = $this->getDataStore()->buildUri( + $this->getDataStore()->getOrganizationUrl() . $uri + ); + $body = $this + ->getDataStore() + ->executeRequest('POST', $uri, $verifyFactorRequest); + + $response = new \Okta\UserFactors\Factor(null, $body); + return $response->convertFromGenericFactor(); + } + + + /** + * Verifies an OTP for a `token` or `token:hardware` factor + * + * + * @return mixed|null + */ + public function verify(VerifyFactorRequest $verifyFactorRequest) + { + $uri = "/api/v1/users/{$this->get()}/factors/{$this->getId()}/verify"; + $uri = $this->getDataStore()->buildUri( + $this->getDataStore()->getOrganizationUrl() . $uri + ); + $body = $this + ->getDataStore() + ->executeRequest('POST', $uri, $verifyFactorRequest); + + return new \Okta\UserFactors\VerifyFactorResponse(null, $body); + } +} diff --git a/src/Generated/UserFactors/FactorProfile.php b/src/Generated/UserFactors/FactorProfile.php new file mode 100644 index 0000000000..3ff7b53b7c --- /dev/null +++ b/src/Generated/UserFactors/FactorProfile.php @@ -0,0 +1,24 @@ +getResourceProperty( + self::PROFILE, + \Okta\UserFactors\HardwareFactorProfile::class, + $options + ); + } + + /** + * Set the profile. + * + * @param \Okta\UserFactors\FactorProfile $profile The HardwareFactorProfile instance. + * @return self + */ + public function setProfile(\Okta\UserFactors\FactorProfile $profile) + { + $this->setResourceProperty( + self::PROFILE, + $profile + ); + + return $this; + } +} diff --git a/src/Generated/UserFactors/HardwareFactorProfile.php b/src/Generated/UserFactors/HardwareFactorProfile.php new file mode 100644 index 0000000000..568c3360d3 --- /dev/null +++ b/src/Generated/UserFactors/HardwareFactorProfile.php @@ -0,0 +1,49 @@ +getProperty(self::CREDENTIAL_ID); + } + /** + * Set the credentialId. + * + * @param mixed $credentialId The value to set. + * @return self + */ + public function setCredentialId($credentialId) + { + $this->setProperty( + self::CREDENTIAL_ID, + $credentialId + ); + + return $this; + } +} diff --git a/src/Generated/UserFactors/PushFactor.php b/src/Generated/UserFactors/PushFactor.php new file mode 100644 index 0000000000..ea36d8866e --- /dev/null +++ b/src/Generated/UserFactors/PushFactor.php @@ -0,0 +1,54 @@ +getResourceProperty( + self::PROFILE, + \Okta\UserFactors\PushFactorProfile::class, + $options + ); + } + + /** + * Set the profile. + * + * @param \Okta\UserFactors\FactorProfile $profile The PushFactorProfile instance. + * @return self + */ + public function setProfile(\Okta\UserFactors\FactorProfile $profile) + { + $this->setResourceProperty( + self::PROFILE, + $profile + ); + + return $this; + } +} diff --git a/src/Generated/UserFactors/PushFactorProfile.php b/src/Generated/UserFactors/PushFactorProfile.php new file mode 100644 index 0000000000..51bcc6c8e8 --- /dev/null +++ b/src/Generated/UserFactors/PushFactorProfile.php @@ -0,0 +1,119 @@ +getProperty(self::NAME); + } + /** + * Set the name. + * + * @param mixed $name The value to set. + * @return self + */ + public function setName($name) + { + $this->setProperty( + self::NAME, + $name + ); + + return $this; + } + /** + * Get the version. + * + * @return string + */ + public function getVersion(): string + { + return $this->getProperty(self::VERSION); + } + /** + * Set the version. + * + * @param mixed $version The value to set. + * @return self + */ + public function setVersion($version) + { + $this->setProperty( + self::VERSION, + $version + ); + + return $this; + } + /** + * Get the platform. + * + * @return string + */ + public function getPlatform(): string + { + return $this->getProperty(self::PLATFORM); + } + /** + * Get the deviceType. + * + * @return string + */ + public function getDeviceType(): string + { + return $this->getProperty(self::DEVICE_TYPE); + } + /** + * Get the credentialId. + * + * @return string + */ + public function getCredentialId(): string + { + return $this->getProperty(self::CREDENTIAL_ID); + } + /** + * Set the credentialId. + * + * @param mixed $credentialId The value to set. + * @return self + */ + public function setCredentialId($credentialId) + { + $this->setProperty( + self::CREDENTIAL_ID, + $credentialId + ); + + return $this; + } +} diff --git a/src/Generated/UserFactors/SecurityQuestion.php b/src/Generated/UserFactors/SecurityQuestion.php new file mode 100644 index 0000000000..203b3a3893 --- /dev/null +++ b/src/Generated/UserFactors/SecurityQuestion.php @@ -0,0 +1,99 @@ +getProperty(self::ANSWER); + } + /** + * Set the answer. + * + * @param mixed $answer The value to set. + * @return self + */ + public function setAnswer($answer) + { + $this->setProperty( + self::ANSWER, + $answer + ); + + return $this; + } + /** + * Get the question. + * + * @return string + */ + public function getQuestion(): string + { + return $this->getProperty(self::QUESTION); + } + /** + * Set the question. + * + * @param mixed $question The value to set. + * @return self + */ + public function setQuestion($question) + { + $this->setProperty( + self::QUESTION, + $question + ); + + return $this; + } + /** + * Get the questionText. + * + * @return string + */ + public function getQuestionText(): string + { + return $this->getProperty(self::QUESTION_TEXT); + } + /** + * Set the questionText. + * + * @param mixed $questionText The value to set. + * @return self + */ + public function setQuestionText($questionText) + { + $this->setProperty( + self::QUESTION_TEXT, + $questionText + ); + + return $this; + } +} diff --git a/src/Generated/UserFactors/SecurityQuestionFactor.php b/src/Generated/UserFactors/SecurityQuestionFactor.php new file mode 100644 index 0000000000..819926f1fb --- /dev/null +++ b/src/Generated/UserFactors/SecurityQuestionFactor.php @@ -0,0 +1,54 @@ +getResourceProperty( + self::PROFILE, + \Okta\UserFactors\SecurityQuestionFactorProfile::class, + $options + ); + } + + /** + * Set the profile. + * + * @param \Okta\UserFactors\FactorProfile $profile The SecurityQuestionFactorProfile instance. + * @return self + */ + public function setProfile(\Okta\UserFactors\FactorProfile $profile) + { + $this->setResourceProperty( + self::PROFILE, + $profile + ); + + return $this; + } +} diff --git a/src/Generated/UserFactors/SecurityQuestionFactorProfile.php b/src/Generated/UserFactors/SecurityQuestionFactorProfile.php new file mode 100644 index 0000000000..4dea3007fa --- /dev/null +++ b/src/Generated/UserFactors/SecurityQuestionFactorProfile.php @@ -0,0 +1,99 @@ +getProperty(self::ANSWER); + } + /** + * Set the answer. + * + * @param mixed $answer The value to set. + * @return self + */ + public function setAnswer($answer) + { + $this->setProperty( + self::ANSWER, + $answer + ); + + return $this; + } + /** + * Get the question. + * + * @return string + */ + public function getQuestion(): string + { + return $this->getProperty(self::QUESTION); + } + /** + * Set the question. + * + * @param mixed $question The value to set. + * @return self + */ + public function setQuestion($question) + { + $this->setProperty( + self::QUESTION, + $question + ); + + return $this; + } + /** + * Get the questionText. + * + * @return string + */ + public function getQuestionText(): string + { + return $this->getProperty(self::QUESTION_TEXT); + } + /** + * Set the questionText. + * + * @param mixed $questionText The value to set. + * @return self + */ + public function setQuestionText($questionText) + { + $this->setProperty( + self::QUESTION_TEXT, + $questionText + ); + + return $this; + } +} diff --git a/src/Generated/UserFactors/SmsFactor.php b/src/Generated/UserFactors/SmsFactor.php new file mode 100644 index 0000000000..9d5cd06923 --- /dev/null +++ b/src/Generated/UserFactors/SmsFactor.php @@ -0,0 +1,54 @@ +getResourceProperty( + self::PROFILE, + \Okta\UserFactors\SmsFactorProfile::class, + $options + ); + } + + /** + * Set the profile. + * + * @param \Okta\UserFactors\FactorProfile $profile The SmsFactorProfile instance. + * @return self + */ + public function setProfile(\Okta\UserFactors\FactorProfile $profile) + { + $this->setResourceProperty( + self::PROFILE, + $profile + ); + + return $this; + } +} diff --git a/src/Generated/UserFactors/SmsFactorProfile.php b/src/Generated/UserFactors/SmsFactorProfile.php new file mode 100644 index 0000000000..5385d24640 --- /dev/null +++ b/src/Generated/UserFactors/SmsFactorProfile.php @@ -0,0 +1,49 @@ +getProperty(self::PHONE_NUMBER); + } + /** + * Set the phoneNumber. + * + * @param mixed $phoneNumber The value to set. + * @return self + */ + public function setPhoneNumber($phoneNumber) + { + $this->setProperty( + self::PHONE_NUMBER, + $phoneNumber + ); + + return $this; + } +} diff --git a/src/Generated/UserFactors/TokenFactor.php b/src/Generated/UserFactors/TokenFactor.php new file mode 100644 index 0000000000..6e648521f6 --- /dev/null +++ b/src/Generated/UserFactors/TokenFactor.php @@ -0,0 +1,54 @@ +getResourceProperty( + self::PROFILE, + \Okta\UserFactors\TokenFactorProfile::class, + $options + ); + } + + /** + * Set the profile. + * + * @param \Okta\UserFactors\FactorProfile $profile The TokenFactorProfile instance. + * @return self + */ + public function setProfile(\Okta\UserFactors\FactorProfile $profile) + { + $this->setResourceProperty( + self::PROFILE, + $profile + ); + + return $this; + } +} diff --git a/src/Generated/UserFactors/TokenFactorProfile.php b/src/Generated/UserFactors/TokenFactorProfile.php new file mode 100644 index 0000000000..ad89f3eaad --- /dev/null +++ b/src/Generated/UserFactors/TokenFactorProfile.php @@ -0,0 +1,49 @@ +getProperty(self::CREDENTIAL_ID); + } + /** + * Set the credentialId. + * + * @param mixed $credentialId The value to set. + * @return self + */ + public function setCredentialId($credentialId) + { + $this->setProperty( + self::CREDENTIAL_ID, + $credentialId + ); + + return $this; + } +} diff --git a/src/Generated/UserFactors/TotpFactor.php b/src/Generated/UserFactors/TotpFactor.php new file mode 100644 index 0000000000..78b036f392 --- /dev/null +++ b/src/Generated/UserFactors/TotpFactor.php @@ -0,0 +1,54 @@ +getResourceProperty( + self::PROFILE, + \Okta\UserFactors\TotpFactorProfile::class, + $options + ); + } + + /** + * Set the profile. + * + * @param \Okta\UserFactors\FactorProfile $profile The TotpFactorProfile instance. + * @return self + */ + public function setProfile(\Okta\UserFactors\FactorProfile $profile) + { + $this->setResourceProperty( + self::PROFILE, + $profile + ); + + return $this; + } +} diff --git a/src/Generated/UserFactors/TotpFactorProfile.php b/src/Generated/UserFactors/TotpFactorProfile.php new file mode 100644 index 0000000000..d5f7bc7f85 --- /dev/null +++ b/src/Generated/UserFactors/TotpFactorProfile.php @@ -0,0 +1,49 @@ +getProperty(self::CREDENTIAL_ID); + } + /** + * Set the credentialId. + * + * @param mixed $credentialId The value to set. + * @return self + */ + public function setCredentialId($credentialId) + { + $this->setProperty( + self::CREDENTIAL_ID, + $credentialId + ); + + return $this; + } +} diff --git a/src/Generated/UserFactors/VerifyFactorRequest.php b/src/Generated/UserFactors/VerifyFactorRequest.php new file mode 100644 index 0000000000..49cecf1c47 --- /dev/null +++ b/src/Generated/UserFactors/VerifyFactorRequest.php @@ -0,0 +1,124 @@ +getProperty(self::ANSWER); + } + /** + * Set the answer. + * + * @param mixed $answer The value to set. + * @return self + */ + public function setAnswer($answer) + { + $this->setProperty( + self::ANSWER, + $answer + ); + + return $this; + } + /** + * Get the passCode. + * + * @return string + */ + public function getPassCode(): string + { + return $this->getProperty(self::PASS_CODE); + } + /** + * Set the passCode. + * + * @param mixed $passCode The value to set. + * @return self + */ + public function setPassCode($passCode) + { + $this->setProperty( + self::PASS_CODE, + $passCode + ); + + return $this; + } + /** + * Get the nextPassCode. + * + * @return string + */ + public function getNextPassCode(): string + { + return $this->getProperty(self::NEXT_PASS_CODE); + } + /** + * Set the nextPassCode. + * + * @param mixed $nextPassCode The value to set. + * @return self + */ + public function setNextPassCode($nextPassCode) + { + $this->setProperty( + self::NEXT_PASS_CODE, + $nextPassCode + ); + + return $this; + } + /** + * Get the activationToken. + * + * @return string + */ + public function getActivationToken(): string + { + return $this->getProperty(self::ACTIVATION_TOKEN); + } + /** + * Set the activationToken. + * + * @param mixed $activationToken The value to set. + * @return self + */ + public function setActivationToken($activationToken) + { + $this->setProperty( + self::ACTIVATION_TOKEN, + $activationToken + ); + + return $this; + } +} diff --git a/src/Generated/UserFactors/VerifyFactorResponse.php b/src/Generated/UserFactors/VerifyFactorResponse.php new file mode 100644 index 0000000000..b1a1935ed8 --- /dev/null +++ b/src/Generated/UserFactors/VerifyFactorResponse.php @@ -0,0 +1,74 @@ +getProperty(self::LINKS); + } + /** + * Get the _embedded. + * + * @return \stdClass + */ + public function getEmbedded(): \stdClass + { + return $this->getProperty(self::EMBEDDED); + } + /** + * Get the expiresAt. + * + * @return \Carbon\Carbon|null + */ + public function getExpiresAt() + { + return $this->getDateProperty(self::EXPIRES_AT); + } + /** + * Get the factorResult. + * + * @return string + */ + public function getFactorResult(): string + { + return $this->getProperty(self::FACTOR_RESULT); + } + /** + * Get the factorResultMessage. + * + * @return string + */ + public function getFactorResultMessage(): string + { + return $this->getProperty(self::FACTOR_RESULT_MESSAGE); + } +} diff --git a/src/Generated/UserFactors/WebFactor.php b/src/Generated/UserFactors/WebFactor.php new file mode 100644 index 0000000000..8e568e0ae0 --- /dev/null +++ b/src/Generated/UserFactors/WebFactor.php @@ -0,0 +1,54 @@ +getResourceProperty( + self::PROFILE, + \Okta\UserFactors\WebFactorProfile::class, + $options + ); + } + + /** + * Set the profile. + * + * @param \Okta\UserFactors\FactorProfile $profile The WebFactorProfile instance. + * @return self + */ + public function setProfile(\Okta\UserFactors\FactorProfile $profile) + { + $this->setResourceProperty( + self::PROFILE, + $profile + ); + + return $this; + } +} diff --git a/src/Generated/UserFactors/WebFactorProfile.php b/src/Generated/UserFactors/WebFactorProfile.php new file mode 100644 index 0000000000..77e5202c6b --- /dev/null +++ b/src/Generated/UserFactors/WebFactorProfile.php @@ -0,0 +1,49 @@ +getProperty(self::CREDENTIAL_ID); + } + /** + * Set the credentialId. + * + * @param mixed $credentialId The value to set. + * @return self + */ + public function setCredentialId($credentialId) + { + $this->setProperty( + self::CREDENTIAL_ID, + $credentialId + ); + + return $this; + } +} diff --git a/src/Generated/Users/AppLink.php b/src/Generated/Users/AppLink.php new file mode 100644 index 0000000000..e92acdefa4 --- /dev/null +++ b/src/Generated/Users/AppLink.php @@ -0,0 +1,124 @@ +getProperty(self::ID); + } + /** + * Get the label. + * + * @return string + */ + public function getLabel(): string + { + return $this->getProperty(self::LABEL); + } + /** + * Get the hidden. + * + * @return bool + */ + public function getHidden(): bool + { + return $this->getProperty(self::HIDDEN); + } + /** + * Get the appName. + * + * @return string + */ + public function getAppName(): string + { + return $this->getProperty(self::APP_NAME); + } + /** + * Get the linkUrl. + * + * @return string + */ + public function getLinkUrl(): string + { + return $this->getProperty(self::LINK_URL); + } + /** + * Get the logoUrl. + * + * @return string + */ + public function getLogoUrl(): string + { + return $this->getProperty(self::LOGO_URL); + } + /** + * Get the sortOrder. + * + * @return int + */ + public function getSortOrder(): int + { + return $this->getProperty(self::SORT_ORDER); + } + /** + * Get the appInstanceId. + * + * @return string + */ + public function getAppInstanceId(): string + { + return $this->getProperty(self::APP_INSTANCE_ID); + } + /** + * Get the appAssignmentId. + * + * @return string + */ + public function getAppAssignmentId(): string + { + return $this->getProperty(self::APP_ASSIGNMENT_ID); + } + /** + * Get the credentialsSetup. + * + * @return bool + */ + public function getCredentialsSetup(): bool + { + return $this->getProperty(self::CREDENTIALS_SETUP); + } +} diff --git a/src/Generated/Users/AuthenticationProvider.php b/src/Generated/Users/AuthenticationProvider.php new file mode 100644 index 0000000000..750b107648 --- /dev/null +++ b/src/Generated/Users/AuthenticationProvider.php @@ -0,0 +1,74 @@ +getProperty(self::NAME); + } + /** + * Set the name. + * + * @param mixed $name The value to set. + * @return self + */ + public function setName($name) + { + $this->setProperty( + self::NAME, + $name + ); + + return $this; + } + /** + * Get the type. + * + * @return string + */ + public function getType(): string + { + return $this->getProperty(self::TYPE); + } + /** + * Set the type. + * + * @param mixed $type The value to set. + * @return self + */ + public function setType($type) + { + $this->setProperty( + self::TYPE, + $type + ); + + return $this; + } +} diff --git a/src/Generated/Users/AuthenticationProviderType.php b/src/Generated/Users/AuthenticationProviderType.php new file mode 100644 index 0000000000..2fa9cf5c3c --- /dev/null +++ b/src/Generated/Users/AuthenticationProviderType.php @@ -0,0 +1,30 @@ +getResourceProperty( + self::NEW_PASSWORD, + \Okta\Users\PasswordCredential::class, + $options + ); + } + + /** + * Set the newPassword. + * + * @param \Okta\Users\PasswordCredential $newPassword The PasswordCredential instance. + * @return self + */ + public function setNewPassword(\Okta\Users\PasswordCredential $newPassword) + { + $this->setResourceProperty( + self::NEW_PASSWORD, + $newPassword + ); + + return $this; + } + /** + * Get the oldPassword. + * + * @return \Okta\Users\PasswordCredential + */ + public function getOldPassword(array $options = []): \Okta\Users\PasswordCredential + { + return $this->getResourceProperty( + self::OLD_PASSWORD, + \Okta\Users\PasswordCredential::class, + $options + ); + } + + /** + * Set the oldPassword. + * + * @param \Okta\Users\PasswordCredential $oldPassword The PasswordCredential instance. + * @return self + */ + public function setOldPassword(\Okta\Users\PasswordCredential $oldPassword) + { + $this->setResourceProperty( + self::OLD_PASSWORD, + $oldPassword + ); + + return $this; + } +} diff --git a/src/Generated/Users/Collection.php b/src/Generated/Users/Collection.php new file mode 100644 index 0000000000..c9827bf99c --- /dev/null +++ b/src/Generated/Users/Collection.php @@ -0,0 +1,25 @@ +getProperty(self::RESET_PASSWORD_URL); + } +} diff --git a/src/Generated/Users/PasswordCredential.php b/src/Generated/Users/PasswordCredential.php new file mode 100644 index 0000000000..9bc3a00f7b --- /dev/null +++ b/src/Generated/Users/PasswordCredential.php @@ -0,0 +1,49 @@ +getProperty(self::VALUE); + } + /** + * Set the value. + * + * @param mixed $value The value to set. + * @return self + */ + public function setValue($value) + { + $this->setProperty( + self::VALUE, + $value + ); + + return $this; + } +} diff --git a/src/Generated/Users/RecoveryQuestionCredential.php b/src/Generated/Users/RecoveryQuestionCredential.php new file mode 100644 index 0000000000..ac26b4a05d --- /dev/null +++ b/src/Generated/Users/RecoveryQuestionCredential.php @@ -0,0 +1,74 @@ +getProperty(self::ANSWER); + } + /** + * Set the answer. + * + * @param mixed $answer The value to set. + * @return self + */ + public function setAnswer($answer) + { + $this->setProperty( + self::ANSWER, + $answer + ); + + return $this; + } + /** + * Get the question. + * + * @return string + */ + public function getQuestion(): string + { + return $this->getProperty(self::QUESTION); + } + /** + * Set the question. + * + * @param mixed $question The value to set. + * @return self + */ + public function setQuestion($question) + { + $this->setProperty( + self::QUESTION, + $question + ); + + return $this; + } +} diff --git a/src/Generated/Users/ResetPasswordToken.php b/src/Generated/Users/ResetPasswordToken.php new file mode 100644 index 0000000000..c8ea3bec3f --- /dev/null +++ b/src/Generated/Users/ResetPasswordToken.php @@ -0,0 +1,34 @@ +getProperty(self::RESET_PASSWORD_URL); + } +} diff --git a/src/Generated/Users/Role.php b/src/Generated/Users/Role.php new file mode 100644 index 0000000000..eb46830b93 --- /dev/null +++ b/src/Generated/Users/Role.php @@ -0,0 +1,119 @@ +getProperty(self::ID); + } + /** + * Get the type. + * + * @return string + */ + public function getType(): string + { + return $this->getProperty(self::TYPE); + } + /** + * Get the label. + * + * @return string + */ + public function getLabel(): string + { + return $this->getProperty(self::LABEL); + } + /** + * Get the status. + * + * @return string + */ + public function getStatus(): string + { + return $this->getProperty(self::STATUS); + } + /** + * Get the created. + * + * @return \Carbon\Carbon|null + */ + public function getCreated() + { + return $this->getDateProperty(self::CREATED); + } + /** + * Get the _embedded. + * + * @return \stdClass + */ + public function getEmbedded(): \stdClass + { + return $this->getProperty(self::EMBEDDED); + } + /** + * Get the description. + * + * @return string + */ + public function getDescription(): string + { + return $this->getProperty(self::DESCRIPTION); + } + /** + * Set the description. + * + * @param mixed $description The value to set. + * @return self + */ + public function setDescription($description) + { + $this->setProperty( + self::DESCRIPTION, + $description + ); + + return $this; + } + /** + * Get the lastUpdated. + * + * @return \Carbon\Carbon|null + */ + public function getLastUpdated() + { + return $this->getDateProperty(self::LAST_UPDATED); + } +} diff --git a/src/Generated/Users/RoleStatus.php b/src/Generated/Users/RoleStatus.php new file mode 100644 index 0000000000..baacc10200 --- /dev/null +++ b/src/Generated/Users/RoleStatus.php @@ -0,0 +1,26 @@ +getProperty(self::TEMP_PASSWORD); + } +} diff --git a/src/Generated/Users/User.php b/src/Generated/Users/User.php new file mode 100644 index 0000000000..181fb04b4f --- /dev/null +++ b/src/Generated/Users/User.php @@ -0,0 +1,753 @@ +getDataStore() + ->createResource( + "/users", + $this, + \Okta\Users\User::class + ); + } + + public function get($query) + { + return \Okta\Client::getInstance() + ->getDataStore() + ->getResource( + $query, + \Okta\Users\User::class, + "/users" + ); + } + public function save() + { + return \Okta\Client::getInstance() + ->getDataStore() + ->saveResource( + "/users", + $this, + \Okta\Users\User::class + ); + } + public function delete() + { + return \Okta\Client::getInstance() + ->getDataStore() + ->deleteResource( + "/users", + $this + ); + } + /** + * Get the id. + * + * @return string + */ + public function getId(): string + { + return $this->getProperty(self::ID); + } + /** + * Get the _links. + * + * @return \stdClass + */ + public function getLinks(): \stdClass + { + return $this->getProperty(self::LINKS); + } + /** + * Get the status. + * + * @return string + */ + public function getStatus(): string + { + return $this->getProperty(self::STATUS); + } + /** + * Get the created. + * + * @return \Carbon\Carbon|null + */ + public function getCreated() + { + return $this->getDateProperty(self::CREATED); + } + /** + * Get the profile. + * + * @return \Okta\Users\UserProfile + */ + public function getProfile(array $options = []): \Okta\Users\UserProfile + { + return $this->getResourceProperty( + self::PROFILE, + \Okta\Users\UserProfile::class, + $options + ); + } + + /** + * Set the profile. + * + * @param \Okta\Users\UserProfile $profile The UserProfile instance. + * @return self + */ + public function setProfile(\Okta\Users\UserProfile $profile) + { + $this->setResourceProperty( + self::PROFILE, + $profile + ); + + return $this; + } + /** + * Get the _embedded. + * + * @return \stdClass + */ + public function getEmbedded(): \stdClass + { + return $this->getProperty(self::EMBEDDED); + } + /** + * Get the activated. + * + * @return \Carbon\Carbon|null + */ + public function getActivated() + { + return $this->getDateProperty(self::ACTIVATED); + } + /** + * Get the lastLogin. + * + * @return \Carbon\Carbon|null + */ + public function getLastLogin() + { + return $this->getDateProperty(self::LAST_LOGIN); + } + /** + * Get the credentials. + * + * @return \Okta\Users\UserCredentials + */ + public function getCredentials(array $options = []): \Okta\Users\UserCredentials + { + return $this->getResourceProperty( + self::CREDENTIALS, + \Okta\Users\UserCredentials::class, + $options + ); + } + + /** + * Set the credentials. + * + * @param \Okta\Users\UserCredentials $credentials The UserCredentials instance. + * @return self + */ + public function setCredentials(\Okta\Users\UserCredentials $credentials) + { + $this->setResourceProperty( + self::CREDENTIALS, + $credentials + ); + + return $this; + } + /** + * Get the lastUpdated. + * + * @return \Carbon\Carbon|null + */ + public function getLastUpdated() + { + return $this->getDateProperty(self::LAST_UPDATED); + } + /** + * Get the statusChanged. + * + * @return \Carbon\Carbon|null + */ + public function getStatusChanged() + { + return $this->getDateProperty(self::STATUS_CHANGED); + } + /** + * Get the passwordChanged. + * + * @return \Carbon\Carbon|null + */ + public function getPasswordChanged() + { + return $this->getDateProperty(self::PASSWORD_CHANGED); + } + /** + * Get the transitioningToStatus. + * + * @return string + */ + public function getTransitioningToStatus(): string + { + return $this->getProperty(self::TRANSITIONING_TO_STATUS); + } + + + /** + * Removes all active identity provider sessions. This forces the user to authenticate on the next operation. Optionally revokes OpenID Connect and OAuth refresh and access tokens issued to the user. + * + * + * @return mixed|null + */ + public function endAllSessions($oauthTokens = false) + { + $uri = "/api/v1/users/{$this->getId()}/sessions"; + $uri = $this->getDataStore()->buildUri( + $this->getDataStore()->getOrganizationUrl() . $uri + ); + $body = $this + ->getDataStore() + ->executeRequest('DELETE', $uri, '', ['query' => ['oauthTokens' => $oauthTokens]]); + + return $body; + } + + /** + * Get the AppLink object. + * + * @param array $options The options for the request. + * @return \Okta\Users\Collection + */ + public function getAppLinks(array $options = []): \Okta\Users\Collection + { + + return $this + ->getDataStore() + ->getCollection( + "/api/v1/users/{$this->getId()}/appLinks", + \Okta\Users\AppLink::class, + \Okta\Users\Collection::class, + $options + ); + } + + + /** + * Changes a user's password by validating the user's current password. This operation can only be performed on users in `STAGED`, `ACTIVE`, `PASSWORD_EXPIRED`, or `RECOVERY` status that have a valid [password credential](#password-object) + * + * + * @return mixed|null + */ + public function changePassword(ChangePasswordRequest $changePasswordRequest) + { + $uri = "/api/v1/users/{$this->getId()}/credentials/change_password"; + $uri = $this->getDataStore()->buildUri( + $this->getDataStore()->getOrganizationUrl() . $uri + ); + $body = $this + ->getDataStore() + ->executeRequest('POST', $uri, $changePasswordRequest); + + return new \Okta\Users\UserCredentials(null, $body); + } + + + /** + * Changes a user's recovery question & answer credential by validating the user's current password. This operation can only be performed on users in **STAGED**, **ACTIVE** or **RECOVERY** `status` that have a valid [password credential](#password-object) + * + * + * @return mixed|null + */ + public function changeRecoveryQuestion(UserCredentials $userCredentials) + { + $uri = "/api/v1/users/{$this->getId()}/credentials/change_recovery_question"; + $uri = $this->getDataStore()->buildUri( + $this->getDataStore()->getOrganizationUrl() . $uri + ); + $body = $this + ->getDataStore() + ->executeRequest('POST', $uri, $userCredentials); + + return new \Okta\Users\UserCredentials(null, $body); + } + + + /** + * Generates a one-time token (OTT) that can be used to reset a user's password. The user will be required to validate their security question's answer when visiting the reset link. This operation can only be performed on users with a valid [recovery question credential](#recovery-question-object) and have an `ACTIVE` status. + * + * @param bool $sendEmail Sets the sendEmail flag. + * @return mixed|null + */ + public function forgotPassword(UserCredentials $userCredentials, $sendEmail = true) + { + $uri = "/api/v1/users/{$this->getId()}/credentials/forgot_password"; + $uri = $this->getDataStore()->buildUri( + $this->getDataStore()->getOrganizationUrl() . $uri + ); + $body = $this + ->getDataStore() + ->executeRequest('POST', $uri, $userCredentials, ['query' => ['sendEmail' => $sendEmail]]); + + return new \Okta\Users\ForgotPasswordResponse(null, $body); + } + + /** + * Get the Role object. + * + * @param array $options The options for the request. + * @return \Okta\Users\Collection + */ + public function getRoles(array $options = []): \Okta\Users\Collection + { + + return $this + ->getDataStore() + ->getCollection( + "/api/v1/users/{$this->getId()}/roles", + \Okta\Users\Role::class, + \Okta\Users\Collection::class, + $options + ); + } + + + /** + * Assigns a role to a user. + * + * + * @return mixed|null + */ + public function addRole(Role $role) + { + $uri = "/api/v1/users/{$this->getId()}/roles"; + $uri = $this->getDataStore()->buildUri( + $this->getDataStore()->getOrganizationUrl() . $uri + ); + $body = $this + ->getDataStore() + ->executeRequest('POST', $uri, $role); + + return new \Okta\Users\Role(null, $body); + } + + + /** + * Unassigns a role from a user. + * + * + * @return mixed|null + */ + public function removeRole($roleId) + { + $uri = "/api/v1/users/{$this->getId()}/roles/{$roleId}"; + $uri = $this->getDataStore()->buildUri( + $this->getDataStore()->getOrganizationUrl() . $uri + ); + $body = $this + ->getDataStore() + ->executeRequest('DELETE', $uri); + + return $body; + } + + /** + * Get the Group object. + * + * @param array $options The options for the request. + * @return \Okta\Groups\Collection + */ + public function getGroupTargetsForRole($roleId, array $options = []): \Okta\Groups\Collection + { + + return $this + ->getDataStore() + ->getCollection( + "/api/v1/users/{$this->getId()}/roles/{$roleId}/targets/groups", + \Okta\Groups\Group::class, + \Okta\Groups\Collection::class, + $options + ); + } + + + /** + * + * + * + * @return mixed|null + */ + public function removeGroupTargetFromRole($roleId, $groupId) + { + $uri = "/api/v1/users/{$this->getId()}/roles/{$roleId}/targets/groups/{$groupId}"; + $uri = $this->getDataStore()->buildUri( + $this->getDataStore()->getOrganizationUrl() . $uri + ); + $body = $this + ->getDataStore() + ->executeRequest('DELETE', $uri); + + return $body; + } + + + /** + * + * + * + * @return mixed|null + */ + public function addGroupTargetToRole($roleId, $groupId) + { + $uri = "/api/v1/users/{$this->getId()}/roles/{$roleId}/targets/groups/{$groupId}"; + $uri = $this->getDataStore()->buildUri( + $this->getDataStore()->getOrganizationUrl() . $uri + ); + $body = $this + ->getDataStore() + ->executeRequest('PUT', $uri); + + return $body; + } + + /** + * Get the Group object. + * + * @param array $options The options for the request. + * @return \Okta\Groups\Collection + */ + public function getGroups(array $options = []): \Okta\Groups\Collection + { + + return $this + ->getDataStore() + ->getCollection( + "/api/v1/users/{$this->getId()}/groups", + \Okta\Groups\Group::class, + \Okta\Groups\Collection::class, + $options + ); + } + + + /** + * Activates a user. This operation can only be performed on users with a `STAGED` status. Activation of a user is an asynchronous operation. The user will have the `transitioningToStatus` property with a value of `ACTIVE` during activation to indicate that the user hasn't completed the asynchronous operation. The user will have a status of `ACTIVE` when the activation process is complete. + * + * @param bool $sendEmail Sets the sendEmail flag. + * @return mixed|null + */ + public function activate($sendEmail = true) + { + $uri = "/api/v1/users/{$this->getId()}/lifecycle/activate"; + $uri = $this->getDataStore()->buildUri( + $this->getDataStore()->getOrganizationUrl() . $uri + ); + $body = $this + ->getDataStore() + ->executeRequest('POST', $uri, '', ['query' => ['sendEmail' => $sendEmail]]); + + return new \Okta\Users\UserActivationToken(null, $body); + } + + + /** + * Deactivates a user. This operation can only be performed on users that do not have a `DEPROVISIONED` status. Deactivation of a user is an asynchronous operation. The user will have the `transitioningToStatus` property with a value of `DEPROVISIONED` during deactivation to indicate that the user hasn't completed the asynchronous operation. The user will have a status of `DEPROVISIONED` when the deactivation process is complete. + * + * + * @return mixed|null + */ + public function deactivate() + { + $uri = "/api/v1/users/{$this->getId()}/lifecycle/deactivate"; + $uri = $this->getDataStore()->buildUri( + $this->getDataStore()->getOrganizationUrl() . $uri + ); + $body = $this + ->getDataStore() + ->executeRequest('POST', $uri); + + return $body; + } + + + /** + * Suspends a user. This operation can only be performed on users with an `ACTIVE` status. The user will have a status of `SUSPENDED` when the process is complete. + * + * + * @return mixed|null + */ + public function suspend() + { + $uri = "/api/v1/users/{$this->getId()}/lifecycle/suspend"; + $uri = $this->getDataStore()->buildUri( + $this->getDataStore()->getOrganizationUrl() . $uri + ); + $body = $this + ->getDataStore() + ->executeRequest('POST', $uri); + + return $body; + } + + + /** + * Unsuspends a user and returns them to the `ACTIVE` state. This operation can only be performed on users that have a `SUSPENDED` status. + * + * + * @return mixed|null + */ + public function unsuspend() + { + $uri = "/api/v1/users/{$this->getId()}/lifecycle/unsuspend"; + $uri = $this->getDataStore()->buildUri( + $this->getDataStore()->getOrganizationUrl() . $uri + ); + $body = $this + ->getDataStore() + ->executeRequest('POST', $uri); + + return $body; + } + + + /** + * Generates a one-time token (OTT) that can be used to reset a user's password. The OTT link can be automatically emailed to the user or returned to the API caller and distributed using a custom flow. + * + * + * @return mixed|null + */ + public function resetPassword() + { + $uri = "/api/v1/users/{$this->getId()}/lifecycle/reset_password"; + $uri = $this->getDataStore()->buildUri( + $this->getDataStore()->getOrganizationUrl() . $uri + ); + $body = $this + ->getDataStore() + ->executeRequest('POST', $uri); + + return new \Okta\Users\ResetPasswordToken(null, $body); + } + + + /** + * This operation transitions the user to the status of `PASSWORD_EXPIRED` so that the user is required to change their password at their next login. + * + * + * @return mixed|null + */ + public function expirePassword($tempPassword = false) + { + $uri = "/api/v1/users/{$this->getId()}/lifecycle/expire_password"; + $uri = $this->getDataStore()->buildUri( + $this->getDataStore()->getOrganizationUrl() . $uri + ); + $body = $this + ->getDataStore() + ->executeRequest('POST', $uri, '', ['query' => ['tempPassword' => $tempPassword]]); + + return new \Okta\Users\TempPassword(null, $body); + } + + + /** + * Unlocks a user with a `LOCKED_OUT` status and returns them to `ACTIVE` status. Users will be able to login with their current password. + * + * + * @return mixed|null + */ + public function unlock() + { + $uri = "/api/v1/users/{$this->getId()}/lifecycle/unlock"; + $uri = $this->getDataStore()->buildUri( + $this->getDataStore()->getOrganizationUrl() . $uri + ); + $body = $this + ->getDataStore() + ->executeRequest('POST', $uri); + + return $body; + } + + + /** + * This operation resets all factors for the specified user. All MFA factor enrollments returned to the unenrolled state. The user's status remains ACTIVE. This link is present only if the user is currently enrolled in one or more MFA factors. + * + * + * @return mixed|null + */ + public function resetFactors() + { + $uri = "/api/v1/users/{$this->getId()}/lifecycle/reset_factors"; + $uri = $this->getDataStore()->buildUri( + $this->getDataStore()->getOrganizationUrl() . $uri + ); + $body = $this + ->getDataStore() + ->executeRequest('POST', $uri); + + return $body; + } + + + /** + * Adds a [user](users.html#user-model) to a group with `OKTA_GROUP` type. + * + * + * @return mixed|null + */ + public function addToGroup($groupId) + { + $uri = "/api/v1/groups/{$groupId}/users/{$this->getId()}"; + $uri = $this->getDataStore()->buildUri( + $this->getDataStore()->getOrganizationUrl() . $uri + ); + $body = $this + ->getDataStore() + ->executeRequest('PUT', $uri); + + return $body; + } + + + /** + * Enrolls a user with a supported [factor](#list-factors-to-enroll) + * + * + * @return mixed|null + */ + public function addFactor(Factor $factor, $updatePhone = false) + { + $uri = "/api/v1/users/{$this->getId()}/factors"; + $uri = $this->getDataStore()->buildUri( + $this->getDataStore()->getOrganizationUrl() . $uri + ); + $body = $this + ->getDataStore() + ->executeRequest('POST', $uri, $factor, ['query' => ['updatePhone' => $updatePhone]]); + + $response = new \Okta\UserFactors\Factor(null, $body); + return $response->convertFromGenericFactor(); + } + + /** + * Get the Factor object. + * + * @param array $options The options for the request. + * @return \Okta\UserFactors\Collection + */ + public function getSupportedFactors(array $options = []): \Okta\UserFactors\Collection + { + + return $this + ->getDataStore() + ->getCollection( + "/api/v1/users/{$this->getId()}/factors/catalog", + \Okta\UserFactors\Factor::class, + \Okta\UserFactors\Collection::class, + $options + ); + } + + /** + * Get the Factor object. + * + * @param array $options The options for the request. + * @return \Okta\UserFactors\Collection + */ + public function getFactors(array $options = []): \Okta\UserFactors\Collection + { + + return $this + ->getDataStore() + ->getCollection( + "/api/v1/users/{$this->getId()}/factors", + \Okta\UserFactors\Factor::class, + \Okta\UserFactors\Collection::class, + $options + ); + } + + /** + * Get the SecurityQuestion object. + * + * @param array $options The options for the request. + * @return \Okta\UserFactors\SecurityQuestionsCollection + */ + public function getSupportedSecurityQuestions(array $options = []): \Okta\UserFactors\SecurityQuestionsCollection + { + + return $this + ->getDataStore() + ->getCollection( + "/api/v1/users/{$this->getId()}/factors/questions", + \Okta\UserFactors\SecurityQuestion::class, + \Okta\UserFactors\SecurityQuestionsCollection::class, + $options + ); + } + + + /** + * Fetches a factor for the specified user + * + * + * @return mixed|null + */ + public function getFactor($factorId) + { + $uri = "/api/v1/users/{$this->getId()}/factors/{$factorId}"; + $uri = $this->getDataStore()->buildUri( + $this->getDataStore()->getOrganizationUrl() . $uri + ); + $body = $this + ->getDataStore() + ->executeRequest('GET', $uri); + + $response = new \Okta\UserFactors\Factor(null, $body); + return $response->convertFromGenericFactor(); + } +} diff --git a/src/Generated/Users/UserActivationToken.php b/src/Generated/Users/UserActivationToken.php new file mode 100644 index 0000000000..5779f34763 --- /dev/null +++ b/src/Generated/Users/UserActivationToken.php @@ -0,0 +1,44 @@ +getProperty(self::ACTIVATION_URL); + } + /** + * Get the activationToken. + * + * @return string + */ + public function getActivationToken(): string + { + return $this->getProperty(self::ACTIVATION_TOKEN); + } +} diff --git a/src/Generated/Users/UserCredentials.php b/src/Generated/Users/UserCredentials.php new file mode 100644 index 0000000000..ba91df803d --- /dev/null +++ b/src/Generated/Users/UserCredentials.php @@ -0,0 +1,114 @@ +getResourceProperty( + self::PASSWORD, + \Okta\Users\PasswordCredential::class, + $options + ); + } + + /** + * Set the password. + * + * @param \Okta\Users\PasswordCredential $password The PasswordCredential instance. + * @return self + */ + public function setPassword(\Okta\Users\PasswordCredential $password) + { + $this->setResourceProperty( + self::PASSWORD, + $password + ); + + return $this; + } + /** + * Get the provider. + * + * @return \Okta\Users\AuthenticationProvider + */ + public function getProvider(array $options = []): \Okta\Users\AuthenticationProvider + { + return $this->getResourceProperty( + self::PROVIDER, + \Okta\Users\AuthenticationProvider::class, + $options + ); + } + + /** + * Set the provider. + * + * @param \Okta\Users\AuthenticationProvider $provider The AuthenticationProvider instance. + * @return self + */ + public function setProvider(\Okta\Users\AuthenticationProvider $provider) + { + $this->setResourceProperty( + self::PROVIDER, + $provider + ); + + return $this; + } + /** + * Get the recovery_question. + * + * @return \Okta\Users\RecoveryQuestionCredential + */ + public function getRecoveryQuestion(array $options = []): \Okta\Users\RecoveryQuestionCredential + { + return $this->getResourceProperty( + self::RECOVERY_QUESTION, + \Okta\Users\RecoveryQuestionCredential::class, + $options + ); + } + + /** + * Set the recovery_question. + * + * @param \Okta\Users\RecoveryQuestionCredential $recovery_question The RecoveryQuestionCredential instance. + * @return self + */ + public function setRecoveryQuestion(\Okta\Users\RecoveryQuestionCredential $recovery_question) + { + $this->setResourceProperty( + self::RECOVERY_QUESTION, + $recovery_question + ); + + return $this; + } +} diff --git a/src/Generated/Users/UserProfile.php b/src/Generated/Users/UserProfile.php new file mode 100644 index 0000000000..2c99b24e73 --- /dev/null +++ b/src/Generated/Users/UserProfile.php @@ -0,0 +1,174 @@ +getProperty(self::EMAIL); + } + /** + * Set the email. + * + * @param mixed $email The value to set. + * @return self + */ + public function setEmail($email) + { + $this->setProperty( + self::EMAIL, + $email + ); + + return $this; + } + /** + * Get the login. + * + * @return string + */ + public function getLogin(): string + { + return $this->getProperty(self::LOGIN); + } + /** + * Set the login. + * + * @param mixed $login The value to set. + * @return self + */ + public function setLogin($login) + { + $this->setProperty( + self::LOGIN, + $login + ); + + return $this; + } + /** + * Get the lastName. + * + * @return string + */ + public function getLastName(): string + { + return $this->getProperty(self::LAST_NAME); + } + /** + * Set the lastName. + * + * @param mixed $lastName The value to set. + * @return self + */ + public function setLastName($lastName) + { + $this->setProperty( + self::LAST_NAME, + $lastName + ); + + return $this; + } + /** + * Get the firstName. + * + * @return string + */ + public function getFirstName(): string + { + return $this->getProperty(self::FIRST_NAME); + } + /** + * Set the firstName. + * + * @param mixed $firstName The value to set. + * @return self + */ + public function setFirstName($firstName) + { + $this->setProperty( + self::FIRST_NAME, + $firstName + ); + + return $this; + } + /** + * Get the mobilePhone. + * + * @return string + */ + public function getMobilePhone(): string + { + return $this->getProperty(self::MOBILE_PHONE); + } + /** + * Set the mobilePhone. + * + * @param mixed $mobilePhone The value to set. + * @return self + */ + public function setMobilePhone($mobilePhone) + { + $this->setProperty( + self::MOBILE_PHONE, + $mobilePhone + ); + + return $this; + } + /** + * Get the secondEmail. + * + * @return string + */ + public function getSecondEmail(): string + { + return $this->getProperty(self::SECOND_EMAIL); + } + /** + * Set the secondEmail. + * + * @param mixed $secondEmail The value to set. + * @return self + */ + public function setSecondEmail($secondEmail) + { + $this->setProperty( + self::SECOND_EMAIL, + $secondEmail + ); + + return $this; + } +} diff --git a/src/Generated/Users/UserStatus.php b/src/Generated/Users/UserStatus.php new file mode 100644 index 0000000000..55500b111d --- /dev/null +++ b/src/Generated/Users/UserStatus.php @@ -0,0 +1,32 @@ +getDataStore() - ->saveResource( - '/groups', - $this, - self::class - ); - } - - public function delete() - { - return \Okta\Client::getInstance() - ->getDataStore() - ->deleteResource( - '/groups', - $this - ); - } - - /** - * Get the id. - * - * @return string - */ - public function getId(): string - { - return $this->getProperty(self::ID); - } - /** - * Get the name. - * - * @return string - */ - public function getName(): string - { - return $this->getProperty(self::NAME); - } - /** - * Set the name. - * - * @param mixed $name The value to set. - * @return self - */ - public function setName($name) - { - $this->setProperty( - self::NAME, - $name - ); - - return $this; - } - /** - * Get the type. - * - * @return string - */ - public function getType(): string - { - return $this->getProperty(self::TYPE); - } - /** - * Set the type. - * - * @param mixed $type The value to set. - * @return self - */ - public function setType($type) - { - $this->setProperty( - self::TYPE, - $type - ); - - return $this; - } - /** - * Get the status. - * - * @return string - */ - public function getStatus(): string - { - return $this->getProperty(self::STATUS); - } - /** - * Get the actions. - * - * @return GroupRuleAction - */ - public function getActions(array $options = []): GroupRuleAction - { - return $this->getResourceProperty( - self::ACTIONS, - GroupRuleAction::class, - $options - ); - } - - /** - * Set the actions. - * - * @param GroupRuleAction $actions The GroupRuleAction instance. - * @return self - */ - public function setActions(GroupRuleAction $actions) - { - $this->setResourceProperty( - self::ACTIONS, - $actions - ); - - return $this; - } - /** - * Get the created. - * - * @return \Carbon\Carbon|null - */ - public function getCreated() - { - return $this->getDateProperty(self::CREATED); - } - /** - * Get the conditions. - * - * @return GroupRuleConditions - */ - public function getConditions(array $options = []): GroupRuleConditions - { - return $this->getResourceProperty( - self::CONDITIONS, - GroupRuleConditions::class, - $options - ); - } - /** - * Set the conditions. - * - * @param GroupRuleConditions $conditions The GroupRuleConditions instance. - * @return self - */ - public function setConditions(GroupRuleConditions $conditions) - { - $this->setResourceProperty( - self::CONDITIONS, - $conditions - ); - - return $this; - } - /** - * Get the lastUpdated. - * - * @return \Carbon\Carbon|null - */ - public function getLastUpdated() - { - return $this->getDateProperty(self::LAST_UPDATED); - } - /** - * Sends a request to the activate endpoint. - * - * - * @return mixed|null - */ - public function activate() - { - $uri = "/api/v1/groups/rules/{$this->getId()}/lifecycle/activate"; - $uri = $this->getDataStore()->buildUri( - $this->getDataStore()->getOrganizationUrl() . $uri - ); - return $this - ->getDataStore() - ->executeRequest('POST', $uri); - } - /** - * Sends a request to the deactivate endpoint. - * - * - * @return mixed|null - */ - public function deactivate() - { - $uri = "/api/v1/groups/rules/{$this->getId()}/lifecycle/deactivate"; - $uri = $this->getDataStore()->buildUri( - $this->getDataStore()->getOrganizationUrl() . $uri - ); - return $this - ->getDataStore() - ->executeRequest('POST', $uri); - } } diff --git a/src/GroupRules/GroupRuleAction.php b/src/GroupRules/GroupRuleAction.php index ed8e8d614c..0abbcd0216 100644 --- a/src/GroupRules/GroupRuleAction.php +++ b/src/GroupRules/GroupRuleAction.php @@ -1,55 +1,23 @@ getResourceProperty( - self::ASSIGN_USER_TO_GROUPS, - GroupRuleGroupAssignment::class, - $options - ); - } - /** - * Set the assignUserToGroups. - * - * @param GroupRuleGroupAssignment $assignUserToGroups The GroupRuleGroupAssignment instance. - * @return self - */ - public function setAssignUserToGroups(GroupRuleGroupAssignment $assignUserToGroups) - { - $this->setResourceProperty( - self::ASSIGN_USER_TO_GROUPS, - $assignUserToGroups - ); - - return $this; - } } diff --git a/src/GroupRules/GroupRuleConditions.php b/src/GroupRules/GroupRuleConditions.php index 8b83c6643a..3421f3a392 100644 --- a/src/GroupRules/GroupRuleConditions.php +++ b/src/GroupRules/GroupRuleConditions.php @@ -1,85 +1,23 @@ getResourceProperty( - self::PEOPLE, - GroupRulePeopleCondition::class, - $options - ); - } - - /** - * Set the people. - * - * @param GroupRulePeopleCondition $people The GroupRulePeopleCondition instance. - * @return self - */ - public function setPeople(GroupRulePeopleCondition $people) - { - $this->setResourceProperty( - self::PEOPLE, - $people - ); - - return $this; - } - /** - * Get the expression. - * - * @return GroupRuleExpression - */ - public function getExpression(array $options = []): GroupRuleExpression - { - return $this->getResourceProperty( - self::EXPRESSION, - GroupRuleExpression::class, - $options - ); - } - /** - * Set the expression. - * - * @param GroupRuleExpression $expression The GroupRuleExpression instance. - * @return self - */ - public function setExpression(GroupRuleExpression $expression) - { - $this->setResourceProperty( - self::EXPRESSION, - $expression - ); - - return $this; - } } diff --git a/src/GroupRules/GroupRuleExpression.php b/src/GroupRules/GroupRuleExpression.php index b13118e101..6f1b1fd9c3 100644 --- a/src/GroupRules/GroupRuleExpression.php +++ b/src/GroupRules/GroupRuleExpression.php @@ -1,75 +1,23 @@ getProperty(self::TYPE); - } - /** - * Set the type. - * - * @param mixed $type The value to set. - * @return self - */ - public function setType($type) - { - $this->setProperty( - self::TYPE, - $type - ); - - return $this; - } - /** - * Get the value. - * - * @return string - */ - public function getValue(): string - { - return $this->getProperty(self::VALUE); - } - /** - * Set the value. - * - * @param mixed $value The value to set. - * @return self - */ - public function setValue($value) - { - $this->setProperty( - self::VALUE, - $value - ); - return $this; - } } diff --git a/src/GroupRules/GroupRuleGroupAssignment.php b/src/GroupRules/GroupRuleGroupAssignment.php index 7e3f1e492d..fdad06b681 100644 --- a/src/GroupRules/GroupRuleGroupAssignment.php +++ b/src/GroupRules/GroupRuleGroupAssignment.php @@ -1,50 +1,23 @@ getProperty(self::GROUP_IDS); - } - /** - * Set the groupIds. - * - * @param mixed $groupIds The value to set. - * @return self - */ - public function setGroupIds($groupIds) - { - $this->setProperty( - self::GROUP_IDS, - $groupIds - ); - return $this; - } } diff --git a/src/GroupRules/GroupRuleGroupCondition.php b/src/GroupRules/GroupRuleGroupCondition.php index 4a1dc68af7..a91a45a219 100644 --- a/src/GroupRules/GroupRuleGroupCondition.php +++ b/src/GroupRules/GroupRuleGroupCondition.php @@ -1,75 +1,23 @@ getProperty(self::EXCLUDE); - } - /** - * Set the exclude. - * - * @param mixed $exclude The value to set. - * @return self - */ - public function setExclude($exclude) - { - $this->setProperty( - self::EXCLUDE, - $exclude - ); - - return $this; - } - /** - * Get the include. - * - * @return array - */ - public function getInclude(): array - { - return $this->getProperty(self::INCLUDE); - } - /** - * Set the include. - * - * @param mixed $include The value to set. - * @return self - */ - public function setInclude($include) - { - $this->setProperty( - self::INCLUDE, - $include - ); - return $this; - } } diff --git a/src/GroupRules/GroupRulePeopleCondition.php b/src/GroupRules/GroupRulePeopleCondition.php index 05d3c6347a..4f0ab87220 100644 --- a/src/GroupRules/GroupRulePeopleCondition.php +++ b/src/GroupRules/GroupRulePeopleCondition.php @@ -1,85 +1,23 @@ getResourceProperty( - self::USERS, - GroupRuleUserCondition::class, - $options - ); - } - - /** - * Set the users. - * - * @param GroupRuleUserCondition $users The GroupRuleUserCondition instance. - * @return self - */ - public function setUsers(GroupRuleUserCondition $users) - { - $this->setResourceProperty( - self::USERS, - $users - ); - - return $this; - } - /** - * Get the groups. - * - * @return GroupRuleGroupCondition - */ - public function getGroups(array $options = []): GroupRuleGroupCondition - { - return $this->getResourceProperty( - self::GROUPS, - GroupRuleGroupCondition::class, - $options - ); - } - /** - * Set the groups. - * - * @param GroupRuleGroupCondition $groups The GroupRuleGroupCondition instance. - * @return self - */ - public function setGroups(GroupRuleGroupCondition $groups) - { - $this->setResourceProperty( - self::GROUPS, - $groups - ); - - return $this; - } } diff --git a/src/GroupRules/GroupRuleStatus.php b/src/GroupRules/GroupRuleStatus.php index d99c94eee1..3e9d780fff 100644 --- a/src/GroupRules/GroupRuleStatus.php +++ b/src/GroupRules/GroupRuleStatus.php @@ -1,25 +1,23 @@ getProperty(self::EXCLUDE); - } - /** - * Set the exclude. - * - * @param mixed $exclude The value to set. - * @return self - */ - public function setExclude($exclude) - { - $this->setProperty( - self::EXCLUDE, - $exclude - ); - - return $this; - } - /** - * Get the include. - * - * @return array - */ - public function getInclude(): array - { - return $this->getProperty(self::INCLUDE); - } - /** - * Set the include. - * - * @param mixed $include The value to set. - * @return self - */ - public function setInclude($include) - { - $this->setProperty( - self::INCLUDE, - $include - ); - return $this; - } } diff --git a/src/Groups/Collection.php b/src/Groups/Collection.php index b4f758619a..4483e5eb4a 100644 --- a/src/Groups/Collection.php +++ b/src/Groups/Collection.php @@ -1,25 +1,23 @@ getDataStore() - ->saveResource( - '/groups', - $this, - self::class - ); - } - - public function delete() - { - return \Okta\Client::getInstance() - ->getDataStore() - ->deleteResource( - '/groups', - $this - ); - } - - /** - * Get the id. - * - * @return string - */ - public function getId(): string - { - return $this->getProperty(self::ID); - } - /** - * Get the type. - * - * @return string - */ - public function getType(): string - { - return $this->getProperty(self::TYPE); - } - /** - * Get the _links. - * - * @return \stdClass - */ - public function getLinks(): \stdClass - { - return $this->getProperty(self::LINKS); - } - /** - * Get the created. - * - * @return \Carbon\Carbon|null - */ - public function getCreated() - { - return $this->getDateProperty(self::CREATED); - } - /** - * Get the profile. - * - * @return GroupProfile - */ - public function getProfile(array $options = []): GroupProfile - { - return $this->getResourceProperty( - self::PROFILE, - GroupProfile::class, - $options - ); - } - /** - * Set the profile. - * - * @param GroupProfile $profile The GroupProfile instance. - * @return self - */ - public function setProfile(GroupProfile $profile) - { - $this->setResourceProperty( - self::PROFILE, - $profile - ); - - return $this; - } - /** - * Get the _embedded. - * - * @return \stdClass - */ - public function getEmbedded(): \stdClass - { - return $this->getProperty(self::EMBEDDED); - } - /** - * Get the lastUpdated. - * - * @return \Carbon\Carbon|null - */ - public function getLastUpdated() - { - return $this->getDateProperty(self::LAST_UPDATED); - } - /** - * Get the objectClass. - * - * @return array - */ - public function getObjectClass(): array - { - return $this->getProperty(self::OBJECT_CLASS); - } - /** - * Get the lastMembershipUpdated. - * - * @return \Carbon\Carbon|null - */ - public function getLastMembershipUpdated() - { - return $this->getDateProperty(self::LAST_MEMBERSHIP_UPDATED); - } - /** - * Sends a request to the removeUser endpoint. - * - * - * @return mixed|null - */ - public function removeUser($userId) - { - $uri = "/api/v1/groups/{$this->getId()}/users/{$userId}"; - $uri = $this->getDataStore()->buildUri( - $this->getDataStore()->getOrganizationUrl() . $uri - ); - return $this - ->getDataStore() - ->executeRequest('DELETE', $uri); - } - /** - * Get the User object. - * - * @param array $options The options for the request. - * @return Collection - */ - public function getUsers(array $options = []): Collection - { - return $this - ->getDataStore() - ->getCollection( - "/api/v1/groups/{$this->getId()}/users", - User::class, - Collection::class, - $options - ); - } } diff --git a/src/Groups/GroupProfile.php b/src/Groups/GroupProfile.php index d7aeb0a1da..57de6e411c 100644 --- a/src/Groups/GroupProfile.php +++ b/src/Groups/GroupProfile.php @@ -1,75 +1,23 @@ getProperty(self::NAME); - } - /** - * Set the name. - * - * @param mixed $name The value to set. - * @return self - */ - public function setName($name) - { - $this->setProperty( - self::NAME, - $name - ); - - return $this; - } - /** - * Get the description. - * - * @return string - */ - public function getDescription(): string - { - return $this->getProperty(self::DESCRIPTION); - } - /** - * Set the description. - * - * @param mixed $description The value to set. - * @return self - */ - public function setDescription($description) - { - $this->setProperty( - self::DESCRIPTION, - $description - ); - return $this; - } } diff --git a/src/Okta.php b/src/Okta.php index 47f1dcf04c..3d990bdfe9 100644 --- a/src/Okta.php +++ b/src/Okta.php @@ -26,7 +26,7 @@ class Okta { - const VERSION = '0.1.0'; + const VERSION = '0.2.0'; public function __construct(Client $client = null, DefaultDataStore $dataStore = null) { diff --git a/src/Resource/AbstractCollection.php b/src/Resource/AbstractCollection.php index e84b1b4990..189033b72d 100644 --- a/src/Resource/AbstractCollection.php +++ b/src/Resource/AbstractCollection.php @@ -19,7 +19,7 @@ use Illuminate\Support\Arr; use Illuminate\Support\Collection; -use Okta\Users\User; +use Okta\Generated\Users\User; class AbstractCollection extends Collection { diff --git a/src/Sessions/AuthenticationMethod.php b/src/Sessions/AuthenticationMethod.php new file mode 100644 index 0000000000..e9d4facfc3 --- /dev/null +++ b/src/Sessions/AuthenticationMethod.php @@ -0,0 +1,23 @@ +getFactorType(); + + $factorEnum = (new FactorType($factorType)); + + $realFactor = $factorEnum->mapToFactorType(); + + $properties = new \stdClass(); + foreach ($this->getPropertyNames() as $name) { + $properties->$name = $this->getProperty($name); + } + + return new $realFactor(null, $properties); + } +} diff --git a/src/UserFactors/FactorProfile.php b/src/UserFactors/FactorProfile.php new file mode 100644 index 0000000000..415856e02f --- /dev/null +++ b/src/UserFactors/FactorProfile.php @@ -0,0 +1,23 @@ +getValue()) { + case 'call': + return \Okta\UserFactors\CallFactor::class; + case 'push': + return \Okta\UserFactors\PushFactor::class; + case 'question': + return \Okta\UserFactors\SecurityQuestionFactor::class; + case 'sms': + return \Okta\UserFactors\SmsFactor::class; + case 'token': + case 'token:hardware': + return \Okta\UserFactors\TokenFactor::class; + case 'token:software:totp': + return \Okta\UserFactors\TotpFactor::class; + case 'web': + return \Okta\UserFactors\WebFactor::class; + default: + return \Okta\UserFactors\Factor::class; + } + } +} diff --git a/src/UserFactors/HardwareFactor.php b/src/UserFactors/HardwareFactor.php new file mode 100644 index 0000000000..eea74ae03a --- /dev/null +++ b/src/UserFactors/HardwareFactor.php @@ -0,0 +1,23 @@ +getProperty(self::ID); - } - /** - * Get the label. - * - * @return string - */ - public function getLabel(): string - { - return $this->getProperty(self::LABEL); - } - /** - * Get the hidden. - * - * @return bool - */ - public function getHidden(): bool - { - return $this->getProperty(self::HIDDEN); - } - /** - * Get the appName. - * - * @return string - */ - public function getAppName(): string - { - return $this->getProperty(self::APP_NAME); - } - /** - * Get the linkUrl. - * - * @return string - */ - public function getLinkUrl(): string - { - return $this->getProperty(self::LINK_URL); - } - /** - * Get the logoUrl. - * - * @return string - */ - public function getLogoUrl(): string - { - return $this->getProperty(self::LOGO_URL); - } - /** - * Get the sortOrder. - * - * @return int - */ - public function getSortOrder(): int - { - return $this->getProperty(self::SORT_ORDER); - } - /** - * Get the appInstanceId. - * - * @return string - */ - public function getAppInstanceId(): string - { - return $this->getProperty(self::APP_INSTANCE_ID); - } - /** - * Get the appAssignmentId. - * - * @return string - */ - public function getAppAssignmentId(): string - { - return $this->getProperty(self::APP_ASSIGNMENT_ID); - } - /** - * Get the credentialsSetup. - * - * @return bool - */ - public function getCredentialsSetup(): bool - { - return $this->getProperty(self::CREDENTIALS_SETUP); - } } diff --git a/src/Users/AuthenticationProvider.php b/src/Users/AuthenticationProvider.php index 1b69887294..79b852b0a9 100644 --- a/src/Users/AuthenticationProvider.php +++ b/src/Users/AuthenticationProvider.php @@ -1,75 +1,23 @@ getProperty(self::NAME); - } - /** - * Set the name. - * - * @param mixed $name The value to set. - * @return self - */ - public function setName($name) - { - $this->setProperty( - self::NAME, - $name - ); - - return $this; - } - /** - * Get the type. - * - * @return string - */ - public function getType(): string - { - return $this->getProperty(self::TYPE); - } - /** - * Set the type. - * - * @param mixed $type The value to set. - * @return self - */ - public function setType($type) - { - $this->setProperty( - self::TYPE, - $type - ); - return $this; - } } diff --git a/src/Users/AuthenticationProviderType.php b/src/Users/AuthenticationProviderType.php index 6a6bf68d27..8b3dfadead 100644 --- a/src/Users/AuthenticationProviderType.php +++ b/src/Users/AuthenticationProviderType.php @@ -1,25 +1,23 @@ getResourceProperty( - self::NEW_PASSWORD, - PasswordCredential::class, - $options - ); - } - - /** - * Set the newPassword. - * - * @param PasswordCredential $newPassword The PasswordCredential instance. - * @return self - */ - public function setNewPassword(PasswordCredential $newPassword) - { - $this->setResourceProperty( - self::NEW_PASSWORD, - $newPassword - ); - - return $this; - } - /** - * Get the oldPassword. - * - * @return PasswordCredential - */ - public function getOldPassword(array $options = []): PasswordCredential - { - return $this->getResourceProperty( - self::OLD_PASSWORD, - PasswordCredential::class, - $options - ); - } - /** - * Set the oldPassword. - * - * @param PasswordCredential $oldPassword The PasswordCredential instance. - * @return self - */ - public function setOldPassword(PasswordCredential $oldPassword) - { - $this->setResourceProperty( - self::OLD_PASSWORD, - $oldPassword - ); - - return $this; - } } diff --git a/src/Users/Collection.php b/src/Users/Collection.php index a25f696e97..b85e592b79 100644 --- a/src/Users/Collection.php +++ b/src/Users/Collection.php @@ -1,25 +1,23 @@ getProperty(self::RESET_PASSWORD_URL); - } } diff --git a/src/Users/PasswordCredential.php b/src/Users/PasswordCredential.php index f2975fa64d..c86e59d23c 100644 --- a/src/Users/PasswordCredential.php +++ b/src/Users/PasswordCredential.php @@ -1,50 +1,23 @@ getProperty(self::VALUE); - } - /** - * Set the value. - * - * @param mixed $value The value to set. - * @return self - */ - public function setValue($value) - { - $this->setProperty( - self::VALUE, - $value - ); - return $this; - } } diff --git a/src/Users/RecoveryQuestionCredential.php b/src/Users/RecoveryQuestionCredential.php index ec2bda984e..9f7c70c351 100644 --- a/src/Users/RecoveryQuestionCredential.php +++ b/src/Users/RecoveryQuestionCredential.php @@ -1,75 +1,23 @@ getProperty(self::ANSWER); - } - /** - * Set the answer. - * - * @param mixed $answer The value to set. - * @return self - */ - public function setAnswer($answer) - { - $this->setProperty( - self::ANSWER, - $answer - ); - - return $this; - } - /** - * Get the question. - * - * @return string - */ - public function getQuestion(): string - { - return $this->getProperty(self::QUESTION); - } - /** - * Set the question. - * - * @param mixed $question The value to set. - * @return self - */ - public function setQuestion($question) - { - $this->setProperty( - self::QUESTION, - $question - ); - return $this; - } } diff --git a/src/Users/ResetPasswordToken.php b/src/Users/ResetPasswordToken.php index 163cb59560..8cfc23ed78 100644 --- a/src/Users/ResetPasswordToken.php +++ b/src/Users/ResetPasswordToken.php @@ -1,35 +1,23 @@ getProperty(self::RESET_PASSWORD_URL); - } } diff --git a/src/Users/Role.php b/src/Users/Role.php index fdd96d8a3e..b8456d3790 100644 --- a/src/Users/Role.php +++ b/src/Users/Role.php @@ -1,120 +1,23 @@ getProperty(self::ID); - } - /** - * Get the type. - * - * @return string - */ - public function getType(): string - { - return $this->getProperty(self::TYPE); - } - /** - * Get the label. - * - * @return string - */ - public function getLabel(): string - { - return $this->getProperty(self::LABEL); - } - /** - * Get the status. - * - * @return string - */ - public function getStatus(): string - { - return $this->getProperty(self::STATUS); - } - /** - * Get the created. - * - * @return \Carbon\Carbon|null - */ - public function getCreated() - { - return $this->getDateProperty(self::CREATED); - } - /** - * Get the _embedded. - * - * @return \stdClass - */ - public function getEmbedded(): \stdClass - { - return $this->getProperty(self::EMBEDDED); - } - /** - * Get the description. - * - * @return string - */ - public function getDescription(): string - { - return $this->getProperty(self::DESCRIPTION); - } - /** - * Set the description. - * - * @param mixed $description The value to set. - * @return self - */ - public function setDescription($description) - { - $this->setProperty( - self::DESCRIPTION, - $description - ); - return $this; - } - /** - * Get the lastUpdated. - * - * @return \Carbon\Carbon|null - */ - public function getLastUpdated() - { - return $this->getDateProperty(self::LAST_UPDATED); - } } diff --git a/src/Users/RoleStatus.php b/src/Users/RoleStatus.php index c3ef144671..2e06eabb41 100644 --- a/src/Users/RoleStatus.php +++ b/src/Users/RoleStatus.php @@ -1,25 +1,23 @@ getProperty(self::TEMP_PASSWORD); - } } diff --git a/src/Users/User.php b/src/Users/User.php index bba8e73c67..6a8a19a698 100644 --- a/src/Users/User.php +++ b/src/Users/User.php @@ -1,563 +1,44 @@ getDataStore() - ->createResource( - '/users', - $this, - self::class - ); - } + $supportedFactors = parent::getSupportedFactors($options); - public function get($query) - { - return \Okta\Client::getInstance() - ->getDataStore() - ->getResource( - $query, - self::class, - '/users' - ); - } + return $supportedFactors->each(function (Factor $factor, $key) use ($supportedFactors) { - public function save() - { - return \Okta\Client::getInstance() - ->getDataStore() - ->saveResource( - '/users', - $this, - self::class - ); + $supportedFactors[$key] = $factor->convertFromGenericFactor(); + }); } - public function delete() + public function getFactors(array $options = []): \Okta\UserFactors\Collection { - return \Okta\Client::getInstance() - ->getDataStore() - ->deleteResource( - '/users', - $this - ); - } + $supportedFactors = parent::getFactors($options); - /** - * Get the id. - * - * @return string - */ - public function getId(): string - { - return $this->getProperty(self::ID); - } - /** - * Get the _links. - * - * @return \stdClass - */ - public function getLinks(): \stdClass - { - return $this->getProperty(self::LINKS); - } - /** - * Get the status. - * - * @return string - */ - public function getStatus(): string - { - return $this->getProperty(self::STATUS); - } - /** - * Get the created. - * - * @return \Carbon\Carbon|null - */ - public function getCreated() - { - return $this->getDateProperty(self::CREATED); - } - /** - * Get the profile. - * - * @return UserProfile - */ - public function getProfile(array $options = []): UserProfile - { - return $this->getResourceProperty( - self::PROFILE, - UserProfile::class, - $options - ); - } - - /** - * Set the profile. - * - * @param UserProfile $profile The UserProfile instance. - * @return self - */ - public function setProfile(UserProfile $profile) - { - $this->setResourceProperty( - self::PROFILE, - $profile - ); - - return $this; - } - /** - * Get the _embedded. - * - * @return \stdClass - */ - public function getEmbedded(): \stdClass - { - return $this->getProperty(self::EMBEDDED); - } - /** - * Get the activated. - * - * @return \Carbon\Carbon|null - */ - public function getActivated() - { - return $this->getDateProperty(self::ACTIVATED); - } - /** - * Get the lastLogin. - * - * @return \Carbon\Carbon|null - */ - public function getLastLogin() - { - return $this->getDateProperty(self::LAST_LOGIN); - } - /** - * Get the credentials. - * - * @return UserCredentials - */ - public function getCredentials(array $options = []): UserCredentials - { - return $this->getResourceProperty( - self::CREDENTIALS, - UserCredentials::class, - $options - ); - } + return $supportedFactors->each(function (Factor $factor, $key) use ($supportedFactors) { - /** - * Set the credentials. - * - * @param UserCredentials $credentials The UserCredentials instance. - * @return self - */ - public function setCredentials(UserCredentials $credentials) - { - $this->setResourceProperty( - self::CREDENTIALS, - $credentials - ); - - return $this; - } - /** - * Get the lastUpdated. - * - * @return \Carbon\Carbon|null - */ - public function getLastUpdated() - { - return $this->getDateProperty(self::LAST_UPDATED); - } - /** - * Get the statusChanged. - * - * @return \Carbon\Carbon|null - */ - public function getStatusChanged() - { - return $this->getDateProperty(self::STATUS_CHANGED); - } - /** - * Get the passwordChanged. - * - * @return \Carbon\Carbon|null - */ - public function getPasswordChanged() - { - return $this->getDateProperty(self::PASSWORD_CHANGED); - } - /** - * Get the transitioningToStatus. - * - * @return string - */ - public function getTransitioningToStatus(): string - { - return $this->getProperty(self::TRANSITIONING_TO_STATUS); - } - /** - * Get the AppLink object. - * - * @param array $options The options for the request. - * @return Collection - */ - public function getAppLinks(array $options = []): Collection - { - return $this - ->getDataStore() - ->getCollection( - "/api/v1/users/{$this->getId()}/appLinks", - AppLink::class, - Collection::class, - $options - ); - } - /** - * Sends a request to the changePassword endpoint. - * - * - * @return mixed|null - */ - public function changePassword(ChangePasswordRequest $changePasswordRequest) - { - $uri = "/api/v1/users/{$this->getId()}/credentials/change_password"; - $uri = $this->getDataStore()->buildUri( - $this->getDataStore()->getOrganizationUrl() . $uri - ); - return $this - ->getDataStore() - ->executeRequest('POST', $uri, $changePasswordRequest); - } - /** - * Sends a request to the changeRecoveryQuestion endpoint. - * - * - * @return mixed|null - */ - public function changeRecoveryQuestion(UserCredentials $userCredentials) - { - $uri = "/api/v1/users/{$this->getId()}/credentials/change_recovery_question"; - $uri = $this->getDataStore()->buildUri( - $this->getDataStore()->getOrganizationUrl() . $uri - ); - return $this - ->getDataStore() - ->executeRequest('POST', $uri, $userCredentials); - } - /** - * Sends a request to the forgotPassword endpoint. - * - * @param bool $sendEmail Sets the sendEmail flag. - * @return mixed|null - */ - public function forgotPassword(UserCredentials $userCredentials, $sendEmail = true) - { - $uri = "/api/v1/users/{$this->getId()}/credentials/forgot_password"; - $uri = $this->getDataStore()->buildUri( - $this->getDataStore()->getOrganizationUrl() . $uri - ); - return $this - ->getDataStore() - ->executeRequest('POST', $uri, $userCredentials, ['query' => ['sendEmail' => $sendEmail]]); - } - /** - * Get the Role object. - * - * @param array $options The options for the request. - * @return Collection - */ - public function getRoles(array $options = []): Collection - { - return $this - ->getDataStore() - ->getCollection( - "/api/v1/users/{$this->getId()}/roles", - Role::class, - Collection::class, - $options - ); - } - /** - * Sends a request to the addRole endpoint. - * - * - * @return mixed|null - */ - public function addRole(Role $role) - { - $uri = "/api/v1/users/{$this->getId()}/roles"; - $uri = $this->getDataStore()->buildUri( - $this->getDataStore()->getOrganizationUrl() . $uri - ); - return $this - ->getDataStore() - ->executeRequest('POST', $uri, $role); - } - /** - * Sends a request to the removeRole endpoint. - * - * - * @return mixed|null - */ - public function removeRole($roleId) - { - $uri = "/api/v1/users/{$this->getId()}/roles/{$roleId}"; - $uri = $this->getDataStore()->buildUri( - $this->getDataStore()->getOrganizationUrl() . $uri - ); - return $this - ->getDataStore() - ->executeRequest('DELETE', $uri); - } - /** - * Get the Group object. - * - * @param array $options The options for the request. - * @return Collection - */ - public function getGroupTargetsForRole($roleId, array $options = []): Collection - { - return $this - ->getDataStore() - ->getCollection( - "/api/v1/users/{$this->getId()}/roles/{$roleId}/targets/groups", - Group::class, - Collection::class, - $options - ); - } - /** - * Sends a request to the removeGroupTargetFromRole endpoint. - * - * - * @return mixed|null - */ - public function removeGroupTargetFromRole($roleId, $groupId) - { - $uri = "/api/v1/users/{$this->getId()}/roles/{$roleId}/targets/groups/{$groupId}"; - $uri = $this->getDataStore()->buildUri( - $this->getDataStore()->getOrganizationUrl() . $uri - ); - return $this - ->getDataStore() - ->executeRequest('DELETE', $uri); - } - /** - * Sends a request to the addGroupTargetToRole endpoint. - * - * - * @return mixed|null - */ - public function addGroupTargetToRole($roleId, $groupId) - { - $uri = "/api/v1/users/{$this->getId()}/roles/{$roleId}/targets/groups/{$groupId}"; - $uri = $this->getDataStore()->buildUri( - $this->getDataStore()->getOrganizationUrl() . $uri - ); - return $this - ->getDataStore() - ->executeRequest('PUT', $uri); - } - /** - * Get the Group object. - * - * @param array $options The options for the request. - * @return Collection - */ - public function getGroups(array $options = []): Collection - { - return $this - ->getDataStore() - ->getCollection( - "/api/v1/users/{$this->getId()}/groups", - Group::class, - Collection::class, - $options - ); - } - /** - * Sends a request to the activate endpoint. - * - * @param bool $sendEmail Sets the sendEmail flag. - * @return mixed|null - */ - public function activate($sendEmail = true) - { - $uri = "/api/v1/users/{$this->getId()}/lifecycle/activate"; - $uri = $this->getDataStore()->buildUri( - $this->getDataStore()->getOrganizationUrl() . $uri - ); - return $this - ->getDataStore() - ->executeRequest('POST', $uri, '', ['query' => ['sendEmail' => $sendEmail]]); - } - /** - * Sends a request to the deactivate endpoint. - * - * - * @return mixed|null - */ - public function deactivate() - { - $uri = "/api/v1/users/{$this->getId()}/lifecycle/deactivate"; - $uri = $this->getDataStore()->buildUri( - $this->getDataStore()->getOrganizationUrl() . $uri - ); - return $this - ->getDataStore() - ->executeRequest('POST', $uri); - } - /** - * Sends a request to the suspend endpoint. - * - * - * @return mixed|null - */ - public function suspend() - { - $uri = "/api/v1/users/{$this->getId()}/lifecycle/suspend"; - $uri = $this->getDataStore()->buildUri( - $this->getDataStore()->getOrganizationUrl() . $uri - ); - return $this - ->getDataStore() - ->executeRequest('POST', $uri); - } - /** - * Sends a request to the unsuspend endpoint. - * - * - * @return mixed|null - */ - public function unsuspend() - { - $uri = "/api/v1/users/{$this->getId()}/lifecycle/unsuspend"; - $uri = $this->getDataStore()->buildUri( - $this->getDataStore()->getOrganizationUrl() . $uri - ); - return $this - ->getDataStore() - ->executeRequest('POST', $uri); - } - /** - * Sends a request to the resetPassword endpoint. - * - * - * @return mixed|null - */ - public function resetPassword() - { - $uri = "/api/v1/users/{$this->getId()}/lifecycle/reset_password"; - $uri = $this->getDataStore()->buildUri( - $this->getDataStore()->getOrganizationUrl() . $uri - ); - return $this - ->getDataStore() - ->executeRequest('POST', $uri); - } - /** - * Sends a request to the expirePassword endpoint. - * - * - * @return mixed|null - */ - public function expirePassword($tempPassword = false) - { - $uri = "/api/v1/users/{$this->getId()}/lifecycle/expire_password"; - $uri = $this->getDataStore()->buildUri( - $this->getDataStore()->getOrganizationUrl() . $uri - ); - return $this - ->getDataStore() - ->executeRequest('POST', $uri, '', ['query' => ['tempPassword' => $tempPassword]]); - } - /** - * Sends a request to the unlock endpoint. - * - * - * @return mixed|null - */ - public function unlock() - { - $uri = "/api/v1/users/{$this->getId()}/lifecycle/unlock"; - $uri = $this->getDataStore()->buildUri( - $this->getDataStore()->getOrganizationUrl() . $uri - ); - return $this - ->getDataStore() - ->executeRequest('POST', $uri); - } - /** - * Sends a request to the resetFactors endpoint. - * - * - * @return mixed|null - */ - public function resetFactors() - { - $uri = "/api/v1/users/{$this->getId()}/lifecycle/reset_factors"; - $uri = $this->getDataStore()->buildUri( - $this->getDataStore()->getOrganizationUrl() . $uri - ); - return $this - ->getDataStore() - ->executeRequest('POST', $uri); - } - /** - * Sends a request to the addToGroup endpoint. - * - * - * @return mixed|null - */ - public function addToGroup($groupId) - { - $uri = "/api/v1/groups/{$groupId}/users/{$this->getId()}"; - $uri = $this->getDataStore()->buildUri( - $this->getDataStore()->getOrganizationUrl() . $uri - ); - return $this - ->getDataStore() - ->executeRequest('PUT', $uri); + $supportedFactors[$key] = $factor->convertFromGenericFactor(); + }); } } diff --git a/src/Users/UserActivationToken.php b/src/Users/UserActivationToken.php index 852be3efdf..524d81bdda 100644 --- a/src/Users/UserActivationToken.php +++ b/src/Users/UserActivationToken.php @@ -1,45 +1,23 @@ getProperty(self::ACTIVATION_URL); - } - /** - * Get the activationToken. - * - * @return string - */ - public function getActivationToken(): string - { - return $this->getProperty(self::ACTIVATION_TOKEN); - } } diff --git a/src/Users/UserCredentials.php b/src/Users/UserCredentials.php index e3fcd13368..62b439f2b2 100644 --- a/src/Users/UserCredentials.php +++ b/src/Users/UserCredentials.php @@ -1,115 +1,23 @@ getResourceProperty( - self::PASSWORD, - PasswordCredential::class, - $options - ); - } - - /** - * Set the password. - * - * @param PasswordCredential $password The PasswordCredential instance. - * @return self - */ - public function setPassword(PasswordCredential $password) - { - $this->setResourceProperty( - self::PASSWORD, - $password - ); - - return $this; - } - /** - * Get the provider. - * - * @return AuthenticationProvider - */ - public function getProvider(array $options = []): AuthenticationProvider - { - return $this->getResourceProperty( - self::PROVIDER, - AuthenticationProvider::class, - $options - ); - } - - /** - * Set the provider. - * - * @param AuthenticationProvider $provider The AuthenticationProvider instance. - * @return self - */ - public function setProvider(AuthenticationProvider $provider) - { - $this->setResourceProperty( - self::PROVIDER, - $provider - ); - - return $this; - } - /** - * Get the recovery_question. - * - * @return RecoveryQuestionCredential - */ - public function getRecoveryQuestion(array $options = []): RecoveryQuestionCredential - { - return $this->getResourceProperty( - self::RECOVERY_QUESTION, - RecoveryQuestionCredential::class, - $options - ); - } - /** - * Set the recovery_question. - * - * @param RecoveryQuestionCredential $recovery_question The RecoveryQuestionCredential instance. - * @return self - */ - public function setRecoveryQuestion(RecoveryQuestionCredential $recovery_question) - { - $this->setResourceProperty( - self::RECOVERY_QUESTION, - $recovery_question - ); - - return $this; - } } diff --git a/src/Users/UserProfile.php b/src/Users/UserProfile.php index c159f98b90..4e0f4c8e28 100644 --- a/src/Users/UserProfile.php +++ b/src/Users/UserProfile.php @@ -1,175 +1,23 @@ getProperty(self::EMAIL); - } - /** - * Set the email. - * - * @param mixed $email The value to set. - * @return self - */ - public function setEmail($email) - { - $this->setProperty( - self::EMAIL, - $email - ); - - return $this; - } - /** - * Get the login. - * - * @return string - */ - public function getLogin(): string - { - return $this->getProperty(self::LOGIN); - } - /** - * Set the login. - * - * @param mixed $login The value to set. - * @return self - */ - public function setLogin($login) - { - $this->setProperty( - self::LOGIN, - $login - ); - - return $this; - } - /** - * Get the lastName. - * - * @return string - */ - public function getLastName(): string - { - return $this->getProperty(self::LAST_NAME); - } - /** - * Set the lastName. - * - * @param mixed $lastName The value to set. - * @return self - */ - public function setLastName($lastName) - { - $this->setProperty( - self::LAST_NAME, - $lastName - ); - - return $this; - } - /** - * Get the firstName. - * - * @return string - */ - public function getFirstName(): string - { - return $this->getProperty(self::FIRST_NAME); - } - /** - * Set the firstName. - * - * @param mixed $firstName The value to set. - * @return self - */ - public function setFirstName($firstName) - { - $this->setProperty( - self::FIRST_NAME, - $firstName - ); - - return $this; - } - /** - * Get the mobilePhone. - * - * @return string - */ - public function getMobilePhone(): string - { - return $this->getProperty(self::MOBILE_PHONE); - } - /** - * Set the mobilePhone. - * - * @param mixed $mobilePhone The value to set. - * @return self - */ - public function setMobilePhone($mobilePhone) - { - $this->setProperty( - self::MOBILE_PHONE, - $mobilePhone - ); - - return $this; - } - /** - * Get the secondEmail. - * - * @return string - */ - public function getSecondEmail(): string - { - return $this->getProperty(self::SECOND_EMAIL); - } - /** - * Set the secondEmail. - * - * @param mixed $secondEmail The value to set. - * @return self - */ - public function setSecondEmail($secondEmail) - { - $this->setProperty( - self::SECOND_EMAIL, - $secondEmail - ); - return $this; - } } diff --git a/src/Users/UserStatus.php b/src/Users/UserStatus.php index ab43128ea8..413f26177b 100644 --- a/src/Users/UserStatus.php +++ b/src/Users/UserStatus.php @@ -1,25 +1,23 @@ isValid($value)) { + throw new \UnexpectedValueException("Value '$value' is not part of the enum " . get_called_class()); + } + $this->value = $value; + } + + /** + * @return mixed + */ + public function getValue() + { + return $this->value; + } + + /** + * Returns the enum key (i.e. the constant name). + * + * @return mixed + */ + public function getKey() + { + return static::search($this->value); + } + + /** + * @return string + */ + public function __toString() + { + return (string)$this->value; + } + + /** + * Returns the names (keys) of all constants in the Enum class + * + * @return array + */ + public static function keys() + { + return array_keys(static::toArray()); + } + + /** + * Returns instances of the Enum class of all Enum constants + * + * @return static[] Constant name in key, Enum instance in value + */ + public static function values() + { + $values = array(); + foreach (static::toArray() as $key => $value) { + $values[$key] = new static($value); + } + return $values; + } + + /** + * Returns all possible values as an array + * + * @return array Constant name in key, constant value in value + */ + public static function toArray() + { + $class = get_called_class(); + if (!array_key_exists($class, static::$cache)) { + $reflection = new \ReflectionClass($class); + static::$cache[$class] = $reflection->getConstants(); + } + return static::$cache[$class]; + } + + /** + * Check if is valid enum value + * + * @param $value + * + * @return bool + */ + public static function isValid($value) + { + return in_array($value, static::toArray(), true); + } + + /** + * Is this a valid key for the Enum + * + * @param string $key The key to test + * + * @return bool + */ + public static function isValidKey($key) + { + $array = static::toArray(); + return isset($array[$key]); + } + + /** + * Search for a key based on the value. + * + * @param string $value The value you are searching for. + * + * @return mixed + */ + public static function search($value) + { + return array_search($value, static::toArray(), true); + } + + /** + * Returns a value when called statically like so: MyEnum::SOME_VALUE() given SOME_VALUE is a class constant + * + * @param string $name + * @param array $arguments + * + * @return static + * @throws \BadMethodCallException + */ + public static function __callStatic($name, $arguments) + { + $array = static::toArray(); + if (isset($array[$name])) { + return new static($array[$name]); + } + throw new \BadMethodCallException("No static method or enum constant '$name' in class " . get_called_class()); + } + + /** + * Allows you to call methods off one of the enums. + * Methods names are either global (isWorkDay), or prefixed with the enum value (mondayIsStartOfWeek). + * + * @param string $method + * @param mixed $args + * + * @return mixed + * @throws \BadMethodCallException + */ + public function __call($method, $args) + { + $methodStart = lcfirst(str_replace('_', '', ucwords(strtolower($this->getKey()), '_'))); + + $method = ucfirst($method); + if (method_exists($this, $methodStart.$method)) { + return call_user_func_array([$this, $methodStart.$method], $args); + } + throw new \BadMethodCallException("Method {$methodStart}{$method} does not exist"); + } +} diff --git a/tests/BaseTestCase.php b/tests/BaseTestCase.php index 244b48f512..90b3055fb3 100644 --- a/tests/BaseTestCase.php +++ b/tests/BaseTestCase.php @@ -15,9 +15,67 @@ * limitations under the License. * ******************************************************************************/ +use Okta\ClientBuilder; use PHPUnit\Framework\TestCase; class BaseTestCase extends TestCase { + protected $token = 'abc123'; + + public static function setUpBeforeClass() + { + parent::setUpBeforeClass(); + (new ClientBuilder())->build(); + } + + /** + * @param array $returns + * + * @return \Http\Mock\Client + */ + protected function createNewHttpClient($returns = []): \Http\Mock\Client + { + $defaults = [ + 'getStatusCode' => 200, + 'getBody' => '{}' + ]; + + $mockReturns = array_replace_recursive($defaults, $returns); + + $httpClient = new \Http\Mock\Client; + + $response = $this->createMock('Psr\Http\Message\ResponseInterface'); + + foreach($mockReturns as $method=>$return) { + $response->method($method)->willReturn($return); + + } + $httpClient->addResponse($response); + + (new \Okta\ClientBuilder()) + ->setOrganizationUrl('https://dev.okta.com') + ->setToken($this->token) + ->setHttpClient($httpClient) + ->build(); + return $httpClient; + } + + protected function createNewUser($properties = []): \Okta\Users\User + { + $defaults = json_decode( + file_get_contents(__DIR__ . '/models/user.json'), + true + ); + + $properties = array_replace_recursive($defaults, $properties); + + $class = new \stdClass(); + foreach($properties as $prop=>$value) + { + $class->{$prop} = $value; + } + return new \Okta\Users\User(null, $class); + + } } \ No newline at end of file diff --git a/tests/BaseUnitTestCase.php b/tests/BaseUnitTestCase.php new file mode 100644 index 0000000000..8abba307fa --- /dev/null +++ b/tests/BaseUnitTestCase.php @@ -0,0 +1,64 @@ +properties = json_decode($this->getModelJson($this->model)); + $this->testable = $this->createModel($this->model, $this->modelType); + } + + protected function createModel($model, $returnType, $properties = []) + { + $properties = json_decode($this->getModel($model, $properties)); + + $class = new \stdClass(); + foreach($properties as $prop=>$value) + { + $class->{$prop} = $value; + } + + return new $returnType(null, $class); + } + + protected function getModel($model, $overrides = []) + { + $model = json_decode($this->getModelJson($model), true); + + return json_encode(array_replace_recursive($model, $overrides)); + + } + + protected function getModelJson($model) + { + if(is_readable($fileName = __DIR__ . "/models/{$model}")) { + return (string) file_get_contents($fileName); + } + return (string)$model; + } +} \ No newline at end of file diff --git a/tests/Integration/ApplicationsTest.php b/tests/Integration/ApplicationsTest.php new file mode 100644 index 0000000000..64177099d4 --- /dev/null +++ b/tests/Integration/ApplicationsTest.php @@ -0,0 +1,259 @@ +createNewHttpClient([ + 'getBody' => file_get_contents(__DIR__ . '/../responses/applications/samlApplication.json') + ]); + + $application = new \Okta\Applications\Application(); + $app = $application->get('application123'); + + $requests = $client->getRequests(); + + + $this->assertEquals( + "/api/v1/apps/application123", + $requests[0]->getUri()->getPath() + ); + + $this->assertInstanceOf(\Okta\Applications\SamlApplication::class, $app); + $this->assertequals('application/json', $requests[0]->getHeaderLine('Accept')); + $this->assertEmpty($requests[0]->getHeaderLine('Content-Type')); + $this->assertEquals("SSWS {$this->token}", $requests[0]->getHeaderLine('Authorization')); + + } + + /** @test */ + public function an_swa_application_can_be_retrieved_by_id() + { + $client = $this->createNewHttpClient([ + 'getBody' => file_get_contents(__DIR__ . '/../responses/applications/swaApplication.json') + ]); + + $application = new \Okta\Applications\Application(); + $app = $application->get('application123'); + + $requests = $client->getRequests(); + + + $this->assertEquals( + "/api/v1/apps/application123", + $requests[0]->getUri()->getPath() + ); + + $this->assertInstanceOf(\Okta\Applications\SwaApplication::class, $app); + $this->assertequals('application/json', $requests[0]->getHeaderLine('Accept')); + $this->assertEmpty($requests[0]->getHeaderLine('Content-Type')); + $this->assertEquals("SSWS {$this->token}", $requests[0]->getHeaderLine('Authorization')); + + } + + /** @test */ + public function a_bookmark_application_returns_correct_application() + { + $client = $this->createNewHttpClient([ + 'getBody' => '{"id":"abc123", "signOnMode": "BOOKMARK"}' + ]); + + $application = new \Okta\Applications\Application(); + $app = $application->get('application123'); + + $requests = $client->getRequests(); + + + $this->assertEquals( + "/api/v1/apps/application123", + $requests[0]->getUri()->getPath() + ); + + $this->assertInstanceOf(\Okta\Applications\BookmarkApplication::class, $app); + } + + /** @test */ + public function a_basic_auth_application_returns_correct_application() + { + $client = $this->createNewHttpClient([ + 'getBody' => '{"id":"abc123", "signOnMode": "BASIC_AUTH"}' + ]); + + $application = new \Okta\Applications\Application(); + $app = $application->get('application123'); + + $requests = $client->getRequests(); + + + $this->assertEquals( + "/api/v1/apps/application123", + $requests[0]->getUri()->getPath() + ); + + $this->assertInstanceOf(\Okta\Applications\BasicAuthApplication::class, $app); + } + + /** @test */ + public function a_swa_application_returns_correct_application() + { + $client = $this->createNewHttpClient([ + 'getBody' => '{"id":"abc123", "signOnMode": "BROWSER_PLUGIN", "name": "template_swa"}' + ]); + + $application = new \Okta\Applications\Application(); + $app = $application->get('application123'); + + $requests = $client->getRequests(); + + + $this->assertEquals( + "/api/v1/apps/application123", + $requests[0]->getUri()->getPath() + ); + + $this->assertInstanceOf(\Okta\Applications\SwaApplication::class, $app); + } + + /** @test */ + public function a_swa_3_field_application_returns_correct_application() + { + $client = $this->createNewHttpClient([ + 'getBody' => '{"id":"abc123", "signOnMode": "BROWSER_PLUGIN", "name": "template_swa3field"}' + ]); + + $application = new \Okta\Applications\Application(); + $app = $application->get('application123'); + + $requests = $client->getRequests(); + + + $this->assertEquals( + "/api/v1/apps/application123", + $requests[0]->getUri()->getPath() + ); + + $this->assertInstanceOf(\Okta\Applications\SwaThreeFieldApplication::class, $app); + } + + /** @test */ + public function a_secure_password_store_application_returns_correct_application() + { + $client = $this->createNewHttpClient([ + 'getBody' => '{"id":"abc123", "signOnMode": "SECURE_PASSWORD_STORE"}' + ]); + + $application = new \Okta\Applications\Application(); + $app = $application->get('application123'); + + $requests = $client->getRequests(); + + + $this->assertEquals( + "/api/v1/apps/application123", + $requests[0]->getUri()->getPath() + ); + + $this->assertInstanceOf(\Okta\Applications\SecurePasswordStoreApplication::class, $app); + } + + /** @test */ + public function a_auto_login_application_returns_correct_application() + { + $client = $this->createNewHttpClient([ + 'getBody' => '{"id":"abc123", "signOnMode": "AUTO_LOGIN"}' + ]); + + $application = new \Okta\Applications\Application(); + $app = $application->get('application123'); + + $requests = $client->getRequests(); + + + $this->assertEquals( + "/api/v1/apps/application123", + $requests[0]->getUri()->getPath() + ); + + $this->assertInstanceOf(\Okta\Applications\AutoLoginApplication::class, $app); + } + + /** @test */ + public function a_ws_federation_application_returns_correct_application() + { + $client = $this->createNewHttpClient([ + 'getBody' => '{"id":"abc123", "signOnMode": "WS_FEDERATION"}' + ]); + + $application = new \Okta\Applications\Application(); + $app = $application->get('application123'); + + $requests = $client->getRequests(); + + + $this->assertEquals( + "/api/v1/apps/application123", + $requests[0]->getUri()->getPath() + ); + + $this->assertInstanceOf(\Okta\Applications\WsFederationApplication::class, $app); + } + + /** @test */ + public function a_saml_2_0_application_returns_correct_application() + { + $client = $this->createNewHttpClient([ + 'getBody' => '{"id":"abc123", "signOnMode": "SAML_2_0"}' + ]); + + $application = new \Okta\Applications\Application(); + $app = $application->get('application123'); + + $requests = $client->getRequests(); + + + $this->assertEquals( + "/api/v1/apps/application123", + $requests[0]->getUri()->getPath() + ); + + $this->assertInstanceOf(\Okta\Applications\SamlApplication::class, $app); + } + + /** @test */ + public function a_openid_connect_application_returns_correct_application() + { + $client = $this->createNewHttpClient([ + 'getBody' => '{"id":"abc123", "signOnMode": "OPENID_CONNECT"}' + ]); + + $application = new \Okta\Applications\Application(); + $app = $application->get('application123'); + + $requests = $client->getRequests(); + + + $this->assertEquals( + "/api/v1/apps/application123", + $requests[0]->getUri()->getPath() + ); + + $this->assertInstanceOf(\Okta\Applications\OpenIdConnectApplication::class, $app); + } +} diff --git a/tests/Integration/FactorsTest.php b/tests/Integration/FactorsTest.php new file mode 100644 index 0000000000..eab2f08a59 --- /dev/null +++ b/tests/Integration/FactorsTest.php @@ -0,0 +1,103 @@ +createNewHttpClient([ + 'getBody' => file_get_contents(__DIR__ . '/../responses/factors/getFactor.json') + ]); + + $user = $this->createNewUser(); + $factor = $user->getFactor('FactorId123'); + $requests = $client->getRequests(); + + + $this->assertEquals("/api/v1/users/{$user->getId()}/factors/FactorId123", $requests[0]->getUri()->getPath()); + + $this->assertInstanceOf(\Okta\UserFactors\SmsFactor::class, $factor); + $this->assertequals('application/json', $requests[0]->getHeaderLine('Accept')); + $this->assertEmpty($requests[0]->getHeaderLine('Content-Type')); + $this->assertEquals("SSWS {$this->token}", $requests[0]->getHeaderLine('Authorization')); + + } + + + + /** @test */ + public function can_list_all_enrolled_factors() + { + $client = $this->createNewHttpClient([ + 'getBody' => file_get_contents(__DIR__ . '/../responses/factors/listEnrolledFactors.json') + ]); + + + $user = $this->createNewUser(); + $allFactors = $user->getFactors(); + + $requests = $client->getRequests(); + + $this->assertEquals("/api/v1/users/{$user->getId()}/factors", $requests[0]->getUri()->getPath()); + + $this->assertInstanceOf(\Okta\UserFactors\Collection::class, $allFactors); + $this->assertequals('application/json', $requests[0]->getHeaderLine('Accept')); + $this->assertEmpty($requests[0]->getHeaderLine('Content-Type')); + $this->assertEquals("SSWS {$this->token}", $requests[0]->getHeaderLine('Authorization')); + + $this->assertCount(3, $allFactors); + $this->assertInstanceof(\Okta\UserFactors\SecurityQuestionFactor::class, $allFactors[0]); + $this->assertInstanceof(\Okta\UserFactors\TotpFactor::class, $allFactors[1]); + $this->assertInstanceof(\Okta\UserFactors\SmsFactor::class, $allFactors[2]); + + } + + /** @test */ + public function can_list_all_factors_to_enroll() + { + $client = $this->createNewHttpClient([ + 'getBody' => file_get_contents(__DIR__ . '/../responses/factors/listFactorsToEnroll.json') + ]); + + + $user = $this->createNewUser(); + $allFactors = $user->getSupportedFactors(); + + $requests = $client->getRequests(); + + $this->assertEquals("/api/v1/users/{$user->getId()}/factors/catalog", $requests[0]->getUri()->getPath()); + + $this->assertInstanceOf(\Okta\UserFactors\Collection::class, $allFactors); + $this->assertequals('application/json', $requests[0]->getHeaderLine('Accept')); + $this->assertEmpty($requests[0]->getHeaderLine('Content-Type')); + $this->assertEquals("SSWS {$this->token}", $requests[0]->getHeaderLine('Authorization')); + + $this->assertCount(7, $allFactors); + + $this->assertInstanceof(\Okta\UserFactors\SecurityQuestionFactor::class, $allFactors[0]); + $this->assertInstanceof(\Okta\UserFactors\TotpFactor::class, $allFactors[1]); + $this->assertInstanceof(\Okta\UserFactors\TotpFactor::class, $allFactors[2]); + $this->assertInstanceof(\Okta\UserFactors\SmsFactor::class, $allFactors[3]); + $this->assertInstanceof(\Okta\UserFactors\CallFactor::class, $allFactors[4]); + $this->assertInstanceof(\Okta\UserFactors\TokenFactor::class, $allFactors[5]); + $this->assertInstanceof(\Okta\UserFactors\TokenFactor::class, $allFactors[6]); + } + + +} diff --git a/tests/Unit/Applications/AppUserCredentialsTest.php b/tests/Unit/Applications/AppUserCredentialsTest.php new file mode 100644 index 0000000000..acee06d418 --- /dev/null +++ b/tests/Unit/Applications/AppUserCredentialsTest.php @@ -0,0 +1,69 @@ +assertInstanceOf(\Okta\Applications\AppUserPasswordCredential::class, $this->testable->getPassword()); + $this->assertInstanceOf(\Okta\Applications\AppUserPasswordCredential::class, $this->testable->password); + } + + /** @test */ + public function password_is_settable() + { + $password = $this->testable->getPassword(); + $password->value = '123abc'; + $this->testable->setPassword($password); + $this->assertEquals('123abc', $this->testable->getPassword()->value); + + $password->value = '789xyz'; + $this->testable->password = $password; + $this->assertEquals('789xyz', $this->testable->getPassword()->value); + } + + /** @test */ + public function user_name_is_accessible() + { + $this->assertEquals($this->properties->userName, $this->testable->getUserName()); + $this->assertEquals($this->properties->userName, $this->testable->userName); + } + + /** @test */ + public function user_name_is_settable() + { + $this->testable->setUserName('abc'); + $this->assertEquals('abc', $this->testable->getUserName()); + + $this->testable->userName = 'xyz'; + $this->assertEquals('xyz', $this->testable->getUserName()); + } + + +} diff --git a/tests/Unit/Applications/AppUserPasswordCredentialTest.php b/tests/Unit/Applications/AppUserPasswordCredentialTest.php new file mode 100644 index 0000000000..3928b816e7 --- /dev/null +++ b/tests/Unit/Applications/AppUserPasswordCredentialTest.php @@ -0,0 +1,48 @@ +assertEquals($this->properties->value, $this->testable->getValue()); + $this->assertEquals($this->properties->value, $this->testable->value); + } + + /** @test */ + public function value_is_settable() + { + $this->testable->setValue('xyz'); + $this->assertEquals('xyz', $this->testable->getValue()); + + $this->testable->value = '123'; + $this->assertEquals('123', $this->testable->getValue()); + } + +} diff --git a/tests/Unit/Applications/AppUserTest.php b/tests/Unit/Applications/AppUserTest.php new file mode 100644 index 0000000000..236cfcdf4c --- /dev/null +++ b/tests/Unit/Applications/AppUserTest.php @@ -0,0 +1,213 @@ +createNewHttpClient(); + $this->testable->save('application1123'); + + $requests = $client->getRequests(); + + $this->assertEquals( + "/api/v1/apps/application1123/users/{$this->testable->getId()}", + $requests[0]->getUri()->getPath() + ); + $this->assertEquals('POST', $requests[0]->getMethod()); + } + + /** @test */ + public function saving_an_application_user_will_return_correct_type() + { + $client = $this->createNewHttpClient(); + + $app = $this->testable->save('application1123'); + + $this->assertInstanceOf(AppUser::class, $app); + } + + /** @test */ + public function deleting_an_application_makes_requests_to_correct_endpoint() + { + $client = $this->createNewHttpClient(); + $this->testable->delete('application123'); + + $requests = $client->getRequests(); + + $this->assertEquals("/api/v1/apps/application123/users/{$this->testable->getId()}", $requests[0]->getUri()->getPath()); + $this->assertEquals('DELETE', $requests[0]->getMethod()); + } + + /** @test */ + public function id_is_accessible() + { + $this->assertEquals($this->properties->id, $this->testable->getId()); + $this->assertEquals($this->properties->id, $this->testable->id); + } + + /** @test */ + public function id_is_settable() + { + $this->testable->setId('abc'); + $this->assertEquals('abc', $this->testable->getId()); + + $this->testable->id = '123'; + $this->assertEquals('123', $this->testable->getId()); + } + + /** @test */ + public function scope_is_accessible() + { + $this->assertEquals($this->properties->scope, $this->testable->getScope()); + $this->assertEquals($this->properties->scope, $this->testable->scope); + } + + /** @test */ + public function scope_is_settable() + { + $this->testable->setScope('USER'); + $this->assertEquals('USER', $this->testable->getScope()); + + $this->testable->scope = 'GROUP'; + $this->assertEquals('GROUP', $this->testable->getScope()); + } + + /** @test */ + public function links_is_accessible() + { + $this->assertEquals($this->properties->_links, $this->testable->getLinks()); + $this->assertEquals($this->properties->_links, $this->testable->links); + } + + /** @test */ + public function status_is_accessible() + { + $this->assertEquals($this->properties->status, $this->testable->getStatus()); + $this->assertEquals($this->properties->status, $this->testable->status); + } + + /** @test */ + public function created_is_accessible() + { + $ts = Carbon::parse($this->properties->created)->timestamp; + $this->assertInstanceOf(\Carbon\Carbon::class, $this->testable->created); + $this->assertEquals($ts, $this->testable->getCreated()->timestamp); + $this->assertEquals($ts, $this->testable->created->timestamp); + } + + /** @test */ + public function profile_is_accessible() + { + $this->assertEquals($this->properties->profile, $this->testable->getProfile()); + $this->assertEquals($this->properties->profile, $this->testable->profile); + } + + /** @test */ + public function last_sync_is_accessible() + { + $ts = Carbon::parse($this->properties->lastSync)->timestamp; + $this->assertInstanceOf(\Carbon\Carbon::class, $this->testable->lastSync); + $this->assertEquals($ts, $this->testable->getLastSync()->timestamp); + $this->assertEquals($ts, $this->testable->lastSync->timestamp); + } + + /** @test */ + public function embedded_is_accessible() + { + $this->assertEquals($this->properties->_embedded, $this->testable->getEmbedded()); + $this->assertEquals($this->properties->_embedded, $this->testable->embedded); + } + + /** @test */ + public function sync_state_is_accessible() + { + $this->assertEquals($this->properties->syncState, $this->testable->getSyncState()); + $this->assertEquals($this->properties->syncState, $this->testable->syncState); + } + + /** @test */ + public function external_id_is_accessible() + { + $this->assertEquals($this->properties->externalId, $this->testable->getExternalId()); + $this->assertEquals($this->properties->externalId, $this->testable->externalId); + } + + /** @test */ + public function credentials_is_accessible() + { + $this->assertInstanceOf(\Okta\Applications\AppUserCredentials::class, $this->testable->getCredentials()); + $this->assertInstanceOf(\Okta\Applications\AppUserCredentials::class, $this->testable->credentials); + } + + /** @test */ + public function credentials_is_settable() + { + $credentials = $this->testable->getCredentials(); + $credentials->username = "username"; + $this->testable->setCredentials($credentials); + $this->assertEquals('username', $this->testable->getCredentials()->username); + + $credentials->username = "login"; + $this->testable->credentials = $credentials; + $this->assertEquals('login', $this->testable->getCredentials()->username); + } + + /** @test */ + public function last_updated_is_accessible() + { + $ts = Carbon::parse($this->properties->lastUpdated)->timestamp; + $this->assertInstanceOf(\Carbon\Carbon::class, $this->testable->lastUpdated); + $this->assertEquals($ts, $this->testable->getLastUpdated()->timestamp); + $this->assertEquals($ts, $this->testable->lastUpdated->timestamp); + } + + /** @test */ + public function status_changed_is_accessible() + { + $ts = Carbon::parse($this->properties->statusChanged)->timestamp; + $this->assertInstanceOf(\Carbon\Carbon::class, $this->testable->statusChanged); + $this->assertEquals($ts, $this->testable->getStatusChanged()->timestamp); + $this->assertEquals($ts, $this->testable->statusChanged->timestamp); + } + + /** @test */ + public function password_changed_is_accessible() + { + $ts = Carbon::parse($this->properties->passwordChanged)->timestamp; + $this->assertInstanceOf(\Carbon\Carbon::class, $this->testable->passwordChanged); + $this->assertEquals($ts, $this->testable->getPasswordChanged()->timestamp); + $this->assertEquals($ts, $this->testable->passwordChanged->timestamp); + } + + + + +} diff --git a/tests/Unit/Applications/ApplicationAccessibilityTest.php b/tests/Unit/Applications/ApplicationAccessibilityTest.php new file mode 100644 index 0000000000..d19797a3da --- /dev/null +++ b/tests/Unit/Applications/ApplicationAccessibilityTest.php @@ -0,0 +1,89 @@ +assertEquals($this->properties->selfService, $this->testable->getSelfService()); + $this->assertEquals($this->properties->selfService, $this->testable->selfService); + } + + /** @test */ + public function self_service_is_settable() + { + $this->testable->setSelfService(true); + $this->assertEquals(true, $this->testable->getSelfService()); + + $this->testable->selfService = false; + $this->assertEquals(false, $this->testable->getSelfService()); + } + + /** @test */ + public function error_redirect_url_is_accessible() + { + $this->assertEquals($this->properties->errorRedirectUrl, $this->testable->getErrorRedirectUrl()); + $this->assertEquals($this->properties->errorRedirectUrl, $this->testable->errorRedirectUrl); + } + + /** @test */ + public function error_redirect_url_is_settable() + { + $this->testable->setErrorRedirectUrl('http://example.com'); + $this->assertEquals('http://example.com', $this->testable->getErrorRedirectUrl()); + + $this->testable->errorRedirectUrl = 'http://example.net'; + $this->assertEquals('http://example.net', $this->testable->getErrorRedirectUrl()); + } + + /** @test */ + public function login_redirect_url_is_accessible() + { + $this->assertEquals($this->properties->loginRedirectUrl, $this->testable->getLoginRedirectUrl()); + $this->assertEquals($this->properties->loginRedirectUrl, $this->testable->loginRedirectUrl); + } + + /** @test */ + public function login_redirect_url_is_settable() + { + $this->testable->setLoginRedirectUrl('http://test.com'); + $this->assertEquals('http://test.com', $this->testable->getLoginRedirectUrl()); + + $this->testable->loginRedirectUrl = 'http://example.com'; + $this->assertEquals('http://example.com', $this->testable->getLoginRedirectUrl()); + } + +} \ No newline at end of file diff --git a/tests/Unit/Applications/ApplicationCredentialsOAuthClientTest.php b/tests/Unit/Applications/ApplicationCredentialsOAuthClientTest.php new file mode 100644 index 0000000000..1cf20c223c --- /dev/null +++ b/tests/Unit/Applications/ApplicationCredentialsOAuthClientTest.php @@ -0,0 +1,105 @@ +assertEquals($this->properties->client_id, $this->testable->getClientId()); + $this->assertEquals($this->properties->client_id, $this->testable->clientId); + } + + /** @test */ + public function client_id_is_settable() + { + $this->testable->setClientId('id1'); + $this->assertEquals('id1', $this->testable->getClientId()); + + $this->testable->clientId = 'id2'; + $this->assertEquals('id2', $this->testable->getClientId()); + } + + /** @test */ + public function client_secret_is_accessible() + { + $this->assertEquals($this->properties->client_secret, $this->testable->getClientSecret()); + $this->assertEquals($this->properties->client_secret, $this->testable->clientSecret); + } + + /** @test */ + public function client_secret_is_settable() + { + $this->testable->setClientSecret('secret1'); + $this->assertEquals('secret1', $this->testable->getClientSecret()); + + $this->testable->clientSecret = 'secret2'; + $this->assertEquals('secret2', $this->testable->getClientSecret()); + } + + /** @test */ + public function auto_key_rotation_is_accessible() + { + $this->assertEquals($this->properties->autoKeyRotation, $this->testable->getAutoKeyRotation()); + $this->assertEquals($this->properties->autoKeyRotation, $this->testable->autoKeyRotation); + } + + /** @test */ + public function auto_key_rotation_is_settable() + { + $this->testable->setAutoKeyRotation(true); + $this->assertEquals(true, $this->testable->getAutoKeyRotation()); + + $this->testable->autoKeyRotation = false; + $this->assertEquals(false, $this->testable->getAutoKeyRotation()); + } + + /** @test */ + public function token_endpoint_auth_method_is_accessible() + { + $this->assertEquals($this->properties->token_endpoint_auth_method, $this->testable->getTokenEndpointAuthMethod()); + $this->assertEquals($this->properties->token_endpoint_auth_method, $this->testable->tokenEndpointAuthMethod); + } + + /** @test */ + public function token_endpoint_auth_method_is_settable() + { + $this->testable->setTokenEndpointAuthMethod('client_credentials'); + $this->assertEquals('client_credentials', $this->testable->getTokenEndpointAuthMethod()); + + $this->testable->tokenEndpointAuthMethod = 'another_method'; + $this->assertEquals('another_method', $this->testable->getTokenEndpointAuthMethod()); + } + + +} diff --git a/tests/Unit/Applications/ApplicationCredentialsSigningTest.php b/tests/Unit/Applications/ApplicationCredentialsSigningTest.php new file mode 100644 index 0000000000..e65d46dd81 --- /dev/null +++ b/tests/Unit/Applications/ApplicationCredentialsSigningTest.php @@ -0,0 +1,89 @@ +assertEquals($this->properties->kid, $this->testable->getKid()); + $this->assertEquals($this->properties->kid, $this->testable->kid); + } + + /** @test */ + public function kid_is_settable() + { + $this->testable->setKid('abc'); + $this->assertEquals('abc', $this->testable->getKid()); + + $this->testable->kid = '123'; + $this->assertEquals('123', $this->testable->getKid()); + } + + /** @test */ + public function last_rotated_is_accessible() + { + $ts = Carbon::parse($this->properties->lastRotated)->timestamp; + $this->assertInstanceOf(\Carbon\Carbon::class, $this->testable->lastRotated); + $this->assertEquals($ts, $this->testable->getLastRotated()->timestamp); + $this->assertEquals($ts, $this->testable->lastRotated->timestamp); + } + + /** @test */ + public function next_Rotation_is_accessible() + { + $ts = Carbon::parse($this->properties->nextRotation)->timestamp; + $this->assertInstanceOf(\Carbon\Carbon::class, $this->testable->nextRotation); + $this->assertEquals($ts, $this->testable->getNextRotation()->timestamp); + $this->assertEquals($ts, $this->testable->nextRotation->timestamp); + } + + /** @test */ + public function rotation_mode_is_accessible() + { + $this->assertEquals($this->properties->rotationMode, $this->testable->getRotationMode()); + $this->assertEquals($this->properties->rotationMode, $this->testable->rotationMode); + } + + /** @test */ + public function rotation_mode_is_settable() + { + $this->testable->setRotationMode('example'); + $this->assertEquals('example', $this->testable->getRotationMode()); + + $this->testable->rotationMode = 'something'; + $this->assertEquals('something', $this->testable->getRotationMode()); + } + +} diff --git a/tests/Unit/Applications/ApplicationCredentialsTest.php b/tests/Unit/Applications/ApplicationCredentialsTest.php new file mode 100644 index 0000000000..96fa684072 --- /dev/null +++ b/tests/Unit/Applications/ApplicationCredentialsTest.php @@ -0,0 +1,93 @@ +assertInstanceOf(\Okta\Applications\ApplicationCredentialsSigning::class, $this->testable->getSigning()); + $this->assertInstanceOf(\Okta\Applications\ApplicationCredentialsSigning::class, $this->testable->signing); + } + + /** @test */ + public function signing_is_settable() + { + $signing1 = $this->testable->getSigning(); + $signing2 = $this->testable->getSigning(); + + $signing1->setKid('abc'); + $signing2->setKid('123'); + + $this->testable->setSigning($signing1); + $this->assertEquals('abc', $this->testable->getSigning()->kid); + + $this->testable->signing = $signing2; + $this->assertEquals('123', $this->testable->getSigning()->kid); + } + + /** @test */ + public function user_name_template_is_accessible() + { + $this->assertInstanceOf(\Okta\Applications\ApplicationCredentialsUsernameTemplate::class, + $this->testable->getUserNameTemplate()); + $this->assertInstanceOf(\Okta\Applications\ApplicationCredentialsUsernameTemplate::class, + $this->testable->userNameTemplate); + } + + /** @test */ + public function user_name_template_is_settable() + { + $userNameTemplate1 = $this->testable->getUserNameTemplate(); + $userNameTemplate2 = $this->testable->getUserNameTemplate(); + + $userNameTemplate1->setTemplate('${source.email}'); + $userNameTemplate2->setTemplate('${source.username}'); + + $this->testable->setUserNameTemplate($userNameTemplate1); + $this->assertEquals('${source.email}', $this->testable->getUserNameTemplate()->template); + + $this->testable->userNameTemplate = $userNameTemplate2; + $this->assertEquals('${source.username}', $this->testable->getUserNameTemplate()->template); + } + + +} \ No newline at end of file diff --git a/tests/Unit/Applications/ApplicationCredentialsUsernameTemplateTest.php b/tests/Unit/Applications/ApplicationCredentialsUsernameTemplateTest.php new file mode 100644 index 0000000000..5ab7bfd66c --- /dev/null +++ b/tests/Unit/Applications/ApplicationCredentialsUsernameTemplateTest.php @@ -0,0 +1,89 @@ +assertEquals($this->properties->type, $this->testable->getType()); + $this->assertEquals($this->properties->type, $this->testable->type); + } + + /** @test */ + public function type_is_settable() + { + $this->testable->setType("NONE"); + $this->assertEquals("NONE", $this->testable->getType()); + + $this->testable->type = "CUSTOM"; + $this->assertEquals("CUSTOM", $this->testable->getType()); + } + + /** @test */ + public function suffix_is_accessible() + { + $this->assertEquals($this->properties->suffix, $this->testable->getSuffix()); + $this->assertEquals($this->properties->suffix, $this->testable->suffix); + } + + /** @test */ + public function suffix_is_settable() + { + $this->testable->setSuffix('sample'); + $this->assertEquals('sample', $this->testable->getSuffix()); + + $this->testable->suffix = 'demo'; + $this->assertEquals('demo', $this->testable->getSuffix()); + } + + /** @test */ + public function template_is_accessible() + { + $this->assertEquals($this->properties->template, $this->testable->getTemplate()); + $this->assertEquals($this->properties->template, $this->testable->template); + } + + /** @test */ + public function template_is_settable() + { + $this->testable->setTemplate('${source.username}'); + $this->assertEquals('${source.username}', $this->testable->getTemplate()); + + $this->testable->template = '${source.email}'; + $this->assertEquals('${source.email}', $this->testable->getTemplate()); + } + + + + +} diff --git a/tests/Unit/Applications/ApplicationGroupAssignmentTest.php b/tests/Unit/Applications/ApplicationGroupAssignmentTest.php new file mode 100644 index 0000000000..ba966cfc87 --- /dev/null +++ b/tests/Unit/Applications/ApplicationGroupAssignmentTest.php @@ -0,0 +1,119 @@ +createNewHttpClient(); + $this->testable->delete('application123'); + + $requests = $client->getRequests(); + + $this->assertEquals( + "/api/v1/apps/application123/group/{$this->testable->getId()}", + $requests[0]->getUri()->getPath() + ); + $this->assertEquals('DELETE', $requests[0]->getMethod()); + } + + /** @test */ + public function id_is_accessible() + { + $this->assertEquals($this->properties->id, $this->testable->getId()); + $this->assertEquals($this->properties->id, $this->testable->id); + } + + /** @test */ + public function links_is_accessible() + { + $this->assertEquals($this->properties->_links, $this->testable->getLinks()); + $this->assertEquals($this->properties->_links, $this->testable->links); + } + + /** @test */ + public function profile_is_accessible() + { + $this->assertEquals($this->properties->profile, $this->testable->getProfile()); + $this->assertEquals($this->properties->profile, $this->testable->profile); + } + + /** @test */ + public function profile_is_settable() + { + $profile = $this->testable->getProfile(); + + $profile->email = 'email1@mailinator.com'; + + $this->testable->setProfile($profile); + $this->assertEquals('email1@mailinator.com', $this->testable->getProfile()->email); + + $this->testable->profile = $profile; + + $profile->email = 'email2@mailinator.com'; + + $this->assertEquals('email2@mailinator.com', $this->testable->getProfile()->email); + } + + /** @test */ + public function priority_is_accessible() + { + $this->assertEquals($this->properties->priority, $this->testable->getPriority()); + $this->assertEquals($this->properties->priority, $this->testable->priority); + } + + /** @test */ + public function priority_is_settable() + { + $this->testable->setPriority(1); + $this->assertEquals(1, $this->testable->getPriority()); + + $this->testable->priority = 2; + $this->assertEquals(2, $this->testable->getPriority()); + } + + /** @test */ + public function embedded_is_accessible() + { + $this->assertEquals($this->properties->_embedded, $this->testable->getEmbedded()); + $this->assertEquals($this->properties->_embedded, $this->testable->embedded); + } + + /** @test */ + public function last_updated_is_accessible() + { + $ts = Carbon::parse($this->properties->lastUpdated)->timestamp; + $this->assertInstanceOf(\Carbon\Carbon::class, $this->testable->lastUpdated); + $this->assertEquals($ts, $this->testable->getLastUpdated()->timestamp); + $this->assertEquals($ts, $this->testable->lastUpdated->timestamp); + } + + +} diff --git a/tests/Unit/Applications/ApplicationLicensingTest.php b/tests/Unit/Applications/ApplicationLicensingTest.php new file mode 100644 index 0000000000..cbe4154d97 --- /dev/null +++ b/tests/Unit/Applications/ApplicationLicensingTest.php @@ -0,0 +1,48 @@ +assertEquals($this->properties->seatCount, $this->testable->getSeatCount()); + $this->assertEquals($this->properties->seatCount, $this->testable->seatCount); + } + + /** @test */ + public function seat_count_is_settable() + { + $this->testable->setSeatCount(5); + $this->assertEquals(5, $this->testable->getSeatCount()); + + $this->testable->seatCount = 10; + $this->assertEquals(10, $this->testable->getSeatCount()); + } + +} diff --git a/tests/Unit/Applications/ApplicationSettingsNotificationsTest.php b/tests/Unit/Applications/ApplicationSettingsNotificationsTest.php new file mode 100644 index 0000000000..8840fe47bd --- /dev/null +++ b/tests/Unit/Applications/ApplicationSettingsNotificationsTest.php @@ -0,0 +1,52 @@ +assertInstanceOf(\Okta\Applications\ApplicationSettingsNotificationsVpn::class, $this->testable->getVpn()); + $this->assertInstanceOf(\Okta\Applications\ApplicationSettingsNotificationsVpn::class, $this->testable->vpn); + } + + /** @test */ + public function vpn_is_settable() + { + $vpn = $this->testable->getVpn(); + $vpn->message = "test"; + $this->testable->setVpn($vpn); + $this->assertEquals("test", $this->testable->getVpn()->message); + + $vpn->message = "this"; + $this->testable->vpn = $vpn; + $this->assertEquals("this", $this->testable->getVpn()->message); + } + + +} diff --git a/tests/Unit/Applications/ApplicationSettingsNotificationsVpnNetworkTest.php b/tests/Unit/Applications/ApplicationSettingsNotificationsVpnNetworkTest.php new file mode 100644 index 0000000000..3702da9e3e --- /dev/null +++ b/tests/Unit/Applications/ApplicationSettingsNotificationsVpnNetworkTest.php @@ -0,0 +1,86 @@ +assertEquals($this->properties->exclude, $this->testable->getExclude()); + $this->assertEquals($this->properties->exclude, $this->testable->exclude); + } + + /** @test */ + public function exclude_is_settable() + { + $this->testable->setExclude(["test"=>"this"]); + $this->assertEquals(["test"=>"this"], $this->testable->getExclude()); + + $this->testable->exclude = ["test"=>"that"]; + $this->assertEquals(["test"=>"that"], $this->testable->getExclude()); + } + + /** @test */ + public function include_is_accessible() + { + $this->assertEquals($this->properties->include, $this->testable->getInclude()); + $this->assertEquals($this->properties->include, $this->testable->include); + } + + /** @test */ + public function include_is_settable() + { + $this->testable->setInclude(['test'=>'this']); + $this->assertEquals(['test'=>'this'], $this->testable->getInclude()); + + $this->testable->include = ['test'=>'that']; + $this->assertEquals(['test'=>'that'], $this->testable->getInclude()); + } + + /** @test */ + public function connection_is_accessible() + { + $this->assertEquals($this->properties->connection, $this->testable->getConnection()); + $this->assertEquals($this->properties->connection, $this->testable->connection); + } + + /** @test */ + public function connection_is_settable() + { + $this->testable->setConnection('ANYWHERE'); + $this->assertEquals('ANYWHERE', $this->testable->getConnection()); + + $this->testable->connection = 'ON_NETWORK'; + $this->assertEquals('ON_NETWORK', $this->testable->getConnection()); + } + +} diff --git a/tests/Unit/Applications/ApplicationSettingsNotificationsVpnTest.php b/tests/Unit/Applications/ApplicationSettingsNotificationsVpnTest.php new file mode 100644 index 0000000000..97055bf502 --- /dev/null +++ b/tests/Unit/Applications/ApplicationSettingsNotificationsVpnTest.php @@ -0,0 +1,90 @@ +assertEquals($this->properties->helpUrl, $this->testable->getHelpUrl()); + $this->assertEquals($this->properties->helpUrl, $this->testable->helpUrl); + } + + /** @test */ + public function help_url_is_settable() + { + $this->testable->setHelpUrl('http://example.com'); + $this->assertEquals('http://example.com', $this->testable->getHelpUrl()); + + $this->testable->helpUrl = 'http://example.org'; + $this->assertEquals('http://example.org', $this->testable->getHelpUrl()); + } + + /** @test */ + public function message_is_accessible() + { + $this->assertEquals($this->properties->message, $this->testable->getMessage()); + $this->assertEquals($this->properties->message, $this->testable->message); + } + + /** @test */ + public function message_is_settable() + { + $this->testable->setMessage('message1'); + $this->assertEquals('message1', $this->testable->getMessage()); + + $this->testable->message = 'message2'; + $this->assertEquals('message2', $this->testable->getMessage()); + } + + /** @test */ + public function network_is_accessible() + { + $this->assertInstanceOf(ApplicationSettingsNotificationsVpnNetwork::class, $this->testable->getNetwork()); + $this->assertInstanceOf(ApplicationSettingsNotificationsVpnNetwork::class, $this->testable->network); + } + + /** @test */ + public function network_is_settable() + { + $network = $this->testable->getNetwork(); + $network->setConnection('ENABLED'); + $this->testable->setNetwork($network); + $this->assertEquals('ENABLED', $this->testable->getNetwork()->getConnection()); + + $network->setConnection('PENDING'); + $this->testable->network = $network; + $this->assertEquals('PENDING', $this->testable->getNetwork()->getConnection()); + } + + +} diff --git a/tests/Unit/Applications/ApplicationSettingsTest.php b/tests/Unit/Applications/ApplicationSettingsTest.php new file mode 100644 index 0000000000..47d9159f7e --- /dev/null +++ b/tests/Unit/Applications/ApplicationSettingsTest.php @@ -0,0 +1,78 @@ +assertInstanceOf(\Okta\Applications\ApplicationSettingsApplication::class, $this->testable->getApp()); + $this->assertInstanceOf(\Okta\Applications\ApplicationSettingsApplication::class, $this->testable->app); + } + + /** @test */ + public function app_is_settable() + { + $app = $this->testable->getApp(); + $app->test = 'this'; + $this->testable->setApp($app); + $this->assertEquals('this', $this->testable->getApp()->test); + + $app = $this->testable->getApp(); + $app->test = 'that'; + $this->testable->app = $app; + $this->assertEquals('that', $this->testable->getApp()->test); + } + + /** @test */ + public function notifications_is_accessible() + { + $this->assertInstanceOf(\Okta\Applications\ApplicationSettingsNotifications::class, + $this->testable->getNotifications()); + $this->assertInstanceOf(\Okta\Applications\ApplicationSettingsNotifications::class, $this->testable->notifications); + } + + /** @test */ + public function notifications_is_settable() + { + $notifications = $this->testable->getNotifications(); + $notifications->test = 'this'; + $this->testable->setNotifications($notifications); + $this->assertEquals('this', $this->testable->getNotifications()->test); + + $notifications = $this->testable->getNotifications(); + $notifications->test = 'that'; + $this->testable->notifications = $notifications; + $this->assertEquals('that', $this->testable->getNotifications()->test); + } + + +} diff --git a/tests/Unit/Applications/ApplicationTest.php b/tests/Unit/Applications/ApplicationTest.php new file mode 100644 index 0000000000..642650aa2e --- /dev/null +++ b/tests/Unit/Applications/ApplicationTest.php @@ -0,0 +1,598 @@ +createNewHttpClient([ + "getBody" => '{"id":"abc123", "signOnMode": "BOOKMARK"}' + ]); + + $this->testable->get('abc123'); + + $requests = $httpClient->getRequests(); + + $this->assertEquals('/api/v1/apps/abc123', $requests[0]->getUri()->getPath()); + $this->assertEquals('GET', $requests[0]->getMethod()); + } + + /** @test */ + public function getting_an_application_will_return_application_object() + { + $client = $this->createNewHttpClient([ + "getBody" => '{"id":"abc123", "signOnMode": "BOOKMARK"}' + ]); + + $app = $this->testable->get('abc123'); + + $this->assertInstanceOf(\Okta\Applications\BookmarkApplication::class, $app); + } + + /** @test */ + public function saving_an_application_makes_requests_to_correct_endpoint() + { + $client = $this->createNewHttpClient(); + $this->testable->save(); + + $requests = $client->getRequests(); + + $this->assertEquals("/api/v1/apps/{$this->testable->getId()}", $requests[0]->getUri()->getPath()); + $this->assertEquals('POST', $requests[0]->getMethod()); + } + + /** @test */ + public function saving_an_application_will_return_correct_type() + { + $client = $this->createNewHttpClient(); + + $app = $this->testable->save(); + + $this->assertInstanceOf(Application::class, $app); + } + + /** @test */ + public function deleting_an_application_makes_requests_to_correct_endpoint() + { + $client = $this->createNewHttpClient(); + $this->testable->delete(); + + $requests = $client->getRequests(); + + $this->assertEquals("/api/v1/apps/{$this->testable->getId()}", $requests[0]->getUri()->getPath()); + $this->assertEquals('DELETE', $requests[0]->getMethod()); + } + + /** @test */ + public function id_is_accessible() + { + $this->assertEquals($this->properties->id, $this->testable->getId()); + $this->assertEquals($this->properties->id, $this->testable->id); + } + + /** @test */ + public function name_is_accessible() + { + $this->assertEquals($this->properties->name, $this->testable->getName()); + $this->assertEquals($this->properties->name, $this->testable->name); + } + + /** @test */ + public function label_is_accessible() + { + $this->assertEquals($this->properties->label, $this->testable->getLabel()); + $this->assertEquals($this->properties->label, $this->testable->label); + } + + /** @test */ + public function label_is_settable() + { + $this->testable->setLabel('CustomApp'); + $this->assertEquals('CustomApp', $this->testable->getLabel()); + + $this->testable->label = 'Custom App 2'; + $this->assertEquals('Custom App 2', $this->testable->getLabel()); + } + + /** @test */ + public function links_is_accessible() + { + $this->assertEquals($this->properties->_links, $this->testable->getLinks()); + $this->assertEquals($this->properties->_links, $this->testable->links); + } + + /** @test */ + public function status_is_accessible() + { + $this->assertEquals($this->properties->status, $this->testable->getStatus()); + $this->assertEquals($this->properties->status, $this->testable->status); + } + + /** @test */ + public function created_is_accessible() + { + $ts = Carbon::parse($this->properties->created)->timestamp; + $this->assertInstanceOf(\Carbon\Carbon::class, $this->testable->created); + $this->assertEquals($ts, $this->testable->getCreated()->timestamp); + $this->assertEquals($ts, $this->testable->created->timestamp); + } + + /** @test */ + public function features_is_accessible() + { + $this->assertEquals($this->properties->features, $this->testable->getFeatures()); + $this->assertEquals($this->properties->features, $this->testable->features); + } + + /** @test */ + public function features_is_settable() + { + $this->testable->setFeatures(['IMPORT_NEW_USERS']); + $this->assertEquals(['IMPORT_NEW_USERS'], $this->testable->getFeatures()); + + $this->testable->features = ['PROFILE_MASTERING']; + $this->assertEquals(['PROFILE_MASTERING'], $this->testable->getFeatures()); + } + + /** @test */ + public function settings_is_accessible() + { + $this->assertInstanceOf(\Okta\Applications\ApplicationSettings::class, $this->testable->getSettings()); + $this->assertInstanceOf(\Okta\Applications\ApplicationSettings::class, $this->testable->settings); + } + + /** @test */ + public function settings_is_settable() + { + $settings1 = $this->testable->getSettings(); + $settings2 = $this->testable->getSettings(); + + $settings1->signOn = 'test'; + $settings2->signOn = 'hello'; + + $this->testable->setSettings($settings1); + $this->assertInstanceOf(\Okta\Applications\ApplicationSettings::class, $this->testable->getSettings()); + $this->assertEquals('test', $this->testable->getSettings()->signOn); + + $this->testable->settings = $settings2; + $this->assertInstanceOf(\Okta\Applications\ApplicationSettings::class, $this->testable->getSettings()); + $this->assertEquals('hello', $this->testable->getSettings()->signOn); + + } + + /** @test */ + public function embedded_is_accessible() + { + $this->assertEquals($this->properties->_embedded, $this->testable->getEmbedded()); + $this->assertEquals($this->properties->_embedded, $this->testable->embedded); + } + + /** @test */ + public function licensing_is_accessible() + { + $this->assertInstanceOf(\Okta\Applications\ApplicationLicensing::class, $this->testable->getLicensing()); + $this->assertInstanceOf(\Okta\Applications\ApplicationLicensing::class, $this->testable->licensing); + } + + /** @test */ + public function licensing_is_settable() + { + $licensing1 = $this->testable->getLicensing(); + $licensing2 = $this->testable->getLicensing(); + + $licensing1->seatCount = 10; + $licensing2->seatCount = 20; + + $this->testable->setLicensing($licensing1); + $this->assertInstanceOf(\Okta\Applications\ApplicationLicensing::class, $this->testable->getLicensing()); + $this->assertEquals(10, $this->testable->getLicensing()->seatCount); + + $this->testable->licensing = $licensing2; + $this->assertInstanceOf(\Okta\Applications\ApplicationLicensing::class, $this->testable->getLicensing()); + $this->assertEquals(20, $this->testable->getLicensing()->seatCount); + + } + + /** @test */ + public function sign_on_mode_is_accessible() + { + $this->assertEquals($this->properties->signOnMode, $this->testable->getSignOnMode()); + $this->assertEquals($this->properties->signOnMode, $this->testable->signOnMode); + } + + /** @test */ + public function sign_on_mode_is_settable() + { + $this->testable->setSignOnMode('BOOKMARK'); + $this->assertEquals('BOOKMARK', $this->testable->getSignOnMode()); + + $this->testable->signOnMode = 'BASIC_AUTH'; + $this->assertEquals('BASIC_AUTH', $this->testable->getSignOnMode()); + } + + /** @test */ + public function visibility_is_accessible() + { + $this->assertInstanceOf(\Okta\Applications\ApplicationVisibility::class, $this->testable->getVisibility()); + $this->assertInstanceOf(\Okta\Applications\ApplicationVisibility::class, $this->testable->visibility); + } + + /** @test */ + public function visibility_is_settable() + { + $visibility1 = $this->testable->getVisibility(); + $visibility2 = $this->testable->getVisibility(); + + $visibility1->autoSubmitToolbar = true; + $visibility2->autoSubmitToolbar = false; + + $this->testable->setVisibility($visibility1); + $this->assertInstanceOf(\Okta\Applications\ApplicationVisibility::class, $this->testable->getVisibility()); + $this->assertTrue($this->testable->getVisibility()->autoSubmitToolbar); + + $this->testable->visibility = $visibility2; + $this->assertInstanceOf(\Okta\Applications\ApplicationVisibility::class, $this->testable->getVisibility()); + $this->assertFalse($this->testable->getVisibility()->autoSubmitToolbar); + + } + + /** @test */ + public function credentials_is_accessible() + { + $this->assertInstanceOf(\Okta\Applications\ApplicationCredentials::class, $this->testable->getCredentials()); + $this->assertInstanceOf(\Okta\Applications\ApplicationCredentials::class, $this->testable->credentials); + } + + /** @test */ + public function credentials_is_settable() + { + $credentials1 = $this->testable->getCredentials(); + $credentials2 = $this->testable->getCredentials(); + + $credentials1->test1 = 'test1'; + $credentials2->test2 = 'test2'; + + $this->testable->setCredentials($credentials1); + $this->assertInstanceOf(\Okta\Applications\ApplicationCredentials::class, $this->testable->getCredentials()); + $this->assertEquals('test1', $this->testable->getCredentials()->test1); + + $this->testable->credentials = $credentials2; + $this->assertInstanceOf(\Okta\Applications\ApplicationCredentials::class, $this->testable->getCredentials()); + $this->assertEquals('test2', $this->testable->getCredentials()->test2); + + } + + /** @test */ + public function last_updated_is_accessible() + { + $ts = Carbon::parse($this->properties->lastUpdated)->timestamp; + $this->assertInstanceOf(\Carbon\Carbon::class, $this->testable->lastUpdated); + $this->assertEquals($ts, $this->testable->getLastUpdated()->timestamp); + $this->assertEquals($ts, $this->testable->lastUpdated->timestamp); + } + + /** @test */ + public function accessibility_is_accessible() + { + $this->assertInstanceOf(\Okta\Applications\ApplicationAccessibility::class, $this->testable->getAccessibility()); + $this->assertInstanceOf(\Okta\Applications\ApplicationAccessibility::class, $this->testable->accessibility); + + } + + /** @test */ + public function accessibility_is_settable() + { + $accessibility1 = $this->testable->getAccessibility(); + $accessibility2 = $this->testable->getAccessibility(); + + $accessibility1->test1 = 'test1'; + $accessibility2->test2 = 'test2'; + + $this->testable->setAccessibility($accessibility1); + $this->assertInstanceOf(\Okta\Applications\ApplicationAccessibility::class, $this->testable->getAccessibility()); + $this->assertEquals('test1', $this->testable->getAccessibility()->test1); + + $this->testable->accessibility = $accessibility2; + $this->assertInstanceOf(\Okta\Applications\ApplicationAccessibility::class, $this->testable->getAccessibility()); + $this->assertEquals('test2', $this->testable->getAccessibility()->test2); + + } + + /** @test */ + public function activate_makes_request_to_correct_endpoint() + { + $client = $this->createNewHttpClient(); + + $app = $this->createModel($this->model, Application::class); + $app->activate(); + $request = $client->getRequests(); + + $this->assertEquals('POST', $request[0]->getMethod()); + $this->assertEquals( + "/api/v1/apps/{$this->testable->getId()}/lifecycle/activate", + $request[0]->getUri()->getPath() + ); + } + + /** @test */ + public function deactivate_makes_request_to_correct_endpoint() + { + $client = $this->createNewHttpClient(); + $app = $this->createModel($this->model, Application::class); + $app->deactivate(); + + $request = $client->getRequests(); + + $this->assertEquals('POST', $request[0]->getMethod()); + $this->assertEquals( + "/api/v1/apps/{$this->testable->getId()}/lifecycle/deactivate", + $request[0]->getUri()->getPath() + ); + } + + /** @test */ + public function get_application_users_makes_request_to_correct_endpoint() + { + + $httpClient = $this->createNewHttpClient([ + 'getBody' => '[{"id": "00uaz81i7cHX3cSsg0h7"}]' + ]); + + $app = $this->createModel($this->model, $this->modelType); + $appUsers = $app->getApplicationUsers(); + + $request = $httpClient->getRequests(); + + $this->assertEquals('GET', $request[0]->getMethod()); + $this->assertEquals( + "/api/v1/apps/{$this->testable->getId()}/users", + $request[0]->getUri()->getPath() + ); + + $this->assertInstanceOf(\Okta\Applications\Collection::class, $appUsers); + $this->assertInstanceOf(\Okta\Applications\AppUser::class, $appUsers->first()); + } + + /** @test */ + public function assign_user_to_application_makes_request_to_correct_endpoint() + { + + $httpClient = $this->createNewHttpClient([ + "getBody" => '{"id":"abc123"}' + ]); + + $app = $this->createModel($this->model, $this->modelType); + + $appUser = json_decode('{ + "id": "abc123", + "scope": "USER", + "credentials": { + "userName": "user@example.com" + } + } '); + + $appUser = $app->assignUserToApplication(new \Okta\Applications\AppUser(null, $appUser)); + + $request = $httpClient->getRequests(); + + $this->assertEquals('POST', $request[0]->getMethod()); + $this->assertEquals( + "/api/v1/apps/{$this->testable->getId()}/users", + $request[0]->getUri()->getPath() + ); + + $this->assertInstanceOf(\Okta\Applications\AppUser::class, $appUser); + } + + /** @test */ + public function get_application_user_makes_request_to_correct_endpoint() + { + + $httpClient = $this->createNewHttpClient([ + "getBody" => '{"id":"abc123"}' + ]); + + $app = $this->createModel($this->model, $this->modelType); + + $appUser = $app->getApplicationUser('abc123'); + + $request = $httpClient->getRequests(); + + $this->assertEquals('GET', $request[0]->getMethod()); + $this->assertEquals( + "/api/v1/apps/{$this->testable->getId()}/users/abc123", + $request[0]->getUri()->getPath() + ); + + $this->assertInstanceOf(\Okta\Applications\AppUser::class, $appUser); + } + + /** @test */ + public function get_application_group_assignment_makes_request_to_correct_endpoint() + { + $httpClient = $this->createNewHttpClient([ + "getBody" => '{"id":"abc123"}' + ]); + + $app = $this->createModel($this->model, $this->modelType); + + $groupAssignment = $app->getApplicationGroupAssignment('abc123'); + + $request = $httpClient->getRequests(); + + $this->assertEquals('GET', $request[0]->getMethod()); + $this->assertEquals( + "/api/v1/apps/{$this->testable->getId()}/groups/abc123", + $request[0]->getUri()->getPath() + ); + + $this->assertInstanceOf(\Okta\Applications\ApplicationGroupAssignment::class, $groupAssignment); + } + + /** @test */ + public function generate_application_key_makes_request_to_correct_endpoint() + { + + $httpClient = $this->createNewHttpClient([ + "getBody" => '{"created":"2015-12-10T18:56:23.000Z","expiresAt":"2017-12-10T18:56:22.000Z","x5c":["MIIDqDCCApCg"],"e":"AQAB","n":"mkC6yAJVvFwUlm","kid":"SIMcCQNY3uw","kty":"RSA","use":"sig","x5t#S256":"5GOpy9CQVt"}' + ]); + + $app = $this->createModel($this->model, $this->modelType); + + $key = $app->generateApplicationKey(); + + $request = $httpClient->getRequests(); + + $this->assertEquals('POST', $request[0]->getMethod()); + $this->assertEquals( + "/api/v1/apps/{$this->testable->getId()}/credentials/keys/generate", + $request[0]->getUri()->getPath() + ); + + $this->assertInstanceOf(\Okta\Applications\JsonWebKey::class, $key); + + } + + /** @test */ + public function clone_application_key_makes_request_to_correct_endpoint() + { + + $httpClient = $this->createNewHttpClient([ + "getBody" => '{"created":"2015-12-10T18:56:23.000Z","expiresAt":"2017-12-10T18:56:22.000Z","x5c":["MIIDqDCCApCg"],"e":"AQAB","n":"mkC6yAJVvFwUlm","kid":"SIMcCQNY3uw","kty":"RSA","use":"sig","x5t#S256":"5GOpy9CQVt"}' + ]); + + $app = $this->createModel($this->model, $this->modelType); + + $key = $app->cloneApplicationKey('abc123'); + + $request = $httpClient->getRequests(); + + $this->assertEquals('POST', $request[0]->getMethod()); + $this->assertEquals( + "/api/v1/apps/{$this->testable->getId()}/credentials/keys/abc123/clone", + $request[0]->getUri()->getPath() + ); + + $this->assertInstanceOf(\Okta\Applications\JsonWebKey::class, $key); + } + + /** @test */ + public function get_application_key_makes_request_to_correct_endpoint() + { + $httpClient = $this->createNewHttpClient([ + "getBody" => '{"created":"2015-12-10T18:56:23.000Z","expiresAt":"2017-12-10T18:56:22.000Z","x5c":["MIIDqDCCApCg"],"e":"AQAB","n":"mkC6yAJVvFwUlm","kid":"SIMcCQNY3uw","kty":"RSA","use":"sig","x5t#S256":"5GOpy9CQVt"}' + ]); + + $app = $this->createModel($this->model, $this->modelType); + + $key = $app->getApplicationKey('abc123'); + + $request = $httpClient->getRequests(); + + $this->assertEquals('GET', $request[0]->getMethod()); + $this->assertEquals( + "/api/v1/apps/{$this->testable->getId()}/credentials/keys/abc123", + $request[0]->getUri()->getPath() + ); + + $this->assertInstanceOf(\Okta\Applications\JsonWebKey::class, $key); + } + + /** @test */ + public function create_application_group_assignment_makes_request_to_correct_endpoint() + { + $httpClient = $this->createNewHttpClient([ + "getBody" => '{"id": "abc123"}' + ]); + + $app = $this->createModel($this->model, $this->modelType); + $appGroupAssignment = new \Okta\Applications\ApplicationGroupAssignment(); + + $applicationGroupAssignment = $app->createApplicationGroupAssignment('xyz789', $appGroupAssignment); + + $request = $httpClient->getRequests(); + + $this->assertEquals('PUT', $request[0]->getMethod()); + $this->assertEquals( + "/api/v1/apps/{$this->testable->getId()}/groups/xyz789", + $request[0]->getUri()->getPath() + ); + + $this->assertInstanceOf(\Okta\Applications\ApplicationGroupAssignment::class, $applicationGroupAssignment); + + } + + /** @test */ + public function get_group_assignments_makes_request_to_correct_endpoint() + { + $httpClient = $this->createNewHttpClient([ + "getBody" => '[{"id": "abc123"}]' + ]); + + $app = $this->createModel($this->model, $this->modelType); + + $groupAssignments = $app->getGroupAssignments(); + + $request = $httpClient->getRequests(); + + $this->assertEquals('GET', $request[0]->getMethod()); + $this->assertEquals( + "/api/v1/apps/{$this->testable->getId()}/groups", + $request[0]->getUri()->getPath() + ); + + $this->assertInstanceOf(\Okta\Applications\Collection::class, $groupAssignments); + $this->assertInstanceOf(\Okta\Applications\ApplicationGroupAssignment::class, $groupAssignments->first()); + } + + /** @test */ + public function get_keys_makes_request_to_correct_endpoint() + { + $httpClient = $this->createNewHttpClient([ + "getBody" => '[{"id": "abc123"}]' + ]); + + $app = $this->createModel($this->model, $this->modelType); + + $keys = $app->getKeys(); + + $request = $httpClient->getRequests(); + + $this->assertEquals('GET', $request[0]->getMethod()); + $this->assertEquals( + "/api/v1/apps/{$this->testable->getId()}/credentials/keys", + $request[0]->getUri()->getPath() + ); + + $this->assertInstanceOf(\Okta\Applications\Collection::class, $keys); + $this->assertInstanceOf(\Okta\Applications\JsonWebKey::class, $keys->first()); + } + + +} diff --git a/tests/Unit/Applications/ApplicationVisibilityHideTest.php b/tests/Unit/Applications/ApplicationVisibilityHideTest.php new file mode 100644 index 0000000000..fc414d8265 --- /dev/null +++ b/tests/Unit/Applications/ApplicationVisibilityHideTest.php @@ -0,0 +1,63 @@ +assertEquals($this->properties->iOS, $this->testable->getIOs()); + } + + /** @test */ + public function ios_is_settable() + { + $this->testable->setIOs(true); + $this->assertEquals(true, $this->testable->getIOs()); + } + + /** @test */ + public function web_is_accessible() + { + $this->assertEquals($this->properties->web, $this->testable->getWeb()); + $this->assertEquals($this->properties->web, $this->testable->web); + } + + /** @test */ + public function web_is_settable() + { + $this->testable->setWeb(true); + $this->assertEquals(true, $this->testable->getWeb()); + + $this->testable->web = false; + $this->assertEquals(false, $this->testable->getWeb()); + } + +} diff --git a/tests/Unit/Applications/ApplicationVisibilityTest.php b/tests/Unit/Applications/ApplicationVisibilityTest.php new file mode 100644 index 0000000000..90a27d198b --- /dev/null +++ b/tests/Unit/Applications/ApplicationVisibilityTest.php @@ -0,0 +1,89 @@ +assertInstanceOf(\Okta\Applications\ApplicationVisibilityHide::class, $this->testable->getHide()); + $this->assertInstanceOf(\Okta\Applications\ApplicationVisibilityHide::class, $this->testable->hide); + } + + /** @test */ + public function hide_is_settable() + { + $hide = $this->testable->getHide(); + $hide->web = true; + $this->testable->setHide($hide); + $this->assertTrue($this->testable->getHide()->web); + + $hide->web = false; + $this->testable->hide = $hide; + $this->assertFalse($this->testable->getHide()->web); + } + + /** @test */ + public function app_links_is_accessible() + { + $this->assertEquals($this->properties->appLinks, $this->testable->getAppLinks()); + $this->assertEquals($this->properties->appLinks, $this->testable->appLinks); + } + + /** @test */ + public function app_links_is_settable() + { + $links = $this->testable->getAppLinks(); + $links->login = false; + $this->testable->setAppLinks($links); + $this->assertFalse($this->testable->getAppLinks()->login); + + $links->login = true; + $this->testable->appLinks = $links; + $this->assertTrue($this->testable->getAppLinks()->login); + } + + /** @test */ + public function auto_submit_toolbar_is_accessible() + { + $this->assertEquals($this->properties->autoSubmitToolbar, $this->testable->getAutoSubmitToolbar()); + $this->assertEquals($this->properties->autoSubmitToolbar, $this->testable->autoSubmitToolbar); + } + + /** @test */ + public function auto_submit_toolbar_is_settable() + { + $this->testable->setAutoSubmitToolbar(true); + $this->assertEquals(true, $this->testable->getAutoSubmitToolbar()); + + $this->testable->autoSubmitToolbar = false; + $this->assertEquals(false, $this->testable->getAutoSubmitToolbar()); + } + + +} diff --git a/tests/Unit/Applications/AutoLoginApplicationSettingsSignOnTest.php b/tests/Unit/Applications/AutoLoginApplicationSettingsSignOnTest.php new file mode 100644 index 0000000000..4fc2cae6c1 --- /dev/null +++ b/tests/Unit/Applications/AutoLoginApplicationSettingsSignOnTest.php @@ -0,0 +1,69 @@ +assertEquals($this->properties->loginUrl, $this->testable->getLoginUrl()); + $this->assertEquals($this->properties->loginUrl, $this->testable->loginUrl); + } + + /** @test */ + public function login_url_is_settable() + { + $this->testable->setLoginUrl('http://example.com'); + $this->assertEquals('http://example.com', $this->testable->getLoginUrl()); + + $this->testable->loginUrl = 'http://example.org'; + $this->assertEquals('http://example.org', $this->testable->getLoginUrl()); + } + + /** @test */ + public function redirect_url_is_accessible() + { + $this->assertEquals($this->properties->redirectUrl, $this->testable->getRedirectUrl()); + $this->assertEquals($this->properties->redirectUrl, $this->testable->redirectUrl); + } + + /** @test */ + public function redirect_url_is_settable() + { + $this->testable->setRedirectUrl('http://example.com'); + $this->assertEquals('http://example.com', $this->testable->getRedirectUrl()); + + $this->testable->redirectUrl = 'http://example.org'; + $this->assertEquals('http://example.org', $this->testable->getRedirectUrl()); + } + + +} diff --git a/tests/Unit/Applications/AutoLoginApplicationSettingsTest.php b/tests/Unit/Applications/AutoLoginApplicationSettingsTest.php new file mode 100644 index 0000000000..85514fb4c0 --- /dev/null +++ b/tests/Unit/Applications/AutoLoginApplicationSettingsTest.php @@ -0,0 +1,58 @@ +assertInstanceOf(\Okta\Applications\AutoLoginApplicationSettingsSignOn::class, $this->testable->getSignOn()); + $this->assertInstanceOf(\Okta\Applications\AutoLoginApplicationSettingsSignOn::class, $this->testable->signOn); + } + + /** @test */ + public function sign_on_is_settable() + { + $signOn = $this->testable->getSignOn(); + $signOn->redirectUrl = 'http://example.com'; + $this->testable->setSignOn($signOn); + $this->assertEquals('http://example.com', $this->testable->getSignOn()->redirectUrl); + + + $signOn->redirectUrl = 'http://example.org'; + $this->testable->signOn = $signOn; + $this->assertEquals('http://example.org', $this->testable->getSignOn()->redirectUrl); + } + + +} diff --git a/tests/Unit/Applications/AutoLoginApplicationTest.php b/tests/Unit/Applications/AutoLoginApplicationTest.php new file mode 100644 index 0000000000..407349e5f6 --- /dev/null +++ b/tests/Unit/Applications/AutoLoginApplicationTest.php @@ -0,0 +1,73 @@ +assertInstanceOf(\Okta\Applications\AutoLoginApplicationSettings::class, $this->testable->getSettings()); + $this->assertInstanceOf(\Okta\Applications\AutoLoginApplicationSettings::class, $this->testable->settings); + } + + /** @test */ + public function settings_is_settable() + { + $settings = $this->testable->getSettings(); + + $settings->abc = '123'; + $this->testable->setSettings($settings); + $this->assertEquals('123', $this->testable->getSettings()->abc); + + $settings->abc = '456'; + $this->testable->settings = $settings; + $this->assertEquals('456', $this->testable->getSettings()->abc); + } + + /** @test */ + public function credentials_is_accessible() + { + $this->assertInstanceOf(\Okta\Applications\SchemeApplicationCredentials::class,$this->testable->getCredentials()); + $this->assertInstanceOf(\Okta\Applications\SchemeApplicationCredentials::class,$this->testable->credentials); + } + + /** @test */ + public function credentials_is_settable() + { + $credentials = $this->testable->getCredentials(); + + $credentials->abc = '123'; + $this->testable->setCredentials($credentials); + $this->assertEquals('123', $this->testable->getCredentials()->abc); + + $credentials->abc = '456'; + $this->testable->credentials = $credentials; + $this->assertEquals('456', $this->testable->getCredentials()->abc); + } + +} diff --git a/tests/Unit/Applications/BasicApplicationSettingsApplicationTest.php b/tests/Unit/Applications/BasicApplicationSettingsApplicationTest.php new file mode 100644 index 0000000000..831d5239c2 --- /dev/null +++ b/tests/Unit/Applications/BasicApplicationSettingsApplicationTest.php @@ -0,0 +1,68 @@ +assertEquals($this->properties->url, $this->testable->getUrl()); + $this->assertEquals($this->properties->url, $this->testable->url); + } + + /** @test */ + public function url_is_settable() + { + $this->testable->setUrl("http://example.com"); + $this->assertEquals("http://example.com", $this->testable->getUrl()); + + $this->testable->url = "http://example.org"; + $this->assertEquals("http://example.org", $this->testable->getUrl()); + } + + /** @test */ + public function auth_url_is_accessible() + { + $this->assertEquals($this->properties->authURL, $this->testable->getAuthUrl()); + $this->assertEquals($this->properties->authURL, $this->testable->authUrl); + } + + /** @test */ + public function auth_url_is_settable() + { + $this->testable->setAuthUrl("http://example.com"); + $this->assertEquals("http://example.com", $this->testable->getAuthUrl()); + + $this->testable->authUrl = "http://example.org"; + $this->assertEquals("http://example.org", $this->testable->getAuthUrl()); + } + +} diff --git a/tests/Unit/Applications/BasicApplicationSettingsTest.php b/tests/Unit/Applications/BasicApplicationSettingsTest.php new file mode 100644 index 0000000000..4c629a11d2 --- /dev/null +++ b/tests/Unit/Applications/BasicApplicationSettingsTest.php @@ -0,0 +1,54 @@ +assertInstanceOf(\Okta\Applications\BasicApplicationSettingsApplication::class, $this->testable->getApp()); + $this->assertInstanceOf(\Okta\Applications\BasicApplicationSettingsApplication::class, $this->testable->app); + } + + /** @test */ + public function app_is_settable() + { + $app = $this->testable->getApp(); + $app->url = "http://example.com"; + $this->testable->setApp($app); + $this->assertEquals("http://example.com", $this->testable->getApp()->url); + + $app->url = "http://example.org"; + $this->testable->app = $app; + $this->assertEquals("http://example.org", $this->testable->getApp()->url); + } + +} diff --git a/tests/Unit/Applications/BasicAuthApplicationTest.php b/tests/Unit/Applications/BasicAuthApplicationTest.php new file mode 100644 index 0000000000..403701de4a --- /dev/null +++ b/tests/Unit/Applications/BasicAuthApplicationTest.php @@ -0,0 +1,72 @@ +assertInstanceOf(\Okta\Applications\BasicApplicationSettings::class, $this->testable->getSettings()); + $this->assertInstanceOf(\Okta\Applications\BasicApplicationSettings::class, $this->testable->settings); + } + + /** @test */ + public function settings_is_settable() + { + $settings = $this->testable->getSettings(); + + $settings->abc = '123'; + $this->testable->setSettings($settings); + $this->assertEquals('123', $this->testable->getSettings()->abc); + + $settings->abc = '456'; + $this->testable->settings = $settings; + $this->assertEquals('456', $this->testable->getSettings()->abc); + } + + /** @test */ + public function credentials_is_accessible() + { + $this->assertInstanceOf(\Okta\Applications\SchemeApplicationCredentials::class,$this->testable->getCredentials()); + $this->assertInstanceOf(\Okta\Applications\SchemeApplicationCredentials::class,$this->testable->credentials); + } + + /** @test */ + public function credentials_is_settable() + { + $credentials = $this->testable->getCredentials(); + + $credentials->abc = '123'; + $this->testable->setCredentials($credentials); + $this->assertEquals('123', $this->testable->getCredentials()->abc); + + $credentials->abc = '456'; + $this->testable->credentials = $credentials; + $this->assertEquals('456', $this->testable->getCredentials()->abc); + } +} diff --git a/tests/Unit/Applications/BookmarkApplicationSettingsApplicationTest.php b/tests/Unit/Applications/BookmarkApplicationSettingsApplicationTest.php new file mode 100644 index 0000000000..68636e5274 --- /dev/null +++ b/tests/Unit/Applications/BookmarkApplicationSettingsApplicationTest.php @@ -0,0 +1,69 @@ +assertEquals($this->properties->url, $this->testable->getUrl()); + $this->assertEquals($this->properties->url, $this->testable->url); + } + + /** @test */ + public function url_is_settable() + { + $this->testable->setUrl("http://example.com"); + $this->assertEquals("http://example.com", $this->testable->getUrl()); + + $this->testable->url = "http://example.org"; + $this->assertEquals("http://example.org", $this->testable->getUrl()); + } + + /** @test */ + public function request_integration_is_accessible() + { + $this->assertEquals($this->properties->requestIntegration, $this->testable->getRequestIntegration()); + $this->assertEquals($this->properties->requestIntegration, $this->testable->requestIntegration); + } + + /** @test */ + public function request_integration_is_settable() + { + $this->testable->setRequestIntegration(false); + $this->assertEquals(false, $this->testable->getRequestIntegration()); + + $this->testable->requestIntegration = true; + $this->assertEquals(true, $this->testable->getRequestIntegration()); + } + + +} diff --git a/tests/Unit/Applications/BookmarkApplicationSettingsTest.php b/tests/Unit/Applications/BookmarkApplicationSettingsTest.php new file mode 100644 index 0000000000..cc6744d96e --- /dev/null +++ b/tests/Unit/Applications/BookmarkApplicationSettingsTest.php @@ -0,0 +1,60 @@ +assertInstanceOf(\Okta\Applications\BookmarkApplicationSettingsApplication::class, + $this->testable->getApp()); + $this->assertInstanceOf(\Okta\Applications\BookmarkApplicationSettingsApplication::class, + $this->testable->app); + } + + /** @test */ + public function app_is_settable() + { + $app = $this->testable->getApp(); + $app->url = 'http://example.com'; + $this->testable->setApp($app); + $this->assertEquals('http://example.com', $this->testable->getApp()->url); + + + $app->url = 'http://example.org'; + $this->testable->signOn = $app; + $this->assertEquals('http://example.org', $this->testable->getApp()->url); + } + + +} diff --git a/tests/Unit/Applications/BookmarkApplicationTest.php b/tests/Unit/Applications/BookmarkApplicationTest.php new file mode 100644 index 0000000000..f49c5d81dc --- /dev/null +++ b/tests/Unit/Applications/BookmarkApplicationTest.php @@ -0,0 +1,52 @@ +assertInstanceOf(\Okta\Applications\BookmarkApplicationSettings::class, $this->testable->getSettings()); + $this->assertInstanceOf(\Okta\Applications\BookmarkApplicationSettings::class, $this->testable->settings); + } + + /** @test */ + public function settings_is_settable() + { + $settings = $this->testable->getSettings(); + + $settings->abc = '123'; + $this->testable->setSettings($settings); + $this->assertEquals('123', $this->testable->getSettings()->abc); + + $settings->abc = '456'; + $this->testable->settings = $settings; + $this->assertEquals('456', $this->testable->getSettings()->abc); + } + +} diff --git a/tests/Unit/Applications/BrowserPluginApplicationTest.php b/tests/Unit/Applications/BrowserPluginApplicationTest.php new file mode 100644 index 0000000000..cfc29f7b25 --- /dev/null +++ b/tests/Unit/Applications/BrowserPluginApplicationTest.php @@ -0,0 +1,51 @@ +assertInstanceOf(\Okta\Applications\SchemeApplicationCredentials::class,$this->testable->getCredentials()); + $this->assertInstanceOf(\Okta\Applications\SchemeApplicationCredentials::class,$this->testable->credentials); + } + + /** @test */ + public function credentials_is_settable() + { + $credentials = $this->testable->getCredentials(); + + $credentials->abc = '123'; + $this->testable->setCredentials($credentials); + $this->assertEquals('123', $this->testable->getCredentials()->abc); + + $credentials->abc = '456'; + $this->testable->credentials = $credentials; + $this->assertEquals('456', $this->testable->getCredentials()->abc); + } +} diff --git a/tests/Unit/Applications/JsonWebKeyTest.php b/tests/Unit/Applications/JsonWebKeyTest.php new file mode 100644 index 0000000000..f864cdacbc --- /dev/null +++ b/tests/Unit/Applications/JsonWebKeyTest.php @@ -0,0 +1,137 @@ +assertEquals($this->properties->e, $this->testable->getE()); + $this->assertEquals($this->properties->e, $this->testable->e); + } + + /** @test */ + public function n_is_accessible() + { + $this->assertEquals($this->properties->n, $this->testable->getN()); + $this->assertEquals($this->properties->n, $this->testable->n); + } + + /** @test */ + public function alg_is_accessible() + { + $this->assertEquals($this->properties->alg, $this->testable->getAlg()); + $this->assertEquals($this->properties->alg, $this->testable->alg); + } + + /** @test */ + public function kid_is_accessible() + { + $this->assertEquals($this->properties->kid, $this->testable->getKid()); + $this->assertEquals($this->properties->kid, $this->testable->kid); + } + + /** @test */ + public function kty_is_accessible() + { + $this->assertEquals($this->properties->kty, $this->testable->getKty()); + $this->assertEquals($this->properties->kty, $this->testable->kty); + } + + /** @test */ + public function x5c_is_accessible() + { + $this->assertEquals($this->properties->x5c, $this->testable->getX5C()); + $this->assertEquals($this->properties->x5c, $this->testable->x5C); + } + + /** @test */ + public function x5t_is_accessible() + { + $this->assertEquals($this->properties->x5t, $this->testable->getX5T()); + $this->assertEquals($this->properties->x5t, $this->testable->x5T); + } + + /** @test */ + public function x5u_is_accessible() + { + $this->assertEquals($this->properties->x5u, $this->testable->getX5U()); + $this->assertEquals($this->properties->x5u, $this->testable->x5U); + } + + /** @test */ + public function status_is_accessible() + { + $this->assertEquals($this->properties->status, $this->testable->getStatus()); + $this->assertEquals($this->properties->status, $this->testable->status); + } + + /** @test */ + public function created_is_accessible() + { + $ts = Carbon::parse($this->properties->created)->timestamp; + $this->assertInstanceOf(\Carbon\Carbon::class, $this->testable->created); + $this->assertEquals($ts, $this->testable->getCreated()->timestamp); + $this->assertEquals($ts, $this->testable->created->timestamp); + } + + /** @test */ + public function key_ops_is_accessible() + { + $this->assertEquals($this->properties->key_ops, $this->testable->getKeyOps()); + $this->assertEquals($this->properties->key_ops, $this->testable->keyOps); + } + + /** @test */ + public function x_5_t_s_256_is_accessible() + { + $this->assertEquals($this->properties->{'x5t#S256'}, $this->testable->getX5TS256()); + $this->assertEquals($this->properties->{'x5t#S256'}, $this->testable->x5TS256); + } + + /** @test */ + public function expires_at_is_accessible() + { + $ts = Carbon::parse($this->properties->expiresAt)->timestamp; + $this->assertInstanceOf(\Carbon\Carbon::class, $this->testable->expiresAt); + $this->assertEquals($ts, $this->testable->getExpiresAt()->timestamp); + $this->assertEquals($ts, $this->testable->expiresAt->timestamp); + } + + + /** @test */ + public function last_updated_is_accessible() + { + $ts = Carbon::parse($this->properties->lastUpdated)->timestamp; + $this->assertInstanceOf(\Carbon\Carbon::class, $this->testable->lastUpdated); + $this->assertEquals($ts, $this->testable->getLastUpdated()->timestamp); + $this->assertEquals($ts, $this->testable->lastUpdated->timestamp); + } + +} diff --git a/tests/Unit/Applications/OAuthApplicationCredentialsTest.php b/tests/Unit/Applications/OAuthApplicationCredentialsTest.php new file mode 100644 index 0000000000..405f19890a --- /dev/null +++ b/tests/Unit/Applications/OAuthApplicationCredentialsTest.php @@ -0,0 +1,61 @@ +assertInstanceOf(\Okta\Applications\ApplicationCredentialsOAuthClient::class, + $this->testable->getOauthClient()); + $this->assertInstanceOf(\Okta\Applications\ApplicationCredentialsOAuthClient::class, + $this->testable->oauthClient); + } + + /** @test */ + public function oauth_client_is_settable() + { + $client = $this->testable->getOauthClient(); + + $client->autoKeyRotation = true; + $this->testable->setOauthClient($client); + $this->assertEquals(true, $this->testable->getOauthClient()->autoKeyRotation); + + $client->autoKeyRotation = false; + $this->testable->oauthClient = $client; + $this->assertEquals(false, $this->testable->getOauthClient()->autoKeyRotation); + } + + +} diff --git a/tests/Unit/Applications/OpenIdConnectApplicationSettingsClientTest.php b/tests/Unit/Applications/OpenIdConnectApplicationSettingsClientTest.php new file mode 100644 index 0000000000..b8384d2a0f --- /dev/null +++ b/tests/Unit/Applications/OpenIdConnectApplicationSettingsClientTest.php @@ -0,0 +1,205 @@ +assertEquals($this->properties->tos_uri, $this->testable->getTosUri()); + $this->assertEquals($this->properties->tos_uri, $this->testable->tosUri); + } + + /** @test */ + public function tos_uri_is_settable() + { + $this->testable->setTosUri('http://example.com'); + $this->assertEquals('http://example.com', $this->testable->getTosUri()); + + $this->testable->tosUri = 'http://example.net'; + $this->assertEquals('http://example.net', $this->testable->getTosUri()); + } + + /** @test */ + public function logo_uri_is_accessible() + { + $this->assertEquals($this->properties->logo_uri, $this->testable->getLogoUri()); + $this->assertEquals($this->properties->logo_uri, $this->testable->logoUri); + } + + /** @test */ + public function logo_uri_is_settable() + { + $this->testable->setLogoUri('http://example.com'); + $this->assertEquals('http://example.com', $this->testable->getLogoUri()); + + $this->testable->logoUri = 'http://example.net'; + $this->assertEquals('http://example.net', $this->testable->getLogoUri()); + } + + /** @test */ + public function client_uri_is_accessible() + { + $this->assertEquals($this->properties->client_uri, $this->testable->getClientUri()); + $this->assertEquals($this->properties->client_uri, $this->testable->clientUri); + } + + /** @test */ + public function client_uri_is_settable() + { + $this->testable->setClientUri('http://example.com'); + $this->assertEquals('http://example.com', $this->testable->getClientUri()); + + $this->testable->clientUri = 'http://example.org'; + $this->assertEquals('http://example.org', $this->testable->getClientUri()); + } + + /** @test */ + public function policy_uri_is_accessible() + { + $this->assertEquals($this->properties->policy_uri, $this->testable->getPolicyUri()); + $this->assertEquals($this->properties->policy_uri, $this->testable->policyUri); + } + + /** @test */ + public function policy_uri_is_settable() + { + $this->testable->setPolicyUri('http://example.com'); + $this->assertEquals('http://example.com', $this->testable->getPolicyUri()); + + $this->testable->policyUri = 'http://example.net'; + $this->assertEquals('http://example.net', $this->testable->getPolicyUri()); + } + + /** @test */ + public function grant_types_is_accessible() + { + $this->assertEquals($this->properties->grant_types, $this->testable->getGrantTypes()); + $this->assertEquals($this->properties->grant_types, $this->testable->grantTypes); + } + + /** @test */ + public function grant_types_is_settable() + { + $this->testable->setGrantTypes(['code']); + $this->assertEquals(['code'], $this->testable->getGrantTypes()); + + $this->testable->grantTypes = ['client_cred']; + $this->assertEquals(['client_cred'], $this->testable->getGrantTypes()); + } + + /** @test */ + public function redirect_uris_is_accessible() + { + $this->assertEquals($this->properties->redirect_uris, $this->testable->getRedirectUris()); + $this->assertEquals($this->properties->redirect_uris, $this->testable->redirectUris); + } + + /** @test */ + public function redirect_uris_is_settable() + { + $this->testable->setRedirectUris(['http://example.com']); + $this->assertEquals(['http://example.com'], $this->testable->getRedirectUris()); + + $this->testable->redirectUris = ['http://example.net']; + $this->assertEquals(['http://example.net'], $this->testable->getRedirectUris()); + } + + /** @test */ + public function consent_method_is_accessible() + { + $this->assertEquals($this->properties->consent_method, $this->testable->getConsentMethod()); + $this->assertEquals($this->properties->consent_method, $this->testable->consentMethod); + } + + /** @test */ + public function consent_method_is_settable() + { + $this->testable->setConsentMethod('REQUIRED'); + $this->assertEquals('REQUIRED', $this->testable->getConsentMethod()); + + $this->testable->consentMethod = 'OPTIONAL'; + $this->assertEquals('OPTIONAL', $this->testable->getConsentMethod()); + } + + /** @test */ + public function response_types_is_accessible() + { + $this->assertEquals($this->properties->response_types, $this->testable->getResponseTypes()); + $this->assertEquals($this->properties->response_types, $this->testable->responseTypes); + } + + /** @test */ + public function response_types_is_settable() + { + $this->testable->setResponseTypes(['token']); + $this->assertEquals(['token'], $this->testable->getResponseTypes()); + + $this->testable->responseTypes = ['code']; + $this->assertEquals(['code'], $this->testable->getResponseTypes()); + } + + /** @test */ + public function application_type_is_accessible() + { + $this->assertEquals($this->properties->application_type, $this->testable->getApplicationType()); + $this->assertEquals($this->properties->application_type, $this->testable->applicationType); + } + + /** @test */ + public function application_type_is_settable() + { + $this->testable->setApplicationType('native'); + $this->assertEquals('native', $this->testable->getApplicationType()); + + $this->testable->applicationType = 'web'; + $this->assertEquals('web', $this->testable->getApplicationType()); + } + + +} diff --git a/tests/Unit/Applications/OpenIdConnectApplicationSettingsTest.php b/tests/Unit/Applications/OpenIdConnectApplicationSettingsTest.php new file mode 100644 index 0000000000..17c811f5d3 --- /dev/null +++ b/tests/Unit/Applications/OpenIdConnectApplicationSettingsTest.php @@ -0,0 +1,73 @@ +assertInstanceOf(\Okta\Applications\OpenIdConnectApplicationSettingsClient::class, $this->testable->getOauthClient()); + $this->assertInstanceOf(\Okta\Applications\OpenIdConnectApplicationSettingsClient::class, $this->testable->oauthClient); + } + + /** @test */ + public function oauth_client_is_settable() + { + $oauthClient = $this->testable->getOauthClient(); + + $oauthClient->tos_uri = 'http://example.com'; + $this->testable->setOauthClient($oauthClient); + $this->assertEquals('http://example.com', $this->testable->getOauthClient()->tos_uri); + + $oauthClient->tos_uri = 'http://example.org'; + $this->testable->oauthClient = $oauthClient; + $this->assertEquals('http://example.org', $this->testable->getOauthClient()->tos_uri); + } + +} diff --git a/tests/Unit/Applications/OpenIdConnectApplicationTest.php b/tests/Unit/Applications/OpenIdConnectApplicationTest.php new file mode 100644 index 0000000000..49e8054314 --- /dev/null +++ b/tests/Unit/Applications/OpenIdConnectApplicationTest.php @@ -0,0 +1,73 @@ +assertInstanceOf(\Okta\Applications\OpenIdConnectApplicationSettings::class, $this->testable->getSettings()); + $this->assertInstanceOf(\Okta\Applications\OpenIdConnectApplicationSettings::class, $this->testable->settings); + } + + /** @test */ + public function settings_is_settable() + { + $settings = $this->testable->getSettings(); + + $settings->abc = '123'; + $this->testable->setSettings($settings); + $this->assertEquals('123', $this->testable->getSettings()->abc); + + $settings->abc = '456'; + $this->testable->settings = $settings; + $this->assertEquals('456', $this->testable->getSettings()->abc); + } + + /** @test */ + public function credentials_is_accessible() + { + $this->assertInstanceOf(\Okta\Applications\OAuthApplicationCredentials::class,$this->testable->getCredentials()); + $this->assertInstanceOf(\Okta\Applications\OAuthApplicationCredentials::class,$this->testable->credentials); + } + + /** @test */ + public function credentials_is_settable() + { + $credentials = $this->testable->getCredentials(); + + $credentials->abc = '123'; + $this->testable->setCredentials($credentials); + $this->assertEquals('123', $this->testable->getCredentials()->abc); + + $credentials->abc = '456'; + $this->testable->credentials = $credentials; + $this->assertEquals('456', $this->testable->getCredentials()->abc); + } + +} diff --git a/tests/Unit/Applications/SamlApplicationSettingsSignOnTest.php b/tests/Unit/Applications/SamlApplicationSettingsSignOnTest.php new file mode 100644 index 0000000000..3590734d38 --- /dev/null +++ b/tests/Unit/Applications/SamlApplicationSettingsSignOnTest.php @@ -0,0 +1,387 @@ +assertEquals($this->properties->audience, $this->testable->getAudience()); + $this->assertEquals($this->properties->audience, $this->testable->audience); + } + + /** @test */ + public function audience_is_settable() + { + $this->testable->setAudience('aud1'); + $this->assertEquals('aud1', $this->testable->getAudience()); + + $this->testable->audience = 'aud2'; + $this->assertEquals('aud2', $this->testable->getAudience()); + } + + /** @test */ + public function sp_issuer_is_accessible() + { + $this->assertEquals($this->properties->spIssuer, $this->testable->getSpIssuer()); + $this->assertEquals($this->properties->spIssuer, $this->testable->spIssuer); + } + + /** @test */ + public function sp_issuer_is_settable() + { + $this->testable->setSpIssuer('issuer1'); + $this->assertEquals('issuer1', $this->testable->getSpIssuer()); + + $this->testable->spIssuer = 'issuer2'; + $this->assertEquals('issuer2', $this->testable->getSpIssuer()); + } + + /** @test */ + public function idp_issuer_is_accessible() + { + $this->assertEquals($this->properties->idpIssuer, $this->testable->getIdpIssuer()); + $this->assertEquals($this->properties->idpIssuer, $this->testable->idpIssuer); + } + + /** @test */ + public function idp_issuer_is_settable() + { + $this->testable->setIdpIssuer('issuer1'); + $this->assertEquals('issuer1', $this->testable->getIdpIssuer()); + + $this->testable->idpIssuer = 'issuer2'; + $this->assertEquals('issuer2', $this->testable->getIdpIssuer()); + } + + /** @test */ + public function recipient_is_accessible() + { + $this->assertEquals($this->properties->recipient, $this->testable->getRecipient()); + $this->assertEquals($this->properties->recipient, $this->testable->recipient); + } + + /** @test */ + public function recipient_is_settable() + { + $this->testable->setRecipient('rec1'); + $this->assertEquals('rec1', $this->testable->getRecipient()); + + $this->testable->recipient = 'rec2'; + $this->assertEquals('rec2', $this->testable->getRecipient()); + } + + /** @test */ + public function sso_acs_url_is_accessible() + { + $this->assertEquals($this->properties->ssoAcsUrl, $this->testable->getSsoAcsUrl()); + $this->assertEquals($this->properties->ssoAcsUrl, $this->testable->ssoAcsUrl); + } + + /** @test */ + public function sso_acs_url_is_settable() + { + $this->testable->setSsoAcsUrl('http://example.com'); + $this->assertEquals('http://example.com', $this->testable->getSsoAcsUrl()); + + $this->testable->ssoAcsUrl = 'http://example.org'; + $this->assertEquals('http://example.org', $this->testable->getSsoAcsUrl()); + } + + /** @test */ + public function destination_is_accessible() + { + $this->assertEquals($this->properties->destination, $this->testable->getDestination()); + $this->assertEquals($this->properties->destination, $this->testable->destination); + } + + /** @test */ + public function destination_is_settable() + { + $this->testable->setDestination('dest1'); + $this->assertEquals('dest1', $this->testable->getDestination()); + + $this->testable->destination = 'dest2'; + $this->assertEquals('dest2', $this->testable->getDestination()); + } + + /** @test */ + public function response_signed_is_accessible() + { + $this->assertEquals($this->properties->responseSigned, $this->testable->getResponseSigned()); + $this->assertEquals($this->properties->responseSigned, $this->testable->responseSigned); + } + + /** @test */ + public function response_signed_is_settable() + { + $this->testable->setResponseSigned(true); + $this->assertEquals(true, $this->testable->getResponseSigned()); + + $this->testable->responseSigned = false; + $this->assertEquals(false, $this->testable->getResponseSigned()); + } + + /** @test */ + public function assertion_signed_is_accessible() + { + $this->assertEquals($this->properties->assertionSigned, $this->testable->getAssertionSigned()); + $this->assertEquals($this->properties->assertionSigned, $this->testable->assertionSigned); + } + + /** @test */ + public function assertion_signed_is_settable() + { + $this->testable->setAssertionSigned(true); + $this->assertEquals(true, $this->testable->getAssertionSigned()); + + $this->testable->assertionSigned = false; + $this->assertEquals(false, $this->testable->getAssertionSigned()); + } + + /** @test */ + public function digest_algorithm_is_accessible() + { + $this->assertEquals($this->properties->digestAlgorithm, $this->testable->getDigestAlgorithm()); + $this->assertEquals($this->properties->digestAlgorithm, $this->testable->digestAlgorithm); + } + + /** @test */ + public function digest_algorithm_is_settable() + { + $this->testable->setDigestAlgorithm('da1'); + $this->assertEquals('da1', $this->testable->getDigestAlgorithm()); + + $this->testable->digestAlgorithm = 'da2'; + $this->assertEquals('da2', $this->testable->getDigestAlgorithm()); + } + + /** @test */ + public function honor_force_authn_is_accessible() + { + $this->assertEquals($this->properties->honorForceAuthn, $this->testable->getHonorForceAuthn()); + $this->assertEquals($this->properties->honorForceAuthn, $this->testable->honorForceAuthn); + } + + /** @test */ + public function honor_force_authn_is_settable() + { + $this->testable->setHonorForceAuthn(true); + $this->assertEquals(true, $this->testable->getHonorForceAuthn()); + + $this->testable->honorForceAuthn = false; + $this->assertEquals(false, $this->testable->getHonorForceAuthn()); + } + + /** @test */ + public function audience_override_is_accessible() + { + $this->assertEquals($this->properties->audienceOverride, $this->testable->getAudienceOverride()); + $this->assertEquals($this->properties->audienceOverride, $this->testable->audienceOverride); + } + + /** @test */ + public function audience_override_is_settable() + { + $this->testable->setAudienceOverride('override1'); + $this->assertEquals('override1', $this->testable->getAudienceOverride()); + + $this->testable->audienceOverride = 'override2'; + $this->assertEquals('override2', $this->testable->getAudienceOverride()); + } + + /** @test */ + public function default_relay_state_is_accessible() + { + $this->assertEquals($this->properties->defaultRelayState, $this->testable->getDefaultRelayState()); + $this->assertEquals($this->properties->defaultRelayState, $this->testable->defaultRelayState); + } + + /** @test */ + public function default_relay_state_is_settable() + { + $this->testable->setDefaultRelayState('drs1'); + $this->assertEquals('drs1', $this->testable->getDefaultRelayState()); + + $this->testable->defaultRelayState = 'drs2'; + $this->assertEquals('drs2', $this->testable->getDefaultRelayState()); + } + + /** @test */ + public function recipient_override_is_accessible() + { + $this->assertEquals($this->properties->recipientOverride, $this->testable->getRecipientOverride()); + $this->assertEquals($this->properties->recipientOverride, $this->testable->recipientOverride); + } + + /** @test */ + public function recipient_override_is_settable() + { + $this->testable->setRecipientOverride('override1'); + $this->assertEquals('override1', $this->testable->getRecipientOverride()); + + $this->testable->recipientOverride = 'override2'; + $this->assertEquals('override2', $this->testable->getRecipientOverride()); + } + + /** @test */ + public function request_compressed_is_accessible() + { + $this->assertEquals($this->properties->requestCompressed, $this->testable->getRequestCompressed()); + $this->assertEquals($this->properties->requestCompressed, $this->testable->requestCompressed); + } + + /** @test */ + public function request_compressed_is_settable() + { + $this->testable->setRequestCompressed(true); + $this->assertEquals(true, $this->testable->getRequestCompressed()); + + $this->testable->requestCompressed = false; + $this->assertEquals(false, $this->testable->getRequestCompressed()); + } + + /** @test */ + public function sso_acs_url_override_is_accessible() + { + $this->assertEquals($this->properties->ssoAcsUrlOverride, $this->testable->getSsoAcsUrlOverride()); + $this->assertEquals($this->properties->ssoAcsUrlOverride, $this->testable->ssoAcsUrlOverride); + } + + /** @test */ + public function sso_acs_url_override_is_settable() + { + $this->testable->setSsoAcsUrlOverride('acs1'); + $this->assertEquals('acs1', $this->testable->getSsoAcsUrlOverride()); + + $this->testable->ssoAcsUrlOverride = 'acs2'; + $this->assertEquals('acs2', $this->testable->getSsoAcsUrlOverride()); + } + + /** @test */ + public function signature_algorithm_is_accessible() + { + $this->assertEquals($this->properties->signatureAlgorithm, $this->testable->getSignatureAlgorithm()); + $this->assertEquals($this->properties->signatureAlgorithm, $this->testable->signatureAlgorithm); + } + + /** @test */ + public function signature_algorithm_is_settable() + { + $this->testable->setSignatureAlgorithm('alg1'); + $this->assertEquals('alg1', $this->testable->getSignatureAlgorithm()); + + $this->testable->signatureAlgorithm = 'alg2'; + $this->assertEquals('alg2', $this->testable->getSignatureAlgorithm()); + } + /** @test */ + public function attribute_statements_is_accessible() + { + $this->assertEquals($this->properties->attributeStatements, $this->testable->getAttributeStatements()); + $this->assertEquals($this->properties->attributeStatements, $this->testable->attributeStatements); + } + + /** @test */ + public function attribute_statements_is_settable() + { + $this->testable->setAttributeStatements(['test'=>'this']); + $this->assertEquals(['test'=>'this'], $this->testable->getAttributeStatements()); + + $this->testable->attributeStatements = ['test'=>'that']; + $this->assertEquals(['test'=>'that'], $this->testable->getAttributeStatements()); + } + + /** @test */ + public function destination_override_is_accessible() + { + $this->assertEquals($this->properties->destinationOverride, $this->testable->getDestinationOverride()); + $this->assertEquals($this->properties->destinationOverride, $this->testable->destinationOverride); + } + + /** @test */ + public function destination_override_is_settable() + { + $this->testable->setDestinationOverride('dest1'); + $this->assertEquals('dest1', $this->testable->getDestinationOverride()); + + $this->testable->destinationOverride = 'dest2'; + $this->assertEquals('dest2', $this->testable->getDestinationOverride()); + } + + /** @test */ + public function subject_name_id_format_is_accessible() + { + $this->assertEquals($this->properties->subjectNameIdFormat, $this->testable->getSubjectNameIdFormat()); + $this->assertEquals($this->properties->subjectNameIdFormat, $this->testable->subjectNameIdFormat); + } + + /** @test */ + public function subject_name_id_format_is_settable() + { + $this->testable->setSubjectNameIdFormat('format1'); + $this->assertEquals('format1', $this->testable->getSubjectNameIdFormat()); + + $this->testable->subjectNameIdFormat = 'format2'; + $this->assertEquals('format2', $this->testable->getSubjectNameIdFormat()); + } + + /** @test */ + public function authn_context_class_ref_is_accessible() + { + $this->assertEquals($this->properties->authnContextClassRef, $this->testable->getAuthnContextClassRef()); + $this->assertEquals($this->properties->authnContextClassRef, $this->testable->authnContextClassRef); + } + + /** @test */ + public function authn_context_class_ref_is_settable() + { + $this->testable->setAuthnContextClassRef('ref1'); + $this->assertEquals('ref1', $this->testable->getAuthnContextClassRef()); + + $this->testable->authnContextClassRef = 'ref2'; + $this->assertEquals('ref2', $this->testable->getAuthnContextClassRef()); + } + + /** @test */ + public function subject_name_id_template_is_accessible() + { + $this->assertEquals($this->properties->subjectNameIdTemplate, $this->testable->getSubjectNameIdTemplate()); + $this->assertEquals($this->properties->subjectNameIdTemplate, $this->testable->subjectNameIdTemplate); + } + + /** @test */ + public function subject_name_id_template_is_settable() + { + $this->testable->setSubjectNameIdTemplate('temp1'); + $this->assertEquals('temp1', $this->testable->getSubjectNameIdTemplate()); + + $this->testable->subjectNameIdTemplate = 'temp2'; + $this->assertEquals('temp2', $this->testable->getSubjectNameIdTemplate()); + } + +} diff --git a/tests/Unit/Applications/SamlApplicationSettingsTest.php b/tests/Unit/Applications/SamlApplicationSettingsTest.php new file mode 100644 index 0000000000..4313e879a2 --- /dev/null +++ b/tests/Unit/Applications/SamlApplicationSettingsTest.php @@ -0,0 +1,82 @@ +assertInstanceOf(\Okta\Applications\SamlApplicationSettingsSignOn::class, $this->testable->getSignOn()); + $this->assertInstanceOf(\Okta\Applications\SamlApplicationSettingsSignOn::class, $this->testable->signOn); + } + + /** @test */ + public function sign_on_is_settable() + { + $signOn = $this->testable->getSignOn(); + + $signOn->testing = 'this'; + $this->testable->setSignOn($signOn); + $this->assertEquals('this', $this->testable->getSignOn()->testing); + + $signOn->testing = 'that'; + $this->testable->signOn = $signOn; + $this->assertEquals('that', $this->testable->getSignOn()->testing); + } + + +} diff --git a/tests/Unit/Applications/SamlApplicationTest.php b/tests/Unit/Applications/SamlApplicationTest.php new file mode 100644 index 0000000000..bfd8c2bf91 --- /dev/null +++ b/tests/Unit/Applications/SamlApplicationTest.php @@ -0,0 +1,52 @@ +assertInstanceOf(\Okta\Applications\SamlApplicationSettings::class, $this->testable->getSettings()); + $this->assertInstanceOf(\Okta\Applications\SamlApplicationSettings::class, $this->testable->settings); + } + + /** @test */ + public function settings_is_settable() + { + $settings = $this->testable->getSettings(); + + $settings->abc = '123'; + $this->testable->setSettings($settings); + $this->assertEquals('123', $this->testable->getSettings()->abc); + + $settings->abc = '456'; + $this->testable->settings = $settings; + $this->assertEquals('456', $this->testable->getSettings()->abc); + } + +} diff --git a/tests/Unit/Applications/SamlAttributeStatementTest.php b/tests/Unit/Applications/SamlAttributeStatementTest.php new file mode 100644 index 0000000000..02e6651e87 --- /dev/null +++ b/tests/Unit/Applications/SamlAttributeStatementTest.php @@ -0,0 +1,106 @@ +assertEquals($this->properties->name, $this->testable->getName()); + $this->assertEquals($this->properties->name, $this->testable->name); + } + + /** @test */ + public function name_is_settable() + { + $this->testable->setName('name1'); + $this->assertEquals('name1', $this->testable->getName()); + + $this->testable->name = 'name2'; + $this->assertEquals('name2', $this->testable->getName()); + } + + /** @test */ + public function type_is_accessible() + { + $this->assertEquals($this->properties->type, $this->testable->getType()); + $this->assertEquals($this->properties->type, $this->testable->type); + } + + /** @test */ + public function type_is_settable() + { + $this->testable->setType('type1'); + $this->assertEquals('type1', $this->testable->getType()); + + $this->testable->type = 'type2'; + $this->assertEquals('type2', $this->testable->getType()); + } + + /** @test */ + public function values_is_accessible() + { + $this->assertEquals($this->properties->values, $this->testable->getValues()); + $this->assertEquals($this->properties->values, $this->testable->values); + } + + /** @test */ + public function values_is_settable() + { + $this->testable->setValues(['test']); + $this->assertEquals(['test'], $this->testable->getValues()); + + $this->testable->values = ['this']; + $this->assertEquals(['this'], $this->testable->getValues()); + } + + /** @test */ + public function namespace_is_accessible() + { + $this->assertEquals($this->properties->namespace, $this->testable->getNamespace()); + $this->assertEquals($this->properties->namespace, $this->testable->namespace); + } + + /** @test */ + public function namespace_is_settable() + { + $this->testable->setNamespace('ns1'); + $this->assertEquals('ns1', $this->testable->getNamespace()); + + $this->testable->namespace = 'ns2'; + $this->assertEquals('ns2', $this->testable->getNamespace()); + } + +} diff --git a/tests/Unit/Applications/SchemeApplicationCredentialsTest.php b/tests/Unit/Applications/SchemeApplicationCredentialsTest.php new file mode 100644 index 0000000000..1e763aa1a9 --- /dev/null +++ b/tests/Unit/Applications/SchemeApplicationCredentialsTest.php @@ -0,0 +1,137 @@ +assertEquals($this->properties->scheme, $this->testable->getScheme()); + $this->assertEquals($this->properties->scheme, $this->testable->scheme); + } + + /** @test */ + public function scheme_is_settable() + { + $this->testable->setScheme('scheme1'); + $this->assertEquals('scheme1', $this->testable->getScheme()); + + $this->testable->scheme = 'scheme2'; + $this->assertEquals('scheme2', $this->testable->getScheme()); + } + + /** @test */ + public function signing_is_accessible() + { + $this->assertInstanceOf(\Okta\Applications\ApplicationCredentialsSigning::class, $this->testable->getSigning()); + $this->assertInstanceOf(\Okta\Applications\ApplicationCredentialsSigning::class, $this->testable->signing); + } + + /** @test */ + public function signing_is_settable() + { + $signing = $this->testable->getSigning(); + + $signing->signature = 'sign1'; + $this->testable->setSigning($signing); + $this->assertEquals('sign1', $this->testable->getSigning()->signature); + + $signing->signature = 'sign2'; + $this->testable->signing = $signing; + $this->assertEquals('sign2', $this->testable->getSigning()->signature); + } + + /** @test */ + public function password_is_accessible() + { + $this->assertInstanceOf(\Okta\Users\PasswordCredential::class, $this->testable->getPassword()); + $this->assertInstanceOf(\Okta\Users\PasswordCredential::class, $this->testable->password); + } + + /** @test */ + public function password_is_settable() + { + $password = $this->testable->getPassword(); + + $password->value = 'pass1'; + $this->testable->setPassword($password); + $this->assertEquals('pass1', $this->testable->getPassword()->value); + + $password->value = 'pass2'; + $this->testable->password = $password; + $this->assertEquals('pass2', $this->testable->getPassword()->value); + } + + + /** @test */ + public function user_name_is_accessible() + { + $this->assertEquals($this->properties->userName, $this->testable->getUserName()); + $this->assertEquals($this->properties->userName, $this->testable->userName); + } + + /** @test */ + public function user_name_is_settable() + { + $this->testable->setUserName('user'); + $this->assertEquals('user', $this->testable->getUserName()); + + $this->testable->userName = 'name'; + $this->assertEquals('name', $this->testable->getUserName()); + } + + /** @test */ + public function reveal_password_is_accessible() + { + $this->assertEquals($this->properties->revealPassword, $this->testable->getRevealPassword()); + $this->assertEquals($this->properties->revealPassword, $this->testable->revealPassword); + } + + /** @test */ + public function reveal_password_is_settable() + { + $this->testable->setRevealPassword(true); + $this->assertEquals(true, $this->testable->getRevealPassword()); + + $this->testable->revealPassword = false; + $this->assertEquals(false, $this->testable->getRevealPassword()); + } + + + +} diff --git a/tests/Unit/Applications/SecurePasswordStoreApplicationSettingsApplicationTest.php b/tests/Unit/Applications/SecurePasswordStoreApplicationSettingsApplicationTest.php new file mode 100644 index 0000000000..1c011cc8a6 --- /dev/null +++ b/tests/Unit/Applications/SecurePasswordStoreApplicationSettingsApplicationTest.php @@ -0,0 +1,196 @@ +assertEquals($this->properties->url, $this->testable->getUrl()); + $this->assertEquals($this->properties->url, $this->testable->url); + } + + /** @test */ + public function url_is_settable() + { + $this->testable->setUrl('http://example.com'); + $this->assertEquals('http://example.com', $this->testable->getUrl()); + + $this->testable->url = 'http://example.org'; + $this->assertEquals('http://example.org', $this->testable->getUrl()); + } + + /** @test */ + public function password_field_is_accessible() + { + $this->assertEquals($this->properties->passwordField, $this->testable->getPasswordField()); + $this->assertEquals($this->properties->passwordField, $this->testable->passwordField); + } + + /** @test */ + public function password_field_is_settable() + { + $this->testable->setPasswordField('abc'); + $this->assertEquals('abc', $this->testable->getPasswordField()); + + $this->testable->passwordField = '123'; + $this->assertEquals('123', $this->testable->getPasswordField()); + } + + /** @test */ + public function username_field_is_accessible() + { + $this->assertEquals($this->properties->usernameField, $this->testable->getUsernameField()); + $this->assertEquals($this->properties->usernameField, $this->testable->usernameField); + } + + /** @test */ + public function username_field_is_settable() + { + $this->testable->setUsernameField('abc'); + $this->assertEquals('abc', $this->testable->getUsernameField()); + + $this->testable->usernameField = '123'; + $this->assertEquals('123', $this->testable->getUsernameField()); + } + + /** @test */ + public function optional_field_1_is_accessible() + { + $this->assertEquals($this->properties->optionalField1, $this->testable->getOptionalField1()); + $this->assertEquals($this->properties->optionalField1, $this->testable->optionalField1); + } + + /** @test */ + public function optional_field_1_is_settable() + { + $this->testable->setOptionalField1('abc'); + $this->assertEquals('abc', $this->testable->getOptionalField1()); + + $this->testable->optionalField1 = '123'; + $this->assertEquals('123', $this->testable->getOptionalField1()); + } + + /** @test */ + public function options_field_2_is_accessible() + { + $this->assertEquals($this->properties->optionalField2, $this->testable->getOptionalField2()); + $this->assertEquals($this->properties->optionalField2, $this->testable->optionalField2); + } + + /** @test */ + public function options_field_2_is_settable() + { + $this->testable->setOptionalField2('abc'); + $this->assertEquals('abc', $this->testable->getOptionalField2()); + + $this->testable->optionalField2 = '123'; + $this->assertEquals('123', $this->testable->getOptionalField2()); + } + + /** @test */ + public function options_field_3_is_accessible() + { + $this->assertEquals($this->properties->optionalField3, $this->testable->getOptionalField3()); + $this->assertEquals($this->properties->optionalField3, $this->testable->optionalField3); + } + + /** @test */ + public function options_field_3_is_settable() + { + $this->testable->setOptionalField3('abc'); + $this->assertEquals('abc', $this->testable->getOptionalField3()); + + $this->testable->optionalField3 = '123'; + $this->assertEquals('123', $this->testable->getOptionalField3()); + } + + /** @test */ + public function optional_field_1_value_is_accessible() + { + $this->assertEquals($this->properties->optionalField1Value, $this->testable->getOptionalField1Value()); + $this->assertEquals($this->properties->optionalField1Value, $this->testable->optionalField1Value); + } + + /** @test */ + public function optional_field_1_value_is_settable() + { + $this->testable->setOptionalField1Value('abc'); + $this->assertEquals('abc', $this->testable->getOptionalField1Value()); + + $this->testable->optionalField1Value = '123'; + $this->assertEquals('123', $this->testable->getOptionalField1Value()); + } + + /** @test */ + public function optional_field_2_value_is_accessible() + { + $this->assertEquals($this->properties->optionalField2Value, $this->testable->getOptionalField2Value()); + $this->assertEquals($this->properties->optionalField2Value, $this->testable->optionalField2Value); + } + + /** @test */ + public function optional_field_2_value_is_settable() + { + $this->testable->setOptionalField2Value('abc'); + $this->assertEquals('abc', $this->testable->getOptionalField2Value()); + + $this->testable->optionalField2Value = '123'; + $this->assertEquals('123', $this->testable->getOptionalField2Value()); + } + + /** @test */ + public function optional_field_3_value_is_accessible() + { + $this->assertEquals($this->properties->optionalField3Value, $this->testable->getOptionalField3Value()); + $this->assertEquals($this->properties->optionalField3Value, $this->testable->optionalField3Value); + } + + /** @test */ + public function optional_field_3_value_is_settable() + { + $this->testable->setOptionalField3Value('abc'); + $this->assertEquals('abc', $this->testable->getOptionalField3Value()); + + $this->testable->optionalField3Value = '123'; + $this->assertEquals('123', $this->testable->getOptionalField3Value()); + } + + + +} diff --git a/tests/Unit/Applications/SecurePasswordStoreApplicationSettingsTest.php b/tests/Unit/Applications/SecurePasswordStoreApplicationSettingsTest.php new file mode 100644 index 0000000000..ae9550f57b --- /dev/null +++ b/tests/Unit/Applications/SecurePasswordStoreApplicationSettingsTest.php @@ -0,0 +1,54 @@ +assertInstanceOf(\Okta\Applications\SecurePasswordStoreApplicationSettingsApplication::class, $this->testable->getApp()); + $this->assertInstanceOf(\Okta\Applications\SecurePasswordStoreApplicationSettingsApplication::class, $this->testable->app); + } + + /** @test */ + public function app_is_settable() + { + $app = $this->testable->getApp(); + $app->url = "http://example.com"; + $this->testable->setApp($app); + $this->assertEquals("http://example.com", $this->testable->getApp()->url); + + $app->url = "http://example.org"; + $this->testable->app = $app; + $this->assertEquals("http://example.org", $this->testable->getApp()->url); + } + +} diff --git a/tests/Unit/Applications/SecurePasswordStoreApplicationTest.php b/tests/Unit/Applications/SecurePasswordStoreApplicationTest.php new file mode 100644 index 0000000000..a5fe9fa6c7 --- /dev/null +++ b/tests/Unit/Applications/SecurePasswordStoreApplicationTest.php @@ -0,0 +1,75 @@ +assertInstanceOf(\Okta\Applications\SecurePasswordStoreApplicationSettings::class, + $this->testable->getSettings()); + $this->assertInstanceOf(\Okta\Applications\SecurePasswordStoreApplicationSettings::class, + $this->testable->settings); + } + + /** @test */ + public function settings_is_settable() + { + $settings = $this->testable->getSettings(); + + $settings->abc = '123'; + $this->testable->setSettings($settings); + $this->assertEquals('123', $this->testable->getSettings()->abc); + + $settings->abc = '456'; + $this->testable->settings = $settings; + $this->assertEquals('456', $this->testable->getSettings()->abc); + } + + /** @test */ + public function credentials_is_accessible() + { + $this->assertInstanceOf(\Okta\Applications\SchemeApplicationCredentials::class,$this->testable->getCredentials()); + $this->assertInstanceOf(\Okta\Applications\SchemeApplicationCredentials::class,$this->testable->credentials); + } + + /** @test */ + public function credentials_is_settable() + { + $credentials = $this->testable->getCredentials(); + + $credentials->abc = '123'; + $this->testable->setCredentials($credentials); + $this->assertEquals('123', $this->testable->getCredentials()->abc); + + $credentials->abc = '456'; + $this->testable->credentials = $credentials; + $this->assertEquals('456', $this->testable->getCredentials()->abc); + } + +} diff --git a/tests/Unit/Applications/SwaApplicationSettingsApplicationTest.php b/tests/Unit/Applications/SwaApplicationSettingsApplicationTest.php new file mode 100644 index 0000000000..f5e88b1c4c --- /dev/null +++ b/tests/Unit/Applications/SwaApplicationSettingsApplicationTest.php @@ -0,0 +1,122 @@ +assertEquals($this->properties->url, $this->testable->getUrl()); + $this->assertEquals($this->properties->url, $this->testable->url); + } + + /** @test */ + public function url_is_settable() + { + $this->testable->setUrl("http://example.com"); + $this->assertEquals("http://example.com", $this->testable->getUrl()); + + $this->testable->url = "http://example.org"; + $this->assertEquals("http://example.org", $this->testable->getUrl()); + } + + /** @test */ + public function button_field_is_accessible() + { + $this->assertEquals($this->properties->buttonField, $this->testable->getButtonField()); + $this->assertEquals($this->properties->buttonField, $this->testable->buttonField); + } + + /** @test */ + public function button_field_is_settable() + { + $this->testable->setButtonField('field1'); + $this->assertEquals('field1', $this->testable->getButtonField()); + + $this->testable->buttonField = 'field2'; + $this->assertEquals('field2', $this->testable->getButtonField()); + } + + /** @test */ + public function login_url_regex_is_accessible() + { + $this->assertEquals($this->properties->loginUrlRegex, $this->testable->getLoginUrlRegex()); + $this->assertEquals($this->properties->loginUrlRegex, $this->testable->loginUrlRegex); + } + + /** @test */ + public function login_url_regex_is_settable() + { + $this->testable->setLoginUrlRegex('regex1'); + $this->assertEquals('regex1', $this->testable->getLoginUrlRegex()); + + $this->testable->loginUrlRegex = 'regex2'; + $this->assertEquals('regex2', $this->testable->getLoginUrlRegex()); + } + + /** @test */ + public function password_field_is_accessible() + { + $this->assertEquals($this->properties->passwordField, $this->testable->getPasswordField()); + $this->assertEquals($this->properties->passwordField, $this->testable->passwordField); + } + + /** @test */ + public function password_field_is_settable() + { + $this->testable->setPasswordField('field1'); + $this->assertEquals('field1', $this->testable->getPasswordField()); + + $this->testable->passwordField = 'field2'; + $this->assertEquals('field2', $this->testable->getPasswordField()); + } + + /** @test */ + public function username_field_is_accessible() + { + $this->assertEquals($this->properties->usernameField, $this->testable->getUsernameField()); + $this->assertEquals($this->properties->usernameField, $this->testable->usernameField); + } + + /** @test */ + public function username_field_is_settable() + { + $this->testable->setUsernameField('field1'); + $this->assertEquals('field1', $this->testable->getUsernameField()); + + $this->testable->usernameField = 'field2'; + $this->assertEquals('field2', $this->testable->getUsernameField()); + } + +} diff --git a/tests/Unit/Applications/SwaApplicationSettingsTest.php b/tests/Unit/Applications/SwaApplicationSettingsTest.php new file mode 100644 index 0000000000..105b4f4cc2 --- /dev/null +++ b/tests/Unit/Applications/SwaApplicationSettingsTest.php @@ -0,0 +1,60 @@ +assertInstanceOf(\Okta\Applications\SwaApplicationSettingsApplication::class, $this->testable->getApp + ()); + $this->assertInstanceOf(\Okta\Applications\SwaApplicationSettingsApplication::class, $this->testable->app); + } + + /** @test */ + public function app_is_settable() + { + $app = $this->testable->getApp(); + $app->url = "http://example.com"; + $this->testable->setApp($app); + $this->assertEquals("http://example.com", $this->testable->getApp()->url); + + $app->url = "http://example.org"; + $this->testable->app = $app; + $this->assertEquals("http://example.org", $this->testable->getApp()->url); + } + +} diff --git a/tests/Unit/Applications/SwaApplicationTest.php b/tests/Unit/Applications/SwaApplicationTest.php new file mode 100644 index 0000000000..e17cdb9e53 --- /dev/null +++ b/tests/Unit/Applications/SwaApplicationTest.php @@ -0,0 +1,52 @@ +assertInstanceOf(\Okta\Applications\SwaApplicationSettings::class, $this->testable->getSettings()); + $this->assertInstanceOf(\Okta\Applications\SwaApplicationSettings::class, $this->testable->settings); + } + + /** @test */ + public function settings_is_settable() + { + $settings = $this->testable->getSettings(); + + $settings->abc = '123'; + $this->testable->setSettings($settings); + $this->assertEquals('123', $this->testable->getSettings()->abc); + + $settings->abc = '456'; + $this->testable->settings = $settings; + $this->assertEquals('456', $this->testable->getSettings()->abc); + } + +} diff --git a/tests/Unit/Applications/SwaThreeFieldApplicationSettingsApplicationTest.php b/tests/Unit/Applications/SwaThreeFieldApplicationSettingsApplicationTest.php new file mode 100644 index 0000000000..fc64e0673f --- /dev/null +++ b/tests/Unit/Applications/SwaThreeFieldApplicationSettingsApplicationTest.php @@ -0,0 +1,161 @@ +assertEquals($this->properties->targetUrl, $this->testable->getTargetUrl()); + $this->assertEquals($this->properties->targetUrl, $this->testable->targetUrl); + } + + /** @test */ + public function target_url_is_settable() + { + $this->testable->setTargetUrl('http://example.com'); + $this->assertEquals('http://example.com', $this->testable->getTargetUrl()); + + $this->testable->targetUrl = 'http://example.org'; + $this->assertEquals('http://example.org', $this->testable->getTargetUrl()); + } + + + /** @test */ + public function button_selector_is_accessible() + { + $this->assertEquals($this->properties->buttonSelector, $this->testable->getButtonSelector()); + $this->assertEquals($this->properties->buttonSelector, $this->testable->buttonSelector); + } + + /** @test */ + public function button_selector_is_settable() + { + $this->testable->setButtonSelector('sel1'); + $this->assertEquals('sel1', $this->testable->getButtonSelector()); + + $this->testable->buttonSelector = 'sel2'; + $this->assertEquals('sel2', $this->testable->getButtonSelector()); + } + + /** @test */ + public function extra_field_value_is_accessible() + { + $this->assertEquals($this->properties->extraFieldValue, $this->testable->getExtraFieldValue()); + $this->assertEquals($this->properties->extraFieldValue, $this->testable->extraFieldValue); + } + + /** @test */ + public function extra_field_value_is_settable() + { + $this->testable->setExtraFieldValue('val1'); + $this->assertEquals('val1', $this->testable->getExtraFieldValue()); + + $this->testable->extraFieldValue = 'val2'; + $this->assertEquals('val2', $this->testable->getExtraFieldValue()); + } + + /** @test */ + public function password_selector_is_accessible() + { + $this->assertEquals($this->properties->passwordSelector, $this->testable->getPasswordSelector()); + $this->assertEquals($this->properties->passwordSelector, $this->testable->passwordSelector); + } + + /** @test */ + public function password_selector_is_settable() + { + $this->testable->setPasswordSelector('pass1'); + $this->assertEquals('pass1', $this->testable->getPasswordSelector()); + + $this->testable->passwordSelector = 'pass2'; + $this->assertEquals('pass2', $this->testable->getPasswordSelector()); + } + + /** @test */ + public function user_name_selector_is_accessible() + { + $this->assertEquals($this->properties->userNameSelector, $this->testable->getUserNameSelector()); + $this->assertEquals($this->properties->userNameSelector, $this->testable->userNameSelector); + } + + /** @test */ + public function user_name_selector_is_settable() + { + $this->testable->setUserNameSelector('un1'); + $this->assertEquals('un1', $this->testable->getUserNameSelector()); + + $this->testable->userNameSelector = 'un2'; + $this->assertEquals('un2', $this->testable->getUserNameSelector()); + } + + /** @test */ + public function extra_field_selector_is_accessible() + { + $this->assertEquals($this->properties->extraFieldSelector, $this->testable->getExtraFieldSelector()); + $this->assertEquals($this->properties->extraFieldSelector, $this->testable->extraFieldSelector); + } + + /** @test */ + public function extra_field_selector_is_settable() + { + $this->testable->setExtraFieldSelector('sel1'); + $this->assertEquals('sel1', $this->testable->getExtraFieldSelector()); + + $this->testable->extraFieldSelector = 'sel2'; + $this->assertEquals('sel2', $this->testable->getExtraFieldSelector()); + } + + /** @test */ + public function login_url_regex_is_accessible() + { + $this->assertEquals($this->properties->loginUrlRegex, $this->testable->getLoginUrlRegex()); + $this->assertEquals($this->properties->loginUrlRegex, $this->testable->loginUrlRegex); + } + + /** @test */ + public function login_url_regex_is_settable() + { + $this->testable->setLoginUrlRegex('regex1'); + $this->assertEquals('regex1', $this->testable->getLoginUrlRegex()); + + $this->testable->loginUrlRegex = 'regex2'; + $this->assertEquals('regex2', $this->testable->getLoginUrlRegex()); + } + + + +} diff --git a/tests/Unit/Applications/SwaThreeFieldApplicationSettingsTest.php b/tests/Unit/Applications/SwaThreeFieldApplicationSettingsTest.php new file mode 100644 index 0000000000..015dd8da5c --- /dev/null +++ b/tests/Unit/Applications/SwaThreeFieldApplicationSettingsTest.php @@ -0,0 +1,62 @@ +assertInstanceOf(\Okta\Applications\SwaThreeFieldApplicationSettingsApplication::class, $this->testable->getApp + ()); + $this->assertInstanceOf(\Okta\Applications\SwaThreeFieldApplicationSettingsApplication::class, $this->testable->app); + } + + /** @test */ + public function app_is_settable() + { + $app = $this->testable->getApp(); + $app->url = "http://example.com"; + $this->testable->setApp($app); + $this->assertEquals("http://example.com", $this->testable->getApp()->url); + + $app->url = "http://example.org"; + $this->testable->app = $app; + $this->assertEquals("http://example.org", $this->testable->getApp()->url); + } + +} diff --git a/tests/Unit/Applications/SwaThreeFieldApplicationTest.php b/tests/Unit/Applications/SwaThreeFieldApplicationTest.php new file mode 100644 index 0000000000..0adad8d9a8 --- /dev/null +++ b/tests/Unit/Applications/SwaThreeFieldApplicationTest.php @@ -0,0 +1,52 @@ +assertInstanceOf(\Okta\Applications\SwaThreeFieldApplicationSettings::class, $this->testable->getSettings()); + $this->assertInstanceOf(\Okta\Applications\SwaThreeFieldApplicationSettings::class, $this->testable->settings); + } + + /** @test */ + public function settings_is_settable() + { + $settings = $this->testable->getSettings(); + + $settings->abc = '123'; + $this->testable->setSettings($settings); + $this->assertEquals('123', $this->testable->getSettings()->abc); + + $settings->abc = '456'; + $this->testable->settings = $settings; + $this->assertEquals('456', $this->testable->getSettings()->abc); + } + +} diff --git a/tests/Unit/Applications/WsFederationApplicationSettingsApplicationTest.php b/tests/Unit/Applications/WsFederationApplicationSettingsApplicationTest.php new file mode 100644 index 0000000000..231551d765 --- /dev/null +++ b/tests/Unit/Applications/WsFederationApplicationSettingsApplicationTest.php @@ -0,0 +1,248 @@ +assertEquals($this->properties->realm, $this->testable->getRealm()); + $this->assertEquals($this->properties->realm, $this->testable->realm); + } + + /** @test */ + public function realm_is_settable() + { + $this->testable->setRealm('realm1'); + $this->assertEquals('realm1', $this->testable->getRealm()); + + $this->testable->realm = 'realm2'; + $this->assertEquals('realm2', $this->testable->getRealm()); + } + + /** @test */ + public function site_url_is_accessible() + { + $this->assertEquals($this->properties->siteURL, $this->testable->getSiteUrl()); + $this->assertEquals($this->properties->siteURL, $this->testable->siteUrl); + } + + /** @test */ + public function site_url_is_settable() + { + $this->testable->setSiteUrl('http://example.com'); + $this->assertEquals('http://example.com', $this->testable->getSiteUrl()); + + $this->testable->siteUrl = 'http://example.org'; + $this->assertEquals('http://example.org', $this->testable->getSiteUrl()); + } + + /** @test */ + public function group_name_is_accessible() + { + $this->assertEquals($this->properties->groupName, $this->testable->getGroupName()); + $this->assertEquals($this->properties->groupName, $this->testable->groupName); + } + + /** @test */ + public function group_name_is_settable() + { + $this->testable->setGroupName('name1'); + $this->assertEquals('name1', $this->testable->getGroupName()); + + $this->testable->groupName = 'name2'; + $this->assertEquals('name2', $this->testable->getGroupName()); + } + + /** @test */ + public function w_reply_Url_is_accessible() + { + $this->assertEquals($this->properties->wReplyURL, $this->testable->getWReplyUrl()); + $this->assertEquals($this->properties->wReplyURL, $this->testable->wReplyUrl); + } + + /** @test */ + public function w_reply_Url_is_settable() + { + $this->testable->setWReplyUrl('http://example.net'); + $this->assertEquals('http://example.net', $this->testable->getWReplyUrl()); + + $this->testable->wReplyUrl = 'http://example.org'; + $this->assertEquals('http://example.org', $this->testable->getWReplyUrl()); + } + + /** @test */ + public function group_filter_is_accessible() + { + $this->assertEquals($this->properties->groupFilter, $this->testable->getGroupFilter()); + $this->assertEquals($this->properties->groupFilter, $this->testable->groupFilter); + } + + /** @test */ + public function group_filter_is_settable() + { + $this->testable->setGroupFilter('filter1'); + $this->assertEquals('filter1', $this->testable->getGroupFilter()); + + $this->testable->groupFilter = 'filter2'; + $this->assertEquals('filter2', $this->testable->getGroupFilter()); + } + + /** @test */ + public function name_id_format_is_accessible() + { + $this->assertEquals($this->properties->nameIDFormat, $this->testable->getNameIdFormat()); + $this->assertEquals($this->properties->nameIDFormat, $this->testable->nameIdFormat); + } + + /** @test */ + public function name_id_format_is_settable() + { + $this->testable->setNameIdFormat('format1'); + $this->assertEquals('format1', $this->testable->getNameIdFormat()); + + $this->testable->nameIdFormat = 'format2'; + $this->assertEquals('format2', $this->testable->getNameIdFormat()); + } + + /** @test */ + public function w_reply_override_is_accessible() + { + $this->assertEquals($this->properties->wReplyOverride, $this->testable->getWReplyOverride()); + $this->assertEquals($this->properties->wReplyOverride, $this->testable->wReplyOverride); + } + + /** @test */ + public function w_reply_override_is_settable() + { + $this->testable->setWReplyOverride(true); + $this->assertEquals(true, $this->testable->getWReplyOverride()); + + $this->testable->wReplyOverride = false; + $this->assertEquals(false, $this->testable->getWReplyOverride()); + } + + /** @test */ + public function group_value_format_is_accessible() + { + $this->assertEquals($this->properties->groupValueFormat, $this->testable->getGroupValueFormat()); + $this->assertEquals($this->properties->groupValueFormat, $this->testable->groupValueFormat); + } + + /** @test */ + public function group_value_format_is_settable() + { + $this->testable->setGroupValueFormat('format1'); + $this->assertEquals('format1', $this->testable->getGroupValueFormat()); + + $this->testable->groupValueFormat = 'format2'; + $this->assertEquals('format2', $this->testable->getGroupValueFormat()); + } + + /** @test */ + public function username_attribute_is_accessible() + { + $this->assertEquals($this->properties->usernameAttribute, $this->testable->getUsernameAttribute()); + $this->assertEquals($this->properties->usernameAttribute, $this->testable->usernameAttribute); + } + + /** @test */ + public function username_attribute_is_settable() + { + $this->testable->setUsernameAttribute('att1'); + $this->assertEquals('att1', $this->testable->getUsernameAttribute()); + + $this->testable->usernameAttribute = 'att2'; + $this->assertEquals('att2', $this->testable->getUsernameAttribute()); + } + + /** @test */ + public function attribute_statements_is_accessible() + { + $this->assertEquals($this->properties->attributeStatements, $this->testable->getAttributeStatements()); + $this->assertEquals($this->properties->attributeStatements, $this->testable->attributeStatements); + } + + /** @test */ + public function attribute_statements_is_settable() + { + $this->testable->setAttributeStatements('state1'); + $this->assertEquals('state1', $this->testable->getAttributeStatements()); + + $this->testable->attributeStatements = 'state2'; + $this->assertEquals('state2', $this->testable->getAttributeStatements()); + } + + /** @test */ + public function audience_restriction_is_accessible() + { + $this->assertEquals($this->properties->audienceRestriction, $this->testable->getAudienceRestriction()); + $this->assertEquals($this->properties->audienceRestriction, $this->testable->audienceRestriction); + } + + /** @test */ + public function audience_restriction_is_settable() + { + $this->testable->setAudienceRestriction('res1'); + $this->assertEquals('res1', $this->testable->getAudienceRestriction()); + + $this->testable->audienceRestriction = 'res2'; + $this->assertEquals('res2', $this->testable->getAudienceRestriction()); + } + + /** @test */ + public function authn_context_class_ref_is_accessible() + { + $this->assertEquals($this->properties->authnContextClassRef, $this->testable->getAuthnContextClassRef()); + $this->assertEquals($this->properties->authnContextClassRef, $this->testable->authnContextClassRef); + } + + /** @test */ + public function authn_context_class_ref_is_settable() + { + $this->testable->setAuthnContextClassRef('ref1'); + $this->assertEquals('ref1', $this->testable->getAuthnContextClassRef()); + + $this->testable->authnContextClassRef = 'ref2'; + $this->assertEquals('ref2', $this->testable->getAuthnContextClassRef()); + } + +} diff --git a/tests/Unit/Applications/WsFederationApplicationSettingsTest.php b/tests/Unit/Applications/WsFederationApplicationSettingsTest.php new file mode 100644 index 0000000000..e8b46e100c --- /dev/null +++ b/tests/Unit/Applications/WsFederationApplicationSettingsTest.php @@ -0,0 +1,67 @@ +assertInstanceOf(\Okta\Applications\WsFederationApplicationSettingsApplication::class, $this->testable->getApp + ()); + $this->assertInstanceOf(\Okta\Applications\WsFederationApplicationSettingsApplication::class, $this->testable->app); + } + + /** @test */ + public function app_is_settable() + { + $app = $this->testable->getApp(); + $app->url = "http://example.com"; + $this->testable->setApp($app); + $this->assertEquals("http://example.com", $this->testable->getApp()->url); + + $app->url = "http://example.org"; + $this->testable->app = $app; + $this->assertEquals("http://example.org", $this->testable->getApp()->url); + } + +} diff --git a/tests/Unit/Applications/WsFederationApplicationTest.php b/tests/Unit/Applications/WsFederationApplicationTest.php new file mode 100644 index 0000000000..94c9c76da8 --- /dev/null +++ b/tests/Unit/Applications/WsFederationApplicationTest.php @@ -0,0 +1,52 @@ +assertInstanceOf(\Okta\Applications\WsFederationApplicationSettings::class, $this->testable->getSettings()); + $this->assertInstanceOf(\Okta\Applications\WsFederationApplicationSettings::class, $this->testable->settings); + } + + /** @test */ + public function settings_is_settable() + { + $settings = $this->testable->getSettings(); + + $settings->abc = '123'; + $this->testable->setSettings($settings); + $this->assertEquals('123', $this->testable->getSettings()->abc); + + $settings->abc = '456'; + $this->testable->settings = $settings; + $this->assertEquals('456', $this->testable->getSettings()->abc); + } + +} diff --git a/tests/Unit/GroupRules/GroupRuleConditionsTest.php b/tests/Unit/GroupRules/GroupRuleConditionsTest.php index 0a8645f168..fa385aa6a8 100644 --- a/tests/Unit/GroupRules/GroupRuleConditionsTest.php +++ b/tests/Unit/GroupRules/GroupRuleConditionsTest.php @@ -57,7 +57,7 @@ public static function setUpBeforeClass() } self::$testable = new GroupRuleConditions(NULL, $class); } - + /** @test */ public function people_is_accessible() { diff --git a/tests/Unit/GroupRules/GroupRuleTest.php b/tests/Unit/GroupRules/GroupRuleTest.php index 6f967ed34e..e182feb47e 100644 --- a/tests/Unit/GroupRules/GroupRuleTest.php +++ b/tests/Unit/GroupRules/GroupRuleTest.php @@ -187,15 +187,18 @@ public function save_makes_a_request_to_save_endpoint() $httpClient = $this->createNewHttpClient(); $groupRule = $this->createNewGroupRule(); - $groupRule->save(); + $response = $groupRule->save(); $request = $httpClient->getRequests(); $this->assertEquals('POST', $request[0]->getMethod()); + $this->assertEquals( "/api/v1/groups/{$groupRule->getId()}", $request[0]->getUri()->getPath() ); + + $this->assertInstanceOf(GroupRule::class, $response); } /** @test */ diff --git a/tests/Unit/Groups/GroupTest.php b/tests/Unit/Groups/GroupTest.php index 884e1f27dc..4914ea3ea4 100644 --- a/tests/Unit/Groups/GroupTest.php +++ b/tests/Unit/Groups/GroupTest.php @@ -205,7 +205,7 @@ public function get_users_makes_correct_request() $request[0]->getUri()->getPath() ); $this->assertInstanceOf( - \Okta\Groups\Collection::class, + \Okta\Users\Collection::class, $groupUsers ); diff --git a/tests/Unit/Sessions/CreateSessionRequestTest.php b/tests/Unit/Sessions/CreateSessionRequestTest.php new file mode 100644 index 0000000000..509cd74ade --- /dev/null +++ b/tests/Unit/Sessions/CreateSessionRequestTest.php @@ -0,0 +1,50 @@ +assertEquals($this->properties->sessionToken, $this->testable->getSessionToken()); + $this->assertEquals($this->properties->sessionToken, $this->testable->sessionToken); + } + + /** @test */ + public function session_token_is_settable() + { + $this->testable->setSessionToken('token1'); + $this->assertEquals('token1', $this->testable->getSessionToken()); + + $this->testable->sessionToken = 'token2'; + $this->assertEquals('token2', $this->testable->getSessionToken()); + } + + + +} diff --git a/tests/Unit/Sessions/SessionAuthorityTest.php b/tests/Unit/Sessions/SessionAuthorityTest.php new file mode 100644 index 0000000000..7d9c2a0f10 --- /dev/null +++ b/tests/Unit/Sessions/SessionAuthorityTest.php @@ -0,0 +1,46 @@ +assertEquals($this->properties->id, $this->testable->getId()); + $this->assertEquals($this->properties->id, $this->testable->id); + } + + /** @test */ + public function type_is_accessible() + { + $this->assertEquals($this->properties->type, $this->testable->getType()); + $this->assertEquals($this->properties->type, $this->testable->type); + } + + +} diff --git a/tests/Unit/Sessions/SessionTest.php b/tests/Unit/Sessions/SessionTest.php new file mode 100644 index 0000000000..502ff254c6 --- /dev/null +++ b/tests/Unit/Sessions/SessionTest.php @@ -0,0 +1,184 @@ +createNewHttpClient([ + "getBody" => '{"id":"abc123", "signOnMode": "BOOKMARK"}' + ]); + + $this->testable->get('abc123'); + + $requests = $httpClient->getRequests(); + + $this->assertEquals('/api/v1/sessions/abc123', $requests[0]->getUri()->getPath()); + $this->assertEquals('GET', $requests[0]->getMethod()); + } + + /** @test */ + public function getting_a_session_will_return_session_object() + { + $client = $this->createNewHttpClient([ + "getBody" => '{"id":"abc123", "signOnMode": "BOOKMARK"}' + ]); + + $app = $this->testable->get('abc123'); + + $this->assertInstanceOf(\Okta\Sessions\Session::class, $app); + } + + /** @test */ + public function deleting_a_session_will_make_request_to_correct_endpoint() + { + $httpClient = $this->createNewHttpClient(); + + $this->testable->delete(); + + $requests = $httpClient->getRequests(); + + $this->assertEquals('/api/v1/sessions/'.$this->testable->getId(), $requests[0]->getUri()->getPath()); + $this->assertEquals('DELETE', $requests[0]->getMethod()); + } + + /** @test */ + public function links_is_accessible() + { + $this->assertEquals($this->properties->_links, $this->testable->getLinks()); + $this->assertEquals($this->properties->_links, $this->testable->links); + } + + /** @test */ + public function amr_is_accessible() + { + $this->assertEquals($this->properties->amr, $this->testable->getAmr()); + $this->assertEquals($this->properties->amr, $this->testable->amr); + } + + + + /** @test */ + public function created_at_is_accessible() + { + $ts = Carbon::parse($this->properties->createdAt)->timestamp; + $this->assertInstanceOf(\Carbon\Carbon::class, $this->testable->createdAt); + $this->assertEquals($ts, $this->testable->getCreatedAt()->timestamp); + $this->assertEquals($ts, $this->testable->createdAt->timestamp); + } + + /** @test */ + public function expires_at_is_accessible() + { + $ts = Carbon::parse($this->properties->expiresAt)->timestamp; + $this->assertInstanceOf(\Carbon\Carbon::class, $this->testable->expiresAt); + $this->assertEquals($ts, $this->testable->getExpiresAt()->timestamp); + $this->assertEquals($ts, $this->testable->expiresAt->timestamp); + } + + /** @test */ + public function id_is_accessible() + { + $this->assertEquals($this->properties->id, $this->testable->getId()); + $this->assertEquals($this->properties->id, $this->testable->id); + } + + /** @test */ + public function idp_is_accessible() + { + $this->assertInstanceOf(\Okta\Sessions\SessionIdentityProvider::class, $this->testable->getIdp()); + $this->assertInstanceOf(\Okta\Sessions\SessionIdentityProvider::class, $this->testable->idp); + } + + /** @test */ + public function last_factor_verification_is_accessible() + { + $ts = Carbon::parse($this->properties->lastFactorVerification)->timestamp; + $this->assertInstanceOf(\Carbon\Carbon::class, $this->testable->lastFactorVerification); + $this->assertEquals($ts, $this->testable->getLastFactorVerification()->timestamp); + $this->assertEquals($ts, $this->testable->lastFactorVerification->timestamp); + } + + /** @test */ + public function last_password_verification_is_accessible() + { + $ts = Carbon::parse($this->properties->lastPasswordVerification)->timestamp; + $this->assertInstanceOf(\Carbon\Carbon::class, $this->testable->lastPasswordVerification); + $this->assertEquals($ts, $this->testable->getLastPasswordVerification()->timestamp); + $this->assertEquals($ts, $this->testable->lastPasswordVerification->timestamp); + } + + /** @test */ + public function login_is_accessible() + { + $this->assertEquals($this->properties->login, $this->testable->getLogin()); + $this->assertEquals($this->properties->login, $this->testable->login); + } + + /** @test */ + public function status_is_accessible() + { + $this->assertEquals($this->properties->status, $this->testable->getStatus()); + $this->assertEquals($this->properties->status, $this->testable->status); + } + + /** @test */ + public function user_id_is_accessible() + { + $this->assertEquals($this->properties->userId, $this->testable->getUserId()); + $this->assertEquals($this->properties->userId, $this->testable->userId); + } + + /** @test */ + public function refresh_makes_request_to_correct_location() + { + $httpClient = $this->createNewHttpClient([ + "getBody" => '{"id": "abc123"}' + ]); + $session = (new Session())->get('abc123'); + $session->refresh(); + + $request = $httpClient->getRequests(); + + $this->assertEquals('POST', $request[1]->getMethod()); + $this->assertEquals( + "/api/v1/sessions/abc123/lifecycle/refresh", + $request[1]->getUri()->getPath() + ); + + } + + + + + + + +} diff --git a/tests/Unit/UserFactors/CallFactorProfileTest.php b/tests/Unit/UserFactors/CallFactorProfileTest.php new file mode 100644 index 0000000000..d5dafd5b0a --- /dev/null +++ b/tests/Unit/UserFactors/CallFactorProfileTest.php @@ -0,0 +1,62 @@ +assertEquals($this->properties->phoneNumber, $this->testable->getPhoneNumber()); + $this->assertEquals($this->properties->phoneNumber, $this->testable->phoneNumber); + } + + /** @test */ + public function phone_number_is_settable() + { + $this->testable->setPhoneNumber('5555551212'); + static::assertEquals('5555551212', $this->testable->getPhoneNumber()); + + $this->testable->phoneNumber = '5551112222'; + static::assertEquals('5551112222', $this->testable->getPhoneNumber()); + } + + /** @test */ + public function extension_is_gettable() + { + $this->assertEquals($this->properties->phoneExtension, $this->testable->getPhoneExtension()); + $this->assertEquals($this->properties->phoneExtension, $this->testable->phoneExtension); + } + + /** @test */ + public function extension_is_settable() + { + $this->testable->setPhoneExtension('123'); + static::assertEquals('123', $this->testable->getPhoneExtension()); + + $this->testable->phoneExtension = '789'; + static::assertEquals('789', $this->testable->getPhoneExtension()); + } + + +} diff --git a/tests/Unit/UserFactors/CallFactorTest.php b/tests/Unit/UserFactors/CallFactorTest.php new file mode 100644 index 0000000000..7d81ba43ae --- /dev/null +++ b/tests/Unit/UserFactors/CallFactorTest.php @@ -0,0 +1,46 @@ +testable->getProfile(); + + $this->assertInstanceOf(\Okta\UserFactors\CallFactorProfile::class, $profile); + + } + + /** @test */ + public function a_profile_can_be_set_on_the_factor() + { + /** @var \Okta\UserFactors\SecurityQuestionFactorProfile $profile */ + $profile = $this->testable->getProfile(); + $profile->setAnswer = 'Test'; + + $factor = $this->testable->setProfile($profile); + $this->assertInstanceOf(\Okta\UserFactors\CallFactor::class, $factor); + } + + +} diff --git a/tests/Unit/UserFactors/EmailFactorProfileTest.php b/tests/Unit/UserFactors/EmailFactorProfileTest.php new file mode 100644 index 0000000000..3c41b85bd5 --- /dev/null +++ b/tests/Unit/UserFactors/EmailFactorProfileTest.php @@ -0,0 +1,41 @@ +assertEquals($this->properties->email, $this->testable->getEmail()); + $this->assertEquals($this->properties->email, $this->testable->email); + } + + /** @test */ + public function email_is_settable() + { + $this->testable->setEmail('test@mailinator.com'); + static::assertEquals('test@mailinator.com', $this->testable->getEmail()); + + $this->testable->email = 'test2@mailinator.com'; + static::assertEquals('test2@mailinator.com', $this->testable->getEmail()); + } + +} diff --git a/tests/Unit/UserFactors/EmailFactorTest.php b/tests/Unit/UserFactors/EmailFactorTest.php new file mode 100644 index 0000000000..8ddcbb25ec --- /dev/null +++ b/tests/Unit/UserFactors/EmailFactorTest.php @@ -0,0 +1,46 @@ +testable->getProfile(); + + $this->assertInstanceOf(\Okta\UserFactors\EmailFactorProfile::class, $profile); + + } + + /** @test */ + public function a_profile_can_be_set_on_the_factor() + { + /** @var \Okta\UserFactors\SecurityQuestionFactorProfile $profile */ + $profile = $this->testable->getProfile(); + $profile->setAnswer = 'Test'; + + $factor = $this->testable->setProfile($profile); + $this->assertInstanceOf(\Okta\UserFactors\EmailFactor::class, $factor); + } + + +} diff --git a/tests/Unit/UserFactors/FactorTest.php b/tests/Unit/UserFactors/FactorTest.php new file mode 100644 index 0000000000..d65497ba13 --- /dev/null +++ b/tests/Unit/UserFactors/FactorTest.php @@ -0,0 +1,81 @@ +assertEquals($this->properties->id, $this->testable->getId()); + $this->assertEquals($this->properties->id, $this->testable->id); + } + + /** @test */ + public function links_is_accessible() + { + $this->assertEquals($this->properties->_links, $this->testable->getLinks()); + $this->assertEquals($this->properties->_links, $this->testable->links); + } + + /** @test */ + public function device_is_accessible() + { + $this->assertEquals($this->properties->device, $this->testable->getDevice()); + $this->assertEquals($this->properties->device, $this->testable->device); + } + + /** @test */ + public function device_is_settable() + { + $this->testable->setDevice('test1'); + static::assertEquals('test1', $this->testable->getDevice()); + + $this->testable->device = 'test2'; + static::assertEquals('test2', $this->testable->getDevice()); + } + + /** @test */ + public function status_is_accessible() + { + $this->assertEquals($this->properties->status, $this->testable->getStatus()); + $this->assertEquals($this->properties->status, $this->testable->status); + } + + /** @test */ + public function user_id_is_accessible() + { + $this->assertEquals($this->properties->userId, $this->testable->getUserId()); + $this->assertEquals($this->properties->userId, $this->testable->userId); + } + + /** @test */ + public function user_id_is_settable() + { + $this->testable->setUserId('123'); + static::assertEquals('123', $this->testable->getUserId()); + + $this->testable->userId = '456'; + static::assertEquals('456', $this->testable->getUserId()); + } + +} diff --git a/tests/Unit/UserFactors/HardwareFactorProfileTest.php b/tests/Unit/UserFactors/HardwareFactorProfileTest.php new file mode 100644 index 0000000000..8f0cda7526 --- /dev/null +++ b/tests/Unit/UserFactors/HardwareFactorProfileTest.php @@ -0,0 +1,41 @@ +assertEquals($this->properties->credentialId, $this->testable->getCredentialId()); + $this->assertEquals($this->properties->credentialId, $this->testable->credentialId); + } + + /** @test */ + public function credential_id_is_settable() + { + $this->testable->setCredentialId('test@mailinator.com'); + static::assertEquals('test@mailinator.com', $this->testable->getCredentialId()); + + $this->testable->credentialId = 'test2@mailinator.com'; + static::assertEquals('test2@mailinator.com', $this->testable->getCredentialId()); + } + +} diff --git a/tests/Unit/UserFactors/HardwareFactorTest.php b/tests/Unit/UserFactors/HardwareFactorTest.php new file mode 100644 index 0000000000..22c25e4250 --- /dev/null +++ b/tests/Unit/UserFactors/HardwareFactorTest.php @@ -0,0 +1,47 @@ +testable->getProfile(); + + $this->assertInstanceOf(\Okta\UserFactors\HardwareFactorProfile::class, $profile); + + } + + /** @test */ + public function a_profile_can_be_set_on_the_factor() + { + /** @var \Okta\UserFactors\SecurityQuestionFactorProfile $profile */ + $profile = $this->testable->getProfile(); + $profile->setAnswer = 'Test'; + + $factor = $this->testable->setProfile($profile); + $this->assertInstanceOf(\Okta\UserFactors\HardwareFactor::class, $factor); + } + + +} diff --git a/tests/Unit/UserFactors/PushFactorProfileTest.php b/tests/Unit/UserFactors/PushFactorProfileTest.php new file mode 100644 index 0000000000..aa079247b4 --- /dev/null +++ b/tests/Unit/UserFactors/PushFactorProfileTest.php @@ -0,0 +1,90 @@ +assertEquals($this->properties->name, $this->testable->getName()); + $this->assertEquals($this->properties->name, $this->testable->name); + } + + /** @test */ + public function name_is_settable() + { + $this->testable->setName('some name'); + static::assertEquals('some name', $this->testable->getName()); + + $this->testable->name = 'some name 2'; + static::assertEquals('some name 2', $this->testable->getName()); + } + + /** @test */ + public function version_is_gettable() + { + $this->assertEquals($this->properties->version, $this->testable->getVersion()); + $this->assertEquals($this->properties->version, $this->testable->version); + } + + /** @test */ + public function version_is_settable() + { + $this->testable->setVersion('some version'); + static::assertEquals('some version', $this->testable->getVersion()); + + $this->testable->version = 'some version 2'; + static::assertEquals('some version 2', $this->testable->getVersion()); + } + + /** @test */ + public function platform_is_gettable() + { + $this->assertEquals($this->properties->platform, $this->testable->getPlatform()); + $this->assertEquals($this->properties->platform, $this->testable->platform); + } + + /** @test */ + public function device_type_is_accessible() + { + $this->assertEquals($this->properties->deviceType, $this->testable->getDeviceType()); + $this->assertEquals($this->properties->deviceType, $this->testable->deviceType); + } + + /** @test */ + public function credential_id_is_accessible() + { + $this->assertEquals($this->properties->credentialId, $this->testable->getCredentialId()); + $this->assertEquals($this->properties->credentialId, $this->testable->credentialId); + } + + /** @test */ + public function credential_id_is_settable() + { + $this->testable->setCredentialId('test@mailinator.com'); + static::assertEquals('test@mailinator.com', $this->testable->getCredentialId()); + + $this->testable->credentialId = 'test2@mailinator.com'; + static::assertEquals('test2@mailinator.com', $this->testable->getCredentialId()); + } + + +} diff --git a/tests/Unit/UserFactors/PushFactorTest.php b/tests/Unit/UserFactors/PushFactorTest.php new file mode 100644 index 0000000000..9786e926a2 --- /dev/null +++ b/tests/Unit/UserFactors/PushFactorTest.php @@ -0,0 +1,46 @@ +testable->getProfile(); + + $this->assertInstanceOf(\Okta\UserFactors\PushFactorProfile::class, $profile); + + } + + /** @test */ + public function a_profile_can_be_set_on_the_factor() + { + /** @var \Okta\UserFactors\SecurityQuestionFactorProfile $profile */ + $profile = $this->testable->getProfile(); + $profile->setAnswer = 'Test'; + + $factor = $this->testable->setProfile($profile); + $this->assertInstanceOf(\Okta\UserFactors\PushFactor::class, $factor); + } + + +} diff --git a/tests/Unit/UserFactors/SecurityQuestionFactorProfileTest.php b/tests/Unit/UserFactors/SecurityQuestionFactorProfileTest.php new file mode 100644 index 0000000000..5c9d55d727 --- /dev/null +++ b/tests/Unit/UserFactors/SecurityQuestionFactorProfileTest.php @@ -0,0 +1,74 @@ +assertEquals($this->properties->answer, $this->testable->getAnswer()); + $this->assertEquals($this->properties->answer, $this->testable->answer); + } + + /** @test */ + public function answer_is_settable() + { + $this->testable->setAnswer('My Answer'); + static::assertEquals('My Answer', $this->testable->getAnswer()); + + $this->testable->answer = 'Custom Answer'; + static::assertEquals('Custom Answer', $this->testable->getAnswer()); + } + + /** @test */ + public function question_is_accessible() + { + $this->assertEquals($this->properties->question, $this->testable->getQuestion()); + $this->assertEquals($this->properties->question, $this->testable->question); + } + + /** @test */ + public function question_is_settable() + { + $this->testable->setQuestion('my_question'); + static::assertEquals('my_question', $this->testable->getQuestion()); + + $this->testable->question = 'custom_question'; + static::assertEquals('custom_question', $this->testable->getQuestion()); + } + + /** @test */ + public function question_text_is_accessible() + { + $this->assertEquals($this->properties->questionText, $this->testable->getQuestionText()); + $this->assertEquals($this->properties->questionText, $this->testable->questionText); + } + + /** @test */ + public function question_text_is_settable() + { + $this->testable->setQuestionText('My Answer'); + static::assertEquals('My Answer', $this->testable->getQuestionText()); + + $this->testable->questionText = "Custom Answer"; + static::assertEquals("Custom Answer", $this->testable->getQuestionText()); + } + +} diff --git a/tests/Unit/UserFactors/SecurityQuestionFactorTest.php b/tests/Unit/UserFactors/SecurityQuestionFactorTest.php new file mode 100644 index 0000000000..c5c2724d78 --- /dev/null +++ b/tests/Unit/UserFactors/SecurityQuestionFactorTest.php @@ -0,0 +1,46 @@ +testable->getProfile(); + + $this->assertInstanceOf(\Okta\UserFactors\SecurityQuestionFactorProfile::class, $profile); + + } + + /** @test */ + public function a_profile_can_be_set_on_the_factor() + { + /** @var \Okta\UserFactors\SecurityQuestionFactorProfile $profile */ + $profile = $this->testable->getProfile(); + $profile->setAnswer = 'Test'; + + $factor = $this->testable->setProfile($profile); + $this->assertInstanceOf(\Okta\UserFactors\SecurityQuestionFactor::class, $factor); + } + + +} diff --git a/tests/Unit/UserFactors/TokenFactorProfileTest.php b/tests/Unit/UserFactors/TokenFactorProfileTest.php new file mode 100644 index 0000000000..2ff217f126 --- /dev/null +++ b/tests/Unit/UserFactors/TokenFactorProfileTest.php @@ -0,0 +1,40 @@ +assertEquals($this->properties->credentialId, $this->testable->getCredentialId()); + $this->assertEquals($this->properties->credentialId, $this->testable->credentialId); + } + + /** @test */ + public function credential_id_is_settable() + { + $this->testable->setCredentialId('test@mailinator.com'); + static::assertEquals('test@mailinator.com', $this->testable->getCredentialId()); + + $this->testable->credentialId = 'test2@mailinator.com'; + static::assertEquals('test2@mailinator.com', $this->testable->getCredentialId()); + } + +} diff --git a/tests/Unit/UserFactors/TokenFactorTest.php b/tests/Unit/UserFactors/TokenFactorTest.php new file mode 100644 index 0000000000..b45578ba0d --- /dev/null +++ b/tests/Unit/UserFactors/TokenFactorTest.php @@ -0,0 +1,46 @@ +testable->getProfile(); + + $this->assertInstanceOf(\Okta\UserFactors\TokenFactorProfile::class, $profile); + + } + + /** @test */ + public function a_profile_can_be_set_on_the_factor() + { + /** @var \Okta\UserFactors\SecurityQuestionFactorProfile $profile */ + $profile = $this->testable->getProfile(); + $profile->setAnswer = 'Test'; + + $factor = $this->testable->setProfile($profile); + $this->assertInstanceOf(\Okta\UserFactors\TokenFactor::class, $factor); + } + + +} diff --git a/tests/Unit/UserFactors/TotpFactorProfileTest.php b/tests/Unit/UserFactors/TotpFactorProfileTest.php new file mode 100644 index 0000000000..75901e3269 --- /dev/null +++ b/tests/Unit/UserFactors/TotpFactorProfileTest.php @@ -0,0 +1,40 @@ +assertEquals($this->properties->credentialId, $this->testable->getCredentialId()); + $this->assertEquals($this->properties->credentialId, $this->testable->credentialId); + } + + /** @test */ + public function credential_id_is_settable() + { + $this->testable->setCredentialId('test@mailinator.com'); + static::assertEquals('test@mailinator.com', $this->testable->getCredentialId()); + + $this->testable->credentialId = 'test2@mailinator.com'; + static::assertEquals('test2@mailinator.com', $this->testable->getCredentialId()); + } + +} diff --git a/tests/Unit/UserFactors/TotpFactorTest.php b/tests/Unit/UserFactors/TotpFactorTest.php new file mode 100644 index 0000000000..665ff32cde --- /dev/null +++ b/tests/Unit/UserFactors/TotpFactorTest.php @@ -0,0 +1,46 @@ +testable->getProfile(); + + $this->assertInstanceOf(\Okta\UserFactors\TotpFactorProfile::class, $profile); + + } + + /** @test */ + public function a_profile_can_be_set_on_the_factor() + { + /** @var \Okta\UserFactors\SecurityQuestionFactorProfile $profile */ + $profile = $this->testable->getProfile(); + $profile->setAnswer = 'Test'; + + $factor = $this->testable->setProfile($profile); + $this->assertInstanceOf(\Okta\UserFactors\TotpFactor::class, $factor); + } + + +} diff --git a/tests/Unit/UserFactors/WebFactorProfileTest.php b/tests/Unit/UserFactors/WebFactorProfileTest.php new file mode 100644 index 0000000000..03f2a0830e --- /dev/null +++ b/tests/Unit/UserFactors/WebFactorProfileTest.php @@ -0,0 +1,40 @@ +assertEquals($this->properties->credentialId, $this->testable->getCredentialId()); + $this->assertEquals($this->properties->credentialId, $this->testable->credentialId); + } + + /** @test */ + public function credential_id_is_settable() + { + $this->testable->setCredentialId('test@mailinator.com'); + static::assertEquals('test@mailinator.com', $this->testable->getCredentialId()); + + $this->testable->credentialId = 'test2@mailinator.com'; + static::assertEquals('test2@mailinator.com', $this->testable->getCredentialId()); + } + +} diff --git a/tests/Unit/UserFactors/WebFactorTest.php b/tests/Unit/UserFactors/WebFactorTest.php new file mode 100644 index 0000000000..744583ba50 --- /dev/null +++ b/tests/Unit/UserFactors/WebFactorTest.php @@ -0,0 +1,46 @@ +testable->getProfile(); + + $this->assertInstanceOf(\Okta\UserFactors\WebFactorProfile::class, $profile); + + } + + /** @test */ + public function a_profile_can_be_set_on_the_factor() + { + /** @var \Okta\UserFactors\SecurityQuestionFactorProfile $profile */ + $profile = $this->testable->getProfile(); + $profile->setAnswer = 'Test'; + + $factor = $this->testable->setProfile($profile); + $this->assertInstanceOf(\Okta\UserFactors\WebFactor::class, $factor); + } + + +} diff --git a/tests/Unit/Users/UserTest.php b/tests/Unit/Users/UserTest.php index 7f7728b824..4546c76cd9 100644 --- a/tests/Unit/Users/UserTest.php +++ b/tests/Unit/Users/UserTest.php @@ -20,18 +20,9 @@ use Okta\Users\User; use PHPUnit\Framework\TestCase; -class UserTest extends TestCase +class UserTest extends BaseUnitTestCase { - protected static $properties; - /** @var User */ - protected static $testable; - - public static function setUpBeforeClass() - { - $clientBuilder = (new ClientBuilder())->build(); - - static::$properties = json_decode( - '{ + protected $model = '{ "id": "00ub0oNGTSWTBKOLGLNR", "status": "ACTIVE", "transitioningToStatus": "ACTIVE", @@ -104,156 +95,143 @@ public static function setUpBeforeClass() "withValue": 30 } } -}' - ); - - $class = new \stdClass(); - foreach(static::$properties as $prop=>$value) - { - $class->{$prop} = $value; - } - self::$testable = new User(null, $class); - - } +}'; + protected $modelType = \Okta\Users\User::class; /** @test */ public function can_get_id_property() { - $this->assertEquals(static::$properties->id, static::$testable->getId()); - $this->assertEquals(static::$properties->id, static::$testable->id); + $this->assertEquals($this->properties->id, $this->testable->getId()); + $this->assertEquals($this->properties->id, $this->testable->id); } /** @test */ public function status_is_accessible() { - $this->assertEquals(static::$properties->status, static::$testable->getStatus()); - $this->assertEquals(static::$properties->status, static::$testable->status); + $this->assertEquals($this->properties->status, $this->testable->getStatus()); + $this->assertEquals($this->properties->status, $this->testable->status); } /** @test */ public function created_is_accessible() { - $ts = Carbon::parse(static::$properties->created)->timestamp; - $this->assertInstanceOf(\Carbon\Carbon::class, static::$testable->created); - $this->assertEquals($ts, static::$testable->getCreated()->timestamp); - $this->assertEquals($ts, static::$testable->created->timestamp); + $ts = Carbon::parse($this->properties->created)->timestamp; + $this->assertInstanceOf(\Carbon\Carbon::class, $this->testable->created); + $this->assertEquals($ts, $this->testable->getCreated()->timestamp); + $this->assertEquals($ts, $this->testable->created->timestamp); } /** @test */ public function activated_is_accessible() { - $ts = Carbon::parse(static::$properties->activated)->timestamp; - $this->assertInstanceOf(\Carbon\Carbon::class, static::$testable->activated); - $this->assertEquals($ts, static::$testable->getActivated()->timestamp); - $this->assertEquals($ts, static::$testable->activated->timestamp); + $ts = Carbon::parse($this->properties->activated)->timestamp; + $this->assertInstanceOf(\Carbon\Carbon::class, $this->testable->activated); + $this->assertEquals($ts, $this->testable->getActivated()->timestamp); + $this->assertEquals($ts, $this->testable->activated->timestamp); } /** @test */ public function status_changed_is_accessible() { - $ts = Carbon::parse(static::$properties->statusChanged)->timestamp; - $this->assertInstanceOf(\Carbon\Carbon::class, static::$testable->statusChanged); - $this->assertEquals($ts, static::$testable->getStatusChanged()->timestamp); - $this->assertEquals($ts, static::$testable->statusChanged->timestamp); + $ts = Carbon::parse($this->properties->statusChanged)->timestamp; + $this->assertInstanceOf(\Carbon\Carbon::class, $this->testable->statusChanged); + $this->assertEquals($ts, $this->testable->getStatusChanged()->timestamp); + $this->assertEquals($ts, $this->testable->statusChanged->timestamp); } /** @test */ public function last_login_is_accessible() { - $ts = Carbon::parse(static::$properties->lastLogin)->timestamp; - $this->assertInstanceOf(\Carbon\Carbon::class, static::$testable->lastLogin); - $this->assertEquals($ts, static::$testable->getLastLogin()->timestamp); - $this->assertEquals($ts, static::$testable->lastLogin->timestamp); + $ts = Carbon::parse($this->properties->lastLogin)->timestamp; + $this->assertInstanceOf(\Carbon\Carbon::class, $this->testable->lastLogin); + $this->assertEquals($ts, $this->testable->getLastLogin()->timestamp); + $this->assertEquals($ts, $this->testable->lastLogin->timestamp); } /** @test */ public function last_updated_is_accessible() { - $ts = Carbon::parse(static::$properties->lastUpdated)->timestamp; - $this->assertInstanceOf(\Carbon\Carbon::class, static::$testable->lastUpdated); - $this->assertEquals($ts, static::$testable->getLastUpdated()->timestamp); - $this->assertEquals($ts, static::$testable->lastUpdated->timestamp); + $ts = Carbon::parse($this->properties->lastUpdated)->timestamp; + $this->assertInstanceOf(\Carbon\Carbon::class, $this->testable->lastUpdated); + $this->assertEquals($ts, $this->testable->getLastUpdated()->timestamp); + $this->assertEquals($ts, $this->testable->lastUpdated->timestamp); } /** @test */ public function password_changed_is_accessible() { - $ts = Carbon::parse(static::$properties->passwordChanged)->timestamp; - $this->assertInstanceOf(\Carbon\Carbon::class, static::$testable->passwordChanged); - $this->assertEquals($ts, static::$testable->getPasswordChanged()->timestamp); - $this->assertEquals($ts, static::$testable->passwordChanged->timestamp); + $ts = Carbon::parse($this->properties->passwordChanged)->timestamp; + $this->assertInstanceOf(\Carbon\Carbon::class, $this->testable->passwordChanged); + $this->assertEquals($ts, $this->testable->getPasswordChanged()->timestamp); + $this->assertEquals($ts, $this->testable->passwordChanged->timestamp); } /** @test */ public function profile_is_accessible() { - $this->assertInstanceOf(\Okta\Users\UserProfile::class, static::$testable->getProfile()); - $this->assertInstanceOf(\Okta\Users\UserProfile::class, static::$testable->profile); + $this->assertInstanceOf(\Okta\Users\UserProfile::class, $this->testable->getProfile()); + $this->assertInstanceOf(\Okta\Users\UserProfile::class, $this->testable->profile); } /** @test */ public function credentials_is_accessible() { - $this->assertInstanceOf(\Okta\Users\UserCredentials::class, static::$testable->getCredentials()); - $this->assertInstanceOf(\Okta\Users\UserCredentials::class, static::$testable->credentials); + $this->assertInstanceOf(\Okta\Users\UserCredentials::class, $this->testable->getCredentials()); + $this->assertInstanceOf(\Okta\Users\UserCredentials::class, $this->testable->credentials); } /** @test */ public function transitioning_to_status_is_accessible() { - $this->assertEquals(static::$properties->transitioningToStatus, static::$testable->getTransitioningToStatus()); - $this->assertEquals(static::$properties->transitioningToStatus, static::$testable->transitioningToStatus); + $this->assertEquals($this->properties->transitioningToStatus, $this->testable->getTransitioningToStatus()); + $this->assertEquals($this->properties->transitioningToStatus, $this->testable->transitioningToStatus); } /** @test */ public function links_is_accessible() { - $this->assertEquals(static::$properties->_links, static::$testable->getLinks()); - $this->assertEquals(static::$properties->_links, static::$testable->links); + $this->assertEquals($this->properties->_links, $this->testable->getLinks()); + $this->assertEquals($this->properties->_links, $this->testable->links); } /** @test */ public function embedded_is_accessible() { - $this->assertEquals(static::$properties->_embedded, static::$testable->getEmbedded()); - $this->assertEquals(static::$properties->_embedded, static::$testable->embedded); + $this->assertEquals($this->properties->_embedded, $this->testable->getEmbedded()); + $this->assertEquals($this->properties->_embedded, $this->testable->embedded); } /** @test */ public function credentials_is_settable() { - $credentials = static::$testable->getCredentials(); + $credentials = $this->testable->getCredentials(); $credentials->testProp = 'Hello'; - static::$testable->setCredentials($credentials); - static::assertInstanceOf(\Okta\Users\UserCredentials::class, static::$testable->getCredentials()); - static::assertEquals('Hello', static::$testable->getCredentials()->testProp); + $this->testable->setCredentials($credentials); + static::assertInstanceOf(\Okta\Users\UserCredentials::class, $this->testable->getCredentials()); + static::assertEquals('Hello', $this->testable->getCredentials()->testProp); - static::$testable->credentials = $credentials; - static::assertInstanceOf(\Okta\Users\UserCredentials::class, static::$testable->credentials); - static::assertEquals('Hello', static::$testable->credentials->testProp); + $this->testable->credentials = $credentials; + static::assertInstanceOf(\Okta\Users\UserCredentials::class, $this->testable->credentials); + static::assertEquals('Hello', $this->testable->credentials->testProp); } - - - /** @test */ public function profile_is_settable() { - $profile = static::$testable->getProfile(); + $profile = $this->testable->getProfile(); $profile->firstName = 'Test'; - static::$testable->setProfile($profile); - static::assertInstanceOf(\Okta\Users\UserProfile::class, static::$testable->getProfile()); - static::assertEquals('Test', static::$testable->getProfile()->getFirstName()); + $this->testable->setProfile($profile); + static::assertInstanceOf(\Okta\Users\UserProfile::class, $this->testable->getProfile()); + static::assertEquals('Test', $this->testable->getProfile()->getFirstName()); - static::$testable->profile = $profile; - static::assertInstanceOf(\Okta\Users\UserProfile::class, static::$testable->profile); - static::assertEquals('Test', static::$testable->profile->firstName); + $this->testable->profile = $profile; + static::assertInstanceOf(\Okta\Users\UserProfile::class, $this->testable->profile); + static::assertEquals('Test', $this->testable->profile->firstName); } - /** @test */ public function get_app_links_requests_correct_location() { @@ -403,7 +381,6 @@ public function change_recovery_question_requests_correct_location() ); } - /** @test */ public function get_groups_makes_request_to_correct_location() { @@ -431,7 +408,7 @@ public function activate_makes_request_to_correct_location() $user = $this->createNewUser(); $user->activate(); - $user->activate(false); + $userResponse = $user->activate(false); $request = $httpClient->getRequests(); @@ -477,6 +454,25 @@ public function deactivate_makes_request_to_correct_location() ); + } + + /** @test */ + public function end_user_session_makes_request_to_correct_location() + { + $httpClient = $this->createNewHttpClient(); + $user = $this->createNewUser(); + + $user->endAllSessions(); + + $request = $httpClient->getRequests(); + + $this->assertEquals('DELETE', $request[0]->getMethod()); + $this->assertEquals( + "/api/v1/users/{$user->getId()}/sessions", + $request[0]->getUri()->getPath() + ); + + } /** @test */ @@ -782,47 +778,107 @@ public function expire_password_makes_request_to_correct_location() } + /** @test */ + public function adding_factor_makes_request_to_correct_location() + { + $httpClient = $this->createNewHttpClient([ + "getBody" => '{"id": "abc123", "factorType": "sms"}' + ]); + $user = $this->createNewUser(); + + $factor = new\Okta\UserFactors\Factor; + $factor->setUserId($user->getId()); + + $user->addFactor($factor); + + $request = $httpClient->getRequests(); + $this->assertEquals('POST', $request[0]->getMethod()); + + $this->assertEquals( + "/api/v1/users/{$user->getId()}/factors", + $request[0]->getUri()->getPath() + ); + + $this->assertEquals( + (string)$factor, + $request[0]->getBody()->getContents() + ); + } + + /** @test */ + public function get_supported_factors_makes_request_to_correct_location() + { + $httpClient = $this->createNewHttpClient([ + 'getBody' => '[{"factorType":"question"}, {"factorType": "token:software:totp"}]' + ]); + $user = $this->createNewUser(); + + $supportedFactors = $user->getSupportedFactors(); + + $request = $httpClient->getRequests(); + $this->assertEquals('GET', $request[0]->getMethod()); + + $this->assertEquals( + "/api/v1/users/{$user->getId()}/factors/catalog", + $request[0]->getUri()->getPath() + ); + + $this->assertCount(2, $supportedFactors); + + $this->assertInstanceOf( + \Okta\UserFactors\Collection::class, + $supportedFactors + ); + + $this->assertInstanceOf( + \Okta\UserFactors\SecurityQuestionFactor::class, + $supportedFactors->first() + ); + + $this->assertInstanceOf( + \Okta\UserFactors\TotpFactor::class, + $supportedFactors[1] + ); + + } + - /** - * @return User - */ - private function createNewUser(): User + /** @test */ + public function getting_factors_makes_request_to_correct_endpoint() { - $class = new \stdClass(); - foreach (static::$properties as $prop => $value) { - $class->{$prop} = $value; - } - return new User(NULL, $class); + $httpClient = $this->createNewHttpClient([ + 'getBody' => '[{"id":"ufs2bysphxKODSZKWVCT","factorType":"question"}]' + ]); + $user = $this->createNewUser(); + + $factors = $user->getFactors(); + + $request = $httpClient->getRequests(); + $this->assertEquals('GET', $request[0]->getMethod()); + + $this->assertEquals( + "/api/v1/users/{$user->getId()}/factors", + $request[0]->getUri()->getPath() + ); + $this->assertInstanceOf( + \Okta\UserFactors\Collection::class, + $factors + ); } - /** - * @param array $returns - * - * @return \Http\Mock\Client - */ - private function createNewHttpClient($returns = []): \Http\Mock\Client + /** @test */ + public function can_get_supported_security_questions() { - $defaults = [ - 'getStatusCode' => 200, - 'getBody' => '{}' - ]; + $httpClient = $this->createNewHttpClient([ + 'getBody' => $this->getModel('UserFactors/supportedSecurityQuestions.json') + ]); + $user = $this->createNewUser(); - $mockReturns = array_replace_recursive($defaults, $returns); + $securityQuestions = $user->getSupportedSecurityQuestions(); - $response = $this->createMock('Psr\Http\Message\ResponseInterface'); - foreach($mockReturns as $method=>$return) { - $response->method($method)->willReturn($return); - } - $httpClient = new \Http\Mock\Client; - $httpClient->addResponse($response); + $this->assertInstanceOf(\Okta\UserFactors\SecurityQuestionsCollection::class, $securityQuestions); - (new \Okta\ClientBuilder()) - ->setOrganizationUrl('https://dev.okta.com') - ->setToken('abc123') - ->setHttpClient($httpClient) - ->build(); - return $httpClient; } diff --git a/tests/Unit/Utilities/EnumTest.php b/tests/Unit/Utilities/EnumTest.php new file mode 100644 index 0000000000..afac086550 --- /dev/null +++ b/tests/Unit/Utilities/EnumTest.php @@ -0,0 +1,247 @@ +assertEquals(DaysOfWeek::MONDAY, $monday->getValue()); + } + + /** + * @test + * @expectedException \BadMethodCallException + */ + public function invalid_values_will_throw_exception() + { + DaysOfWeek::BAD(); + } + + /** @test */ + public function can_get_key_from_enum() + { + $monday = new DaysOfWeek(DaysOfWeek::MONDAY); + $this->assertEquals('MONDAY', $monday->getKey()); + } + + /** @test */ + public function will_render_as_a_string() + { + $monday = new DaysOfWeek(DaysOfWeek::MONDAY); + $this->assertEquals('Monday', $monday); + } + + /** @test */ + public function all_keys_can_be_returned() + { + $keys = DaysOfWeek::keys(); + + $this->assertCount(7, $keys); + $this->assertEquals([ + 'SUNDAY','MONDAY','TUESDAY','WEDNESDAY','THURSDAY','FRIDAY','SATURDAY' + ], $keys); + } + + /** @test */ + public function all_values_can_be_returned() + { + $values = DaysOfWeek::values(); + + $this->assertCount(7, $values); + $this->assertEquals([ + 'SUNDAY' => new DaysOfWeek(DaysOfWeek::SUNDAY), + 'MONDAY' => new DaysOfWeek(DaysOfWeek::MONDAY), + 'TUESDAY' => new DaysOfWeek(DaysOfWeek::TUESDAY), + 'WEDNESDAY' => new DaysOfWeek(DaysOfWeek::WEDNESDAY), + 'THURSDAY' => new DaysOfWeek(DaysOfWeek::THURSDAY), + 'FRIDAY' => new DaysOfWeek(DaysOfWeek::FRIDAY), + 'SATURDAY' => new DaysOfWeek(DaysOfWeek::SATURDAY) + ], $values); + } + + /** @test */ + public function can_be_converted_to_array() + { + $array = DaysOfWeek::toArray(); + + $this->assertCount(7, $array); + $this->assertEquals([ + 'SUNDAY' => new DaysOfWeek(DaysOfWeek::SUNDAY), + 'MONDAY' => new DaysOfWeek(DaysOfWeek::MONDAY), + 'TUESDAY' => new DaysOfWeek(DaysOfWeek::TUESDAY), + 'WEDNESDAY' => new DaysOfWeek(DaysOfWeek::WEDNESDAY), + 'THURSDAY' => new DaysOfWeek(DaysOfWeek::THURSDAY), + 'FRIDAY' => new DaysOfWeek(DaysOfWeek::FRIDAY), + 'SATURDAY' => new DaysOfWeek(DaysOfWeek::SATURDAY) + ], $array); + } + + /** @test */ + public function can_check_if_value_is_valid_enum() + { + $valid = 'Monday'; + $invalid = 'Invalid'; + + $this->assertTrue(DaysOfWeek::isValid($valid)); + $this->assertFalse(DaysOfWeek::isValid($invalid)); + } + + /** @test */ + public function can_check_if_key_is_valid_on_enum() + { + $valid = 'MONDAY'; + $invalid = 'INVALID'; + $invalid2 = 'Monday'; + + $this->assertTrue(DaysOfWeek::isValidKey($valid)); + $this->assertFalse(DaysOfWeek::isValidKey($invalid)); + $this->assertFalse(DaysOfWeek::isValidKey($invalid2)); + } + + /** @test */ + public function can_search_for_key_based_on_value() + { + $this->assertEquals( + (new DaysOfWeek(DaysOfWeek::MONDAY))->getKey(), + DaysOfWeek::search('Monday') + ); + } + + /** @test */ + public function can_call_enum_method() + { + $monday = DaysOfWeek::MONDAY(); + + $this->assertTrue($monday->isStartOfWeek()); + } + + /** + * @test + * @expectedException \BadMethodCallException + */ + public function will_throw_exception_if_method_does_not_exist_for_enum() + { + $tuesday = DaysOfWeek::TUESDAY(); + + $this->assertTrue($tuesday->isStartOfWeek()); + } + + /** @test */ + public function able_to_handle_wildcard_methods_for_enums() + { + $sunday = DaysOfWeek::SUNDAY(); + $monday = DaysOfWeek::MONDAY(); + + $this->assertFalse($sunday->isWorkDay()); + $this->assertTrue($monday->isWorkDay()); + } + + /** @test */ + public function can_handle_multiple_word_enums() + { + $enum = MultiWordEnum::MULTI_WORD_ENUM(); + + $this->assertEquals('Multiple Word Enum', $enum->getValue()); + + $this->assertTrue($enum->testFunction()); + + $this->assertFalse($enum->alwaysFalseExceptSomethingElse()); + $this->assertTrue((MultiWordEnum::SOMETHING_ELSE())->alwaysFalseExceptSomethingElse()); + + } + + + /** + * @test + * @expectedException \UnexpectedValueException + */ + public function throws_exception_if_created_without_valid_value() + { + new MultiWordEnum('FOO_BAR'); + } + + + + + + +} + +class MultiWordEnum extends \Okta\Utilities\Enum +{ + const MULTI_WORD_ENUM = 'Multiple Word Enum'; + const SOMETHING_ELSE = 'Foo Bar'; + + public function multiWordEnumTestFunction() + { + return true; + } + + public function alwaysFalseExceptSomethingElse() + { + if($this->getKey() == 'SOMETHING_ELSE') + { + return true; + } + return false; + } +} + +/** + * Class DaysOfWeek + * + * @method static DaysOfWeek SUNDAY() + * @method static DaysOfWeek MONDAY() + * @method static DaysOfWeek TUESDAY() + * @method static DaysOfWeek WEDNESDAY() + * @method static DaysOfWeek THURSDAY() + * @method static DaysOfWeek FRIDAY() + * @method static DaysOfWeek SATURDAY() + * @method bool isStartOfWeek() + * @method bool isWorkDay() + * + */ +class DaysOfWeek extends \Okta\Utilities\Enum +{ + const SUNDAY = "Sunday"; + const MONDAY = "Monday"; + const TUESDAY = "Tuesday"; + const WEDNESDAY = "Wednesday"; + const THURSDAY = "Thursday"; + const FRIDAY = "Friday"; + const SATURDAY = "Saturday"; + + public function mondayIsStartOfWeek() + { + return true; + } + + public function isWorkDay() + { + switch($this->getKey()) { + case 'SUNDAY': + case 'SATURDAY': + return false; + default: + return true; + } + } +} diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 6ebbf554f4..ced9b07728 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,3 +1,4 @@