Fixes build as commit 9fffdb4 added a check/call to GetCurrentUser and JS test was failing for unexpected HTTP call to GetCurrentUser

This commit is contained in:
Warren Buckley
2019-06-24 10:39:47 +01:00
parent aed6ef28e6
commit 41b8294ce3
3 changed files with 66 additions and 3 deletions

View File

@@ -0,0 +1,59 @@
/**
* @ngdoc service
* @name umbraco.mocks.authMocks
* @description
* Mocks data retrival for the auth service
**/
function authMocks($httpBackend, mocksUtils) {
/** internal method to mock the current user to be returned */
function getCurrentUser() {
if (!mocksUtils.checkAuth()) {
return [401, null, null];
}
var currentUser = {
"email":"warren@umbraco.com",
"locale":"en-US",
"emailHash":"da0673cb2c930ee247e8ba5ebe4355bf",
"userGroups":[
"admin",
"sensitiveData"
],
"remainingAuthSeconds":1178.2645038,
"startContentIds":[-1],
"startMediaIds":[-1],
"avatars":[
"https://www.gravatar.com/avatar/da0673cb2c930ee247e8ba5ebe4355bf?d=404&s=30",
"https://www.gravatar.com/avatar/da0673cb2c930ee247e8ba5ebe4355bf?d=404&s=60",
"https://www.gravatar.com/avatar/da0673cb2c930ee247e8ba5ebe4355bf?d=404&s=90",
"https://www.gravatar.com/avatar/da0673cb2c930ee247e8ba5ebe4355bf?d=404&s=150",
"https://www.gravatar.com/avatar/da0673cb2c930ee247e8ba5ebe4355bf?d=404&s=300"
],
"allowedSections":[
"content",
"forms",
"media",
"member",
"packages",
"settings",
"users"
],
"id":-1,
"name":"Warren Buckley"
};
return [200, currentUser, null];
}
return {
register: function () {
$httpBackend
.whenGET(mocksUtils.urlRegex('/umbraco/UmbracoApi/Authentication/GetCurrentUser'))
.respond(getCurrentUser);
}
};
}
angular.module('umbraco.mocks').factory('authMocks', ['$httpBackend', 'mocksUtils', authMocks]);

View File

@@ -1,10 +1,10 @@
var umbracoAppDev = angular.module('umbraco.httpbackend', ['umbraco', 'ngMockE2E', 'umbraco.mocks']);
function initBackEnd($httpBackend, contentMocks, mediaMocks, treeMocks, userMocks, contentTypeMocks, sectionMocks, entityMocks, dataTypeMocks, dashboardMocks, macroMocks, utilMocks, localizationMocks, prevaluesMocks) {
function initBackEnd($httpBackend, contentMocks, mediaMocks, treeMocks, userMocks, contentTypeMocks, sectionMocks, entityMocks, dataTypeMocks, dashboardMocks, macroMocks, utilMocks, localizationMocks, prevaluesMocks, authMocks) {
console.log("httpBackend inited");
//Register mocked http responses
contentMocks.register();
mediaMocks.register();
@@ -19,6 +19,7 @@ function initBackEnd($httpBackend, contentMocks, mediaMocks, treeMocks, userMock
localizationMocks.register();
prevaluesMocks.register();
entityMocks.register();
authMocks.register();
$httpBackend.whenGET(/^..\/config\//).passThrough();
$httpBackend.whenGET(/^views\//).passThrough();

View File

@@ -33,7 +33,10 @@
}
beforeEach(inject(function ($controller, $rootScope, $q, $location) {
beforeEach(inject(function ($controller, $rootScope, $q, $location, authMocks) {
authMocks.register();
contentTypeResource = {
getAllowedTypes: function () {
var def = $q.defer();