From 032be8e293661a6c24c07d5fefa399ab9996b1e6 Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Thu, 18 Jun 2020 15:51:40 -0400 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=A4=96=20add=20mock=20auth=20met?= =?UTF-8?q?hods?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addons/api/addon/generated/models/auth-method.js | 5 +++++ ui/core/mirage/config.js | 8 ++++++++ ui/core/mirage/factories/auth-method.js | 3 +++ .../mirage/generated/factories/auth-method.js | 16 ++++++++++++++++ ui/core/mirage/scenarios/default.js | 11 +++++++++-- ui/core/mirage/serializers/auth-method.js | 5 +++++ 6 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 ui/core/mirage/factories/auth-method.js create mode 100644 ui/core/mirage/generated/factories/auth-method.js create mode 100644 ui/core/mirage/serializers/auth-method.js diff --git a/addons/api/addon/generated/models/auth-method.js b/addons/api/addon/generated/models/auth-method.js index 624663584..995e65efd 100644 --- a/addons/api/addon/generated/models/auth-method.js +++ b/addons/api/addon/generated/models/auth-method.js @@ -34,4 +34,9 @@ export default class GeneratedAuthMethodModel extends BaseModel { }) updated_time; + @attr('boolean', { + description: 'Whether the resource is disabled', + }) + disabled; + } diff --git a/ui/core/mirage/config.js b/ui/core/mirage/config.js index 0f714aba6..b81ef488f 100644 --- a/ui/core/mirage/config.js +++ b/ui/core/mirage/config.js @@ -32,6 +32,14 @@ export default function() { this.patch('/orgs/:org_id/projects/:id'); this.del('/orgs/:org_id/projects/:id'); + // Auth & IAM resources + + this.get('/orgs/:org_id/auth-methods'); + this.post('/orgs/:org_id/auth-methods'); + this.get('/orgs/:org_id/auth-methods/:id'); + this.patch('/orgs/:org_id/auth-methods/:id'); + this.del('/orgs/:org_id/auth-methods/:id'); + // Other resources // host-catalog diff --git a/ui/core/mirage/factories/auth-method.js b/ui/core/mirage/factories/auth-method.js new file mode 100644 index 000000000..aa15a1103 --- /dev/null +++ b/ui/core/mirage/factories/auth-method.js @@ -0,0 +1,3 @@ +import factory from '../generated/factories/auth-method'; + +export default factory.extend(); diff --git a/ui/core/mirage/generated/factories/auth-method.js b/ui/core/mirage/generated/factories/auth-method.js new file mode 100644 index 000000000..d76245946 --- /dev/null +++ b/ui/core/mirage/generated/factories/auth-method.js @@ -0,0 +1,16 @@ +import { Factory } from 'ember-cli-mirage'; +import { random, date } from 'faker'; + +/** + * GeneratedAuthMethodModelFactory + */ +export default Factory.extend({ + + type: 'password', + name: () => random.words(), + description: () => random.words(), + created_time: () => date.recent(), + updated_time: () => date.recent(), + disabled: () => random.boolean(), + +}); diff --git a/ui/core/mirage/scenarios/default.js b/ui/core/mirage/scenarios/default.js index 9255fc853..b8accbf8b 100644 --- a/ui/core/mirage/scenarios/default.js +++ b/ui/core/mirage/scenarios/default.js @@ -3,10 +3,17 @@ export default function(server) { // Scope resources server.createList('org', 3); - server.createList('project', 3); + server.createList('project', 6); + + // Auth + + // Auth methods exist both at the global scope and the org scope. + // For simplicity we don't scope our mock auth methods and just return the + // same items for request at all scopes. + server.createList('auth-method', 3); // Other resources - server.createList('host-catalog', 3); + server.createList('host-catalog', 6); } diff --git a/ui/core/mirage/serializers/auth-method.js b/ui/core/mirage/serializers/auth-method.js new file mode 100644 index 000000000..cabe9ee7b --- /dev/null +++ b/ui/core/mirage/serializers/auth-method.js @@ -0,0 +1,5 @@ +import ApplicationSerializer from './application'; + +export default ApplicationSerializer.extend({ + modelName: 'auth-method' +});