'use strict';var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.ASSUME_ES5=false;$jscomp.ASSUME_NO_NATIVE_MAP=false;$jscomp.ASSUME_NO_NATIVE_SET=false;$jscomp.defineProperty=$jscomp.ASSUME_ES5||typeof Object.defineProperties=="function"?Object.defineProperty:function(target,property,descriptor){descriptor=descriptor;if(target==Array.prototype||target==Object.prototype)return;target[property]=descriptor.value};
$jscomp.getGlobal=function(maybeGlobal){return typeof window!="undefined"&&window===maybeGlobal?maybeGlobal:typeof global!="undefined"&&global!=null?global:maybeGlobal};$jscomp.global=$jscomp.getGlobal(this);
$jscomp.polyfill=function(target,polyfill,fromLang,toLang){if(!polyfill)return;var obj=$jscomp.global;var split=target.split(".");for(var i=0;i<split.length-1;i++){var key=split[i];if(!(key in obj))obj[key]={};obj=obj[key]}var property=split[split.length-1];var orig=obj[property];var impl=polyfill(orig);if(impl==orig||impl==null)return;$jscomp.defineProperty(obj,property,{configurable:true,writable:true,value:impl})};
$jscomp.polyfill("Array.prototype.copyWithin",function(orig){if(orig)return orig;var polyfill=function(target,start,opt_end){var len=this.length;target=Number(target);start=Number(start);opt_end=Number(opt_end!=null?opt_end:len);if(target<start){opt_end=Math.min(opt_end,len);while(start<opt_end)if(start in this)this[target++]=this[start++];else{delete this[target++];start++}}else{opt_end=Math.min(opt_end,len+start-target);target+=opt_end-start;while(opt_end>start)if(--opt_end in this)this[--target]=
this[opt_end];else delete this[target]}return this};return polyfill},"es6","es3");$jscomp.SYMBOL_PREFIX="jscomp_symbol_";$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};if(!$jscomp.global["Symbol"])$jscomp.global["Symbol"]=$jscomp.Symbol};$jscomp.Symbol=function(){var counter=0;function Symbol(opt_description){return $jscomp.SYMBOL_PREFIX+(opt_description||"")+counter++}return Symbol}();
$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var symbolIterator=$jscomp.global["Symbol"].iterator;if(!symbolIterator)symbolIterator=$jscomp.global["Symbol"].iterator=$jscomp.global["Symbol"]("iterator");if(typeof Array.prototype[symbolIterator]!="function")$jscomp.defineProperty(Array.prototype,symbolIterator,{configurable:true,writable:true,value:function(){return $jscomp.arrayIterator(this)}});$jscomp.initSymbolIterator=function(){}};
$jscomp.arrayIterator=function(array){var index=0;return $jscomp.iteratorPrototype(function(){if(index<array.length)return{done:false,value:array[index++]};else return{done:true}})};$jscomp.iteratorPrototype=function(next){$jscomp.initSymbolIterator();var iterator={next:next};iterator[$jscomp.global["Symbol"].iterator]=function(){return this};return iterator};
$jscomp.iteratorFromArray=function(array,transform){$jscomp.initSymbolIterator();if(array instanceof String)array=array+"";var i=0;var iter={next:function(){if(i<array.length){var index=i++;return{value:transform(index,array[index]),done:false}}iter.next=function(){return{done:true,value:void 0}};return iter.next()}};iter[Symbol.iterator]=function(){return iter};return iter};
$jscomp.polyfill("Array.prototype.entries",function(orig){if(orig)return orig;var polyfill=function(){return $jscomp.iteratorFromArray(this,function(i,v){return[i,v]})};return polyfill},"es6","es3");
$jscomp.polyfill("Array.prototype.fill",function(orig){if(orig)return orig;var polyfill=function(value,opt_start,opt_end){var length=this.length||0;if(opt_start<0)opt_start=Math.max(0,length+opt_start);if(opt_end==null||opt_end>length)opt_end=length;opt_end=Number(opt_end);if(opt_end<0)opt_end=Math.max(0,length+opt_end);for(var i=Number(opt_start||0);i<opt_end;i++)this[i]=value;return this};return polyfill},"es6","es3");
$jscomp.findInternal=function(array,callback,thisArg){if(array instanceof String)array=String(array);var len=array.length;for(var i=0;i<len;i++){var value=array[i];if(callback.call(thisArg,value,i,array))return{i:i,v:value}}return{i:-1,v:void 0}};$jscomp.polyfill("Array.prototype.find",function(orig){if(orig)return orig;var polyfill=function(callback,opt_thisArg){return $jscomp.findInternal(this,callback,opt_thisArg).v};return polyfill},"es6","es3");
$jscomp.polyfill("Array.prototype.findIndex",function(orig){if(orig)return orig;var polyfill=function(callback,opt_thisArg){return $jscomp.findInternal(this,callback,opt_thisArg).i};return polyfill},"es6","es3");
$jscomp.polyfill("Array.from",function(orig){if(orig)return orig;var polyfill=function(arrayLike,opt_mapFn,opt_thisArg){$jscomp.initSymbolIterator();opt_mapFn=opt_mapFn!=null?opt_mapFn:function(x){return x};var result=[];var iteratorFunction=arrayLike[Symbol.iterator];if(typeof iteratorFunction=="function"){arrayLike=iteratorFunction.call(arrayLike);var next;while(!(next=arrayLike.next()).done)result.push(opt_mapFn.call(opt_thisArg,next.value))}else{var len=arrayLike.length;for(var i=0;i<len;i++)result.push(opt_mapFn.call(opt_thisArg,
arrayLike[i]))}return result};return polyfill},"es6","es3");$jscomp.polyfill("Object.is",function(orig){if(orig)return orig;var polyfill=function(left,right){if(left===right)return left!==0||1/left===1/right;else return left!==left&&right!==right};return polyfill},"es6","es3");
$jscomp.polyfill("Array.prototype.includes",function(orig){if(orig)return orig;var includes=function(searchElement,opt_fromIndex){var array=this;if(array instanceof String)array=String(array);var len=array.length;for(var i=opt_fromIndex||0;i<len;i++)if(array[i]==searchElement||Object.is(array[i],searchElement))return true;return false};return includes},"es7","es3");
$jscomp.polyfill("Array.prototype.keys",function(orig){if(orig)return orig;var polyfill=function(){return $jscomp.iteratorFromArray(this,function(i){return i})};return polyfill},"es6","es3");$jscomp.polyfill("Array.of",function(orig){if(orig)return orig;var polyfill=function(var_args){return Array.from(arguments)};return polyfill},"es6","es3");
$jscomp.polyfill("Array.prototype.values",function(orig){if(orig)return orig;var polyfill=function(){return $jscomp.iteratorFromArray(this,function(k,v){return v})};return polyfill},"es8","es3");$jscomp.makeIterator=function(iterable){$jscomp.initSymbolIterator();var iteratorFunction=iterable[Symbol.iterator];return iteratorFunction?iteratorFunction.call(iterable):$jscomp.arrayIterator(iterable)};$jscomp.FORCE_POLYFILL_PROMISE=false;
$jscomp.polyfill("Promise",function(NativePromise){if(NativePromise&&!$jscomp.FORCE_POLYFILL_PROMISE)return NativePromise;function AsyncExecutor(){this.batch_=null}AsyncExecutor.prototype.asyncExecute=function(f){if(this.batch_==null){this.batch_=[];this.asyncExecuteBatch_()}this.batch_.push(f);return this};AsyncExecutor.prototype.asyncExecuteBatch_=function(){var self=this;this.asyncExecuteFunction(function(){self.executeBatch_()})};var nativeSetTimeout=$jscomp.global["setTimeout"];AsyncExecutor.prototype.asyncExecuteFunction=
function(f){nativeSetTimeout(f,0)};AsyncExecutor.prototype.executeBatch_=function(){while(this.batch_&&this.batch_.length){var executingBatch=this.batch_;this.batch_=[];for(var i=0;i<executingBatch.length;++i){var f=executingBatch[i];delete executingBatch[i];try{f()}catch(error){this.asyncThrow_(error)}}}this.batch_=null};AsyncExecutor.prototype.asyncThrow_=function(exception){this.asyncExecuteFunction(function(){throw exception;})};var PromiseState={PENDING:0,FULFILLED:1,REJECTED:2};var PolyfillPromise=
function(executor){this.state_=PromiseState.PENDING;this.result_=undefined;this.onSettledCallbacks_=[];var resolveAndReject=this.createResolveAndReject_();try{executor(resolveAndReject.resolve,resolveAndReject.reject)}catch(e){resolveAndReject.reject(e)}};PolyfillPromise.prototype.createResolveAndReject_=function(){var thisPromise=this;var alreadyCalled=false;function firstCallWins(method){return function(x){if(!alreadyCalled){alreadyCalled=true;method.call(thisPromise,x)}}}return{resolve:firstCallWins(this.resolveTo_),
reject:firstCallWins(this.reject_)}};PolyfillPromise.prototype.resolveTo_=function(value){if(value===this)this.reject_(new TypeError("A Promise cannot resolve to itself"));else if(value instanceof PolyfillPromise)this.settleSameAsPromise_(value);else if(isObject(value))this.resolveToNonPromiseObj_(value);else this.fulfill_(value)};PolyfillPromise.prototype.resolveToNonPromiseObj_=function(obj){var thenMethod=undefined;try{thenMethod=obj.then}catch(error){this.reject_(error);return}if(typeof thenMethod==
"function")this.settleSameAsThenable_(thenMethod,obj);else this.fulfill_(obj)};function isObject(value){switch(typeof value){case "object":return value!=null;case "function":return true;default:return false}}PolyfillPromise.prototype.reject_=function(reason){this.settle_(PromiseState.REJECTED,reason)};PolyfillPromise.prototype.fulfill_=function(value){this.settle_(PromiseState.FULFILLED,value)};PolyfillPromise.prototype.settle_=function(settledState,valueOrReason){if(this.state_!=PromiseState.PENDING)throw new Error("Cannot settle("+
settledState+", "+valueOrReason|"): Promise already settled in state"+this.state_);this.state_=settledState;this.result_=valueOrReason;this.executeOnSettledCallbacks_()};PolyfillPromise.prototype.executeOnSettledCallbacks_=function(){if(this.onSettledCallbacks_!=null){var callbacks=this.onSettledCallbacks_;for(var i=0;i<callbacks.length;++i){callbacks[i].call();callbacks[i]=null}this.onSettledCallbacks_=null}};var asyncExecutor=new AsyncExecutor;PolyfillPromise.prototype.settleSameAsPromise_=function(promise){var methods=
this.createResolveAndReject_();promise.callWhenSettled_(methods.resolve,methods.reject)};PolyfillPromise.prototype.settleSameAsThenable_=function(thenMethod,thenable){var methods=this.createResolveAndReject_();try{thenMethod.call(thenable,methods.resolve,methods.reject)}catch(error){methods.reject(error)}};PolyfillPromise.prototype.then=function(onFulfilled,onRejected){var resolveChild;var rejectChild;var childPromise=new PolyfillPromise(function(resolve,reject){resolveChild=resolve;rejectChild=reject});
function createCallback(paramF,defaultF){if(typeof paramF=="function")return function(x){try{resolveChild(paramF(x))}catch(error){rejectChild(error)}};else return defaultF}this.callWhenSettled_(createCallback(onFulfilled,resolveChild),createCallback(onRejected,rejectChild));return childPromise};PolyfillPromise.prototype.catch=function(onRejected){return this.then(undefined,onRejected)};PolyfillPromise.prototype.callWhenSettled_=function(onFulfilled,onRejected){var thisPromise=this;function callback(){switch(thisPromise.state_){case PromiseState.FULFILLED:onFulfilled(thisPromise.result_);
break;case PromiseState.REJECTED:onRejected(thisPromise.result_);break;default:throw new Error("Unexpected state: "+thisPromise.state_);}}if(this.onSettledCallbacks_==null)asyncExecutor.asyncExecute(callback);else this.onSettledCallbacks_.push(function(){asyncExecutor.asyncExecute(callback)})};function resolvingPromise(opt_value){if(opt_value instanceof PolyfillPromise)return opt_value;else return new PolyfillPromise(function(resolve,reject){resolve(opt_value)})}PolyfillPromise["resolve"]=resolvingPromise;
PolyfillPromise["reject"]=function(opt_reason){return new PolyfillPromise(function(resolve,reject){reject(opt_reason)})};PolyfillPromise["race"]=function(thenablesOrValues){return new PolyfillPromise(function(resolve,reject){var iterator=$jscomp.makeIterator(thenablesOrValues);for(var iterRec=iterator.next();!iterRec.done;iterRec=iterator.next())resolvingPromise(iterRec.value).callWhenSettled_(resolve,reject)})};PolyfillPromise["all"]=function(thenablesOrValues){var iterator=$jscomp.makeIterator(thenablesOrValues);
var iterRec=iterator.next();if(iterRec.done)return resolvingPromise([]);else return new PolyfillPromise(function(resolveAll,rejectAll){var resultsArray=[];var unresolvedCount=0;function onFulfilled(i){return function(ithResult){resultsArray[i]=ithResult;unresolvedCount--;if(unresolvedCount==0)resolveAll(resultsArray)}}do{resultsArray.push(undefined);unresolvedCount++;resolvingPromise(iterRec.value).callWhenSettled_(onFulfilled(resultsArray.length-1),rejectAll);iterRec=iterator.next()}while(!iterRec.done)})};
return PolyfillPromise},"es6","es3");$jscomp.executeAsyncGenerator=function(generator){function passValueToGenerator(value){return generator.next(value)}function passErrorToGenerator(error){return generator.throw(error)}return new Promise(function(resolve,reject){function handleGeneratorRecord(genRec){if(genRec.done)resolve(genRec.value);else Promise.resolve(genRec.value).then(passValueToGenerator,passErrorToGenerator).then(handleGeneratorRecord,reject)}handleGeneratorRecord(generator.next())})};
$jscomp.owns=function(obj,prop){return Object.prototype.hasOwnProperty.call(obj,prop)};
$jscomp.polyfill("WeakMap",function(NativeWeakMap){function isConformant(){if(!NativeWeakMap||!Object.seal)return false;try{var x=Object.seal({});var y=Object.seal({});var map=new NativeWeakMap([[x,2],[y,3]]);if(map.get(x)!=2||map.get(y)!=3)return false;map.delete(x);map.set(y,4);return!map.has(x)&&map.get(y)==4}catch(err){return false}}if(isConformant())return NativeWeakMap;var prop="$jscomp_hidden_"+Math.random().toString().substring(2);function insert(target){if(!$jscomp.owns(target,prop)){var obj=
{};$jscomp.defineProperty(target,prop,{value:obj})}}function patch(name){var prev=Object[name];if(prev)Object[name]=function(target){insert(target);return prev(target)}}patch("freeze");patch("preventExtensions");patch("seal");var index=0;var PolyfillWeakMap=function(opt_iterable){this.id_=(index+=Math.random()+1).toString();if(opt_iterable){$jscomp.initSymbol();$jscomp.initSymbolIterator();var iter=$jscomp.makeIterator(opt_iterable);var entry;while(!(entry=iter.next()).done){var item=entry.value;
this.set(item[0],item[1])}}};PolyfillWeakMap.prototype.set=function(key,value){insert(key);if(!$jscomp.owns(key,prop))throw new Error("WeakMap key fail: "+key);key[prop][this.id_]=value;return this};PolyfillWeakMap.prototype.get=function(key){return $jscomp.owns(key,prop)?key[prop][this.id_]:undefined};PolyfillWeakMap.prototype.has=function(key){return $jscomp.owns(key,prop)&&$jscomp.owns(key[prop],this.id_)};PolyfillWeakMap.prototype.delete=function(key){if(!$jscomp.owns(key,prop)||!$jscomp.owns(key[prop],
this.id_))return false;return delete key[prop][this.id_]};return PolyfillWeakMap},"es6","es3");$jscomp.MapEntry=function(){this.previous;this.next;this.head;this.key;this.value};
$jscomp.polyfill("Map",function(NativeMap){var isConformant=!$jscomp.ASSUME_NO_NATIVE_MAP&&function(){if(!NativeMap||!NativeMap.prototype.entries||typeof Object.seal!="function")return false;try{NativeMap=NativeMap;var key=Object.seal({x:4});var map=new NativeMap($jscomp.makeIterator([[key,"s"]]));if(map.get(key)!="s"||map.size!=1||map.get({x:4})||map.set({x:4},"t")!=map||map.size!=2)return false;var iter=map.entries();var item=iter.next();if(item.done||item.value[0]!=key||item.value[1]!="s")return false;
item=iter.next();if(item.done||item.value[0].x!=4||item.value[1]!="t"||!iter.next().done)return false;return true}catch(err){return false}}();if(isConformant)return NativeMap;$jscomp.initSymbol();$jscomp.initSymbolIterator();var idMap=new WeakMap;var PolyfillMap=function(opt_iterable){this.data_={};this.head_=createHead();this.size=0;if(opt_iterable){var iter=$jscomp.makeIterator(opt_iterable);var entry;while(!(entry=iter.next()).done){var item=entry.value;this.set(item[0],item[1])}}};PolyfillMap.prototype.set=
function(key,value){var r=maybeGetEntry(this,key);if(!r.list)r.list=this.data_[r.id]=[];if(!r.entry){r.entry={next:this.head_,previous:this.head_.previous,head:this.head_,key:key,value:value};r.list.push(r.entry);this.head_.previous.next=r.entry;this.head_.previous=r.entry;this.size++}else r.entry.value=value;return this};PolyfillMap.prototype.delete=function(key){var r=maybeGetEntry(this,key);if(r.entry&&r.list){r.list.splice(r.index,1);if(!r.list.length)delete this.data_[r.id];r.entry.previous.next=
r.entry.next;r.entry.next.previous=r.entry.previous;r.entry.head=null;this.size--;return true}return false};PolyfillMap.prototype.clear=function(){this.data_={};this.head_=this.head_.previous=createHead();this.size=0};PolyfillMap.prototype.has=function(key){return!!maybeGetEntry(this,key).entry};PolyfillMap.prototype.get=function(key){var entry=maybeGetEntry(this,key).entry;return entry&&entry.value};PolyfillMap.prototype.entries=function(){return makeIterator(this,function(entry){return[entry.key,
entry.value]})};PolyfillMap.prototype.keys=function(){return makeIterator(this,function(entry){return entry.key})};PolyfillMap.prototype.values=function(){return makeIterator(this,function(entry){return entry.value})};PolyfillMap.prototype.forEach=function(callback,opt_thisArg){var iter=this.entries();var item;while(!(item=iter.next()).done){var entry=item.value;callback.call(opt_thisArg,entry[1],entry[0],this)}};PolyfillMap.prototype[Symbol.iterator]=PolyfillMap.prototype.entries;var maybeGetEntry=
function(map,key){var id=getId(key);var list=map.data_[id];if(list&&$jscomp.owns(map.data_,id))for(var index=0;index<list.length;index++){var entry=list[index];if(key!==key&&entry.key!==entry.key||key===entry.key)return{id:id,list:list,index:index,entry:entry}}return{id:id,list:list,index:-1,entry:undefined}};var makeIterator=function(map,func){var entry=map.head_;return $jscomp.iteratorPrototype(function(){if(entry){while(entry.head!=map.head_)entry=entry.previous;while(entry.next!=entry.head){entry=
entry.next;return{done:false,value:func(entry)}}entry=null}return{done:true,value:void 0}})};var createHead=function(){var head={};head.previous=head.next=head.head=head;return head};var mapIndex=0;var getId=function(obj){var type=obj&&typeof obj;if(type=="object"||type=="function"){obj=obj;if(!idMap.has(obj)){var id=""+ ++mapIndex;idMap.set(obj,id);return id}return idMap.get(obj)}return"p_"+obj};return PolyfillMap},"es6","es3");
$jscomp.polyfill("Math.acosh",function(orig){if(orig)return orig;var polyfill=function(x){x=Number(x);return Math.log(x+Math.sqrt(x*x-1))};return polyfill},"es6","es3");$jscomp.polyfill("Math.asinh",function(orig){if(orig)return orig;var polyfill=function(x){x=Number(x);if(x===0)return x;var y=Math.log(Math.abs(x)+Math.sqrt(x*x+1));return x<0?-y:y};return polyfill},"es6","es3");
$jscomp.polyfill("Math.log1p",function(orig){if(orig)return orig;var polyfill=function(x){x=Number(x);if(x<.25&&x>-.25){var y=x;var d=1;var z=x;var zPrev=0;var s=1;while(zPrev!=z){y*=x;s*=-1;z=(zPrev=z)+s*y/++d}return z}return Math.log(1+x)};return polyfill},"es6","es3");$jscomp.polyfill("Math.atanh",function(orig){if(orig)return orig;var log1p=Math.log1p;var polyfill=function(x){x=Number(x);return(log1p(x)-log1p(-x))/2};return polyfill},"es6","es3");
$jscomp.polyfill("Math.cbrt",function(orig){if(orig)return orig;var polyfill=function(x){if(x===0)return x;x=Number(x);var y=Math.pow(Math.abs(x),1/3);return x<0?-y:y};return polyfill},"es6","es3");
$jscomp.polyfill("Math.clz32",function(orig){if(orig)return orig;var polyfill=function(x){x=Number(x)>>>0;if(x===0)return 32;var result=0;if((x&4294901760)===0){x<<=16;result+=16}if((x&4278190080)===0){x<<=8;result+=8}if((x&4026531840)===0){x<<=4;result+=4}if((x&3221225472)===0){x<<=2;result+=2}if((x&2147483648)===0)result++;return result};return polyfill},"es6","es3");
$jscomp.polyfill("Math.cosh",function(orig){if(orig)return orig;var exp=Math.exp;var polyfill=function(x){x=Number(x);return(exp(x)+exp(-x))/2};return polyfill},"es6","es3");$jscomp.polyfill("Math.expm1",function(orig){if(orig)return orig;var polyfill=function(x){x=Number(x);if(x<.25&&x>-.25){var y=x;var d=1;var z=x;var zPrev=0;while(zPrev!=z){y*=x/++d;z=(zPrev=z)+y}return z}return Math.exp(x)-1};return polyfill},"es6","es3");
$jscomp.polyfill("Math.hypot",function(orig){if(orig)return orig;var polyfill=function(x,y,var_args){x=Number(x);y=Number(y);var i,z,sum;var max=Math.max(Math.abs(x),Math.abs(y));for(i=2;i<arguments.length;i++)max=Math.max(max,Math.abs(arguments[i]));if(max>1E100||max<1E-100){x=x/max;y=y/max;sum=x*x+y*y;for(i=2;i<arguments.length;i++){z=Number(arguments[i])/max;sum+=z*z}return Math.sqrt(sum)*max}else{sum=x*x+y*y;for(i=2;i<arguments.length;i++){z=Number(arguments[i]);sum+=z*z}return Math.sqrt(sum)}};
return polyfill},"es6","es3");$jscomp.polyfill("Math.imul",function(orig){if(orig)return orig;var polyfill=function(a,b){a=Number(a);b=Number(b);var ah=a>>>16&65535;var al=a&65535;var bh=b>>>16&65535;var bl=b&65535;var lh=ah*bl+al*bh<<16>>>0;return al*bl+lh|0};return polyfill},"es6","es3");$jscomp.polyfill("Math.log10",function(orig){if(orig)return orig;var polyfill=function(x){return Math.log(x)/Math.LN10};return polyfill},"es6","es3");
$jscomp.polyfill("Math.log2",function(orig){if(orig)return orig;var polyfill=function(x){return Math.log(x)/Math.LN2};return polyfill},"es6","es3");$jscomp.polyfill("Math.sign",function(orig){if(orig)return orig;var polyfill=function(x){x=Number(x);return x===0||isNaN(x)?x:x>0?1:-1};return polyfill},"es6","es3");$jscomp.polyfill("Math.sinh",function(orig){if(orig)return orig;var exp=Math.exp;var polyfill=function(x){x=Number(x);if(x===0)return x;return(exp(x)-exp(-x))/2};return polyfill},"es6","es3");
$jscomp.polyfill("Math.tanh",function(orig){if(orig)return orig;var polyfill=function(x){x=Number(x);if(x===0)return x;var y=Math.exp(-2*Math.abs(x));var z=(1-y)/(1+y);return x<0?-z:z};return polyfill},"es6","es3");$jscomp.polyfill("Math.trunc",function(orig){if(orig)return orig;var polyfill=function(x){x=Number(x);if(isNaN(x)||x===Infinity||x===-Infinity||x===0)return x;var y=Math.floor(Math.abs(x));return x<0?-y:y};return polyfill},"es6","es3");
$jscomp.polyfill("Number.EPSILON",function(orig){return Math.pow(2,-52)},"es6","es3");$jscomp.polyfill("Number.MAX_SAFE_INTEGER",function(){return 9007199254740991},"es6","es3");$jscomp.polyfill("Number.MIN_SAFE_INTEGER",function(){return-9007199254740991},"es6","es3");$jscomp.polyfill("Number.isFinite",function(orig){if(orig)return orig;var polyfill=function(x){if(typeof x!=="number")return false;return!isNaN(x)&&x!==Infinity&&x!==-Infinity};return polyfill},"es6","es3");
$jscomp.polyfill("Number.isInteger",function(orig){if(orig)return orig;var polyfill=function(x){if(!Number.isFinite(x))return false;return x===Math.floor(x)};return polyfill},"es6","es3");$jscomp.polyfill("Number.isNaN",function(orig){if(orig)return orig;var polyfill=function(x){return typeof x==="number"&&isNaN(x)};return polyfill},"es6","es3");
$jscomp.polyfill("Number.isSafeInteger",function(orig){if(orig)return orig;var polyfill=function(x){return Number.isInteger(x)&&Math.abs(x)<=Number.MAX_SAFE_INTEGER};return polyfill},"es6","es3");$jscomp.polyfill("Object.assign",function(orig){if(orig)return orig;var polyfill=function(target,var_args){for(var i=1;i<arguments.length;i++){var source=arguments[i];if(!source)continue;for(var key in source)if($jscomp.owns(source,key))target[key]=source[key]}return target};return polyfill},"es6","es3");
$jscomp.polyfill("Object.entries",function(orig){if(orig)return orig;var entries=function(obj){var result=[];for(var key in obj)if($jscomp.owns(obj,key))result.push([key,obj[key]]);return result};return entries},"es8","es3");$jscomp.polyfill("Object.getOwnPropertySymbols",function(orig){if(orig)return orig;return function(){return[]}},"es6","es5");
$jscomp.polyfill("Reflect.ownKeys",function(orig){if(orig)return orig;var symbolPrefix="jscomp_symbol_";function isSymbol(key){return key.substring(0,symbolPrefix.length)==symbolPrefix}var polyfill=function(target){var keys=[];var names=Object.getOwnPropertyNames(target);var symbols=Object.getOwnPropertySymbols(target);for(var i=0;i<names.length;i++)(isSymbol(names[i])?symbols:keys).push(names[i]);return keys.concat(symbols)};return polyfill},"es6","es5");
$jscomp.polyfill("Object.getOwnPropertyDescriptors",function(orig){if(orig)return orig;var getOwnPropertyDescriptors=function(obj){var result={};var keys=Reflect.ownKeys(obj);for(var i=0;i<keys.length;i++)result[keys[i]]=Object.getOwnPropertyDescriptor(obj,keys[i]);return result};return getOwnPropertyDescriptors},"es8","es5");$jscomp.underscoreProtoCanBeSet=function(){var x={a:true};var y={};try{y.__proto__=x;return y.a}catch(e){}return false};
$jscomp.setPrototypeOf=typeof Object.setPrototypeOf=="function"?Object.setPrototypeOf:$jscomp.underscoreProtoCanBeSet()?function(target,proto){target.__proto__=proto;if(target.__proto__!==proto)throw new TypeError(target+" is not extensible");return target}:null;$jscomp.polyfill("Object.setPrototypeOf",function(orig){return orig||$jscomp.setPrototypeOf},"es6","es5");
$jscomp.polyfill("Object.values",function(orig){if(orig)return orig;var values=function(obj){var result=[];for(var key in obj)if($jscomp.owns(obj,key))result.push(obj[key]);return result};return values},"es8","es3");$jscomp.polyfill("Reflect.apply",function(orig){if(orig)return orig;var apply=Function.prototype.apply;var polyfill=function(target,thisArg,argList){return apply.call(target,thisArg,argList)};return polyfill},"es6","es3");
$jscomp.objectCreate=$jscomp.ASSUME_ES5||typeof Object.create=="function"?Object.create:function(prototype){var ctor=function(){};ctor.prototype=prototype;return new ctor};
$jscomp.construct=function(){function reflectConstructWorks(){function Base(){}function Derived(){}new Base;Reflect.construct(Base,[],Derived);return new Base instanceof Base}if(typeof Reflect!="undefined"&&Reflect.construct){if(reflectConstructWorks())return Reflect.construct;var brokenConstruct=Reflect.construct;var patchedConstruct=function(target,argList,opt_newTarget){var out=brokenConstruct(target,argList);if(opt_newTarget)Reflect.setPrototypeOf(out,opt_newTarget.prototype);return out};return patchedConstruct}function construct(target,
argList,opt_newTarget){if(opt_newTarget===undefined)opt_newTarget=target;var proto=opt_newTarget.prototype||Object.prototype;var obj=$jscomp.objectCreate(proto);var apply=Function.prototype.apply;var out=apply.call(target,obj,argList);return out||obj}return construct}();$jscomp.polyfill("Reflect.construct",function(orig){return $jscomp.construct},"es6","es3");
$jscomp.polyfill("Reflect.defineProperty",function(orig){if(orig)return orig;var polyfill=function(target,propertyKey,attributes){try{Object.defineProperty(target,propertyKey,attributes);var desc=Object.getOwnPropertyDescriptor(target,propertyKey);if(!desc)return false;return desc.configurable===(attributes.configurable||false)&&desc.enumerable===(attributes.enumerable||false)&&("value"in desc?desc.value===attributes.value&&desc.writable===(attributes.writable||false):desc.get===attributes.get&&desc.set===
attributes.set)}catch(err){return false}};return polyfill},"es6","es5");$jscomp.polyfill("Reflect.deleteProperty",function(orig){if(orig)return orig;var polyfill=function(target,propertyKey){if(!$jscomp.owns(target,propertyKey))return true;try{return delete target[propertyKey]}catch(err){return false}};return polyfill},"es6","es3");$jscomp.polyfill("Reflect.getOwnPropertyDescriptor",function(orig){return orig||Object.getOwnPropertyDescriptor},"es6","es5");
$jscomp.polyfill("Reflect.getPrototypeOf",function(orig){return orig||Object.getPrototypeOf},"es6","es5");$jscomp.findDescriptor=function(target,propertyKey){var obj=target;while(obj){var property=Reflect.getOwnPropertyDescriptor(obj,propertyKey);if(property)return property;obj=Reflect.getPrototypeOf(obj)}return undefined};
$jscomp.polyfill("Reflect.get",function(orig){if(orig)return orig;var polyfill=function(target,propertyKey,opt_receiver){if(arguments.length<=2)return target[propertyKey];var property=$jscomp.findDescriptor(target,propertyKey);if(property)return property.get?property.get.call(opt_receiver):property.value;return undefined};return polyfill},"es6","es5");
$jscomp.polyfill("Reflect.has",function(orig){if(orig)return orig;var polyfill=function(target,propertyKey){return propertyKey in target};return polyfill},"es6","es3");$jscomp.polyfill("Reflect.isExtensible",function(orig){if(orig)return orig;if($jscomp.ASSUME_ES5||typeof Object.isExtensible=="function")return Object.isExtensible;return function(){return true}},"es6","es3");
$jscomp.polyfill("Reflect.preventExtensions",function(orig){if(orig)return orig;if(!($jscomp.ASSUME_ES5||typeof Object.preventExtensions=="function"))return function(){return false};var polyfill=function(target){Object.preventExtensions(target);return!Object.isExtensible(target)};return polyfill},"es6","es3");
$jscomp.polyfill("Reflect.set",function(orig){if(orig)return orig;var polyfill=function(target,propertyKey,value,opt_receiver){var property=$jscomp.findDescriptor(target,propertyKey);if(!property){if(Reflect.isExtensible(target)){target[propertyKey]=value;return true}return false}if(property.set){property.set.call(arguments.length>3?opt_receiver:target,value);return true}else if(property.writable&&!Object.isFrozen(target)){target[propertyKey]=value;return true}return false};return polyfill},"es6",
"es5");$jscomp.polyfill("Reflect.setPrototypeOf",function(orig){if(orig)return orig;else if($jscomp.setPrototypeOf){var setPrototypeOf=$jscomp.setPrototypeOf;var polyfill=function(target,proto){try{setPrototypeOf(target,proto);return true}catch(e){return false}};return polyfill}else return null},"es6","es5");
$jscomp.polyfill("Set",function(NativeSet){var isConformant=!$jscomp.ASSUME_NO_NATIVE_SET&&function(){if(!NativeSet||!NativeSet.prototype.entries||typeof Object.seal!="function")return false;try{NativeSet=NativeSet;var value=Object.seal({x:4});var set=new NativeSet($jscomp.makeIterator([value]));if(!set.has(value)||set.size!=1||set.add(value)!=set||set.size!=1||set.add({x:4})!=set||set.size!=2)return false;var iter=set.entries();var item=iter.next();if(item.done||item.value[0]!=value||item.value[1]!=
value)return false;item=iter.next();if(item.done||item.value[0]==value||item.value[0].x!=4||item.value[1]!=item.value[0])return false;return iter.next().done}catch(err){return false}}();if(isConformant)return NativeSet;$jscomp.initSymbol();$jscomp.initSymbolIterator();var PolyfillSet=function(opt_iterable){this.map_=new Map;if(opt_iterable){var iter=$jscomp.makeIterator(opt_iterable);var entry;while(!(entry=iter.next()).done){var item=entry.value;this.add(item)}}this.size=this.map_.size};PolyfillSet.prototype.add=
function(value){this.map_.set(value,value);this.size=this.map_.size;return this};PolyfillSet.prototype.delete=function(value){var result=this.map_.delete(value);this.size=this.map_.size;return result};PolyfillSet.prototype.clear=function(){this.map_.clear();this.size=0};PolyfillSet.prototype.has=function(value){return this.map_.has(value)};PolyfillSet.prototype.entries=function(){return this.map_.entries()};PolyfillSet.prototype.values=function(){return this.map_.values()};PolyfillSet.prototype.keys=
PolyfillSet.prototype.values;PolyfillSet.prototype[Symbol.iterator]=PolyfillSet.prototype.values;PolyfillSet.prototype.forEach=function(callback,opt_thisArg){var set=this;this.map_.forEach(function(value){return callback.call(opt_thisArg,value,value,set)})};return PolyfillSet},"es6","es3");
$jscomp.checkStringArgs=function(thisArg,arg,func){if(thisArg==null)throw new TypeError("The 'this' value for String.prototype."+func+" must not be null or undefined");if(arg instanceof RegExp)throw new TypeError("First argument to String.prototype."+func+" must not be a regular expression");return thisArg+""};
$jscomp.polyfill("String.prototype.codePointAt",function(orig){if(orig)return orig;var polyfill=function(position){var string=$jscomp.checkStringArgs(this,null,"codePointAt");var size=string.length;position=Number(position)||0;if(!(position>=0&&position<size))return void 0;position=position|0;var first=string.charCodeAt(position);if(first<55296||first>56319||position+1===size)return first;var second=string.charCodeAt(position+1);if(second<56320||second>57343)return first;return(first-55296)*1024+
second+9216};return polyfill},"es6","es3");$jscomp.polyfill("String.prototype.endsWith",function(orig){if(orig)return orig;var polyfill=function(searchString,opt_position){var string=$jscomp.checkStringArgs(this,searchString,"endsWith");searchString=searchString+"";if(opt_position===void 0)opt_position=string.length;var i=Math.max(0,Math.min(opt_position|0,string.length));var j=searchString.length;while(j>0&&i>0)if(string[--i]!=searchString[--j])return false;return j<=0};return polyfill},"es6","es3");
$jscomp.polyfill("String.fromCodePoint",function(orig){if(orig)return orig;var polyfill=function(var_args){var result="";for(var i=0;i<arguments.length;i++){var code=Number(arguments[i]);if(code<0||code>1114111||code!==Math.floor(code))throw new RangeError("invalid_code_point "+code);if(code<=65535)result+=String.fromCharCode(code);else{code-=65536;result+=String.fromCharCode(code>>>10&1023|55296);result+=String.fromCharCode(code&1023|56320)}}return result};return polyfill},"es6","es3");
$jscomp.polyfill("String.prototype.includes",function(orig){if(orig)return orig;var polyfill=function(searchString,opt_position){var string=$jscomp.checkStringArgs(this,searchString,"includes");return string.indexOf(searchString,opt_position||0)!==-1};return polyfill},"es6","es3");
$jscomp.polyfill("String.prototype.repeat",function(orig){if(orig)return orig;var polyfill=function(copies){var string=$jscomp.checkStringArgs(this,null,"repeat");if(copies<0||copies>1342177279)throw new RangeError("Invalid count value");copies=copies|0;var result="";while(copies){if(copies&1)result+=string;if(copies>>>=1)string+=string}return result};return polyfill},"es6","es3");
$jscomp.stringPadding=function(padString,padLength){var padding=padString!==undefined?String(padString):" ";if(!(padLength>0)||!padding)return"";var repeats=Math.ceil(padLength/padding.length);return padding.repeat(repeats).substring(0,padLength)};
$jscomp.polyfill("String.prototype.padEnd",function(orig){if(orig)return orig;var padEnd=function(targetLength,opt_padString){var string=$jscomp.checkStringArgs(this,null,"padStart");var padLength=targetLength-string.length;return string+$jscomp.stringPadding(opt_padString,padLength)};return padEnd},"es8","es3");
$jscomp.polyfill("String.prototype.padStart",function(orig){if(orig)return orig;var padStart=function(targetLength,opt_padString){var string=$jscomp.checkStringArgs(this,null,"padStart");var padLength=targetLength-string.length;return $jscomp.stringPadding(opt_padString,padLength)+string};return padStart},"es8","es3");
$jscomp.polyfill("String.prototype.startsWith",function(orig){if(orig)return orig;var polyfill=function(searchString,opt_position){var string=$jscomp.checkStringArgs(this,searchString,"startsWith");searchString=searchString+"";var strLen=string.length;var searchLen=searchString.length;var i=Math.max(0,Math.min(opt_position|0,string.length));var j=0;while(j<searchLen&&i<strLen)if(string[i++]!=searchString[j++])return false;return j>=searchLen};return polyfill},"es6","es3");
$jscomp.arrayFromIterator=function(iterator){var i;var arr=[];while(!(i=iterator.next()).done)arr.push(i.value);return arr};$jscomp.arrayFromIterable=function(iterable){if(iterable instanceof Array)return iterable;else return $jscomp.arrayFromIterator($jscomp.makeIterator(iterable))};
$jscomp.inherits=function(childCtor,parentCtor){childCtor.prototype=$jscomp.objectCreate(parentCtor.prototype);childCtor.prototype.constructor=childCtor;if($jscomp.setPrototypeOf){var setPrototypeOf=$jscomp.setPrototypeOf;setPrototypeOf(childCtor,parentCtor)}else for(var p in parentCtor){if(p=="prototype")continue;if(Object.defineProperties){var descriptor=Object.getOwnPropertyDescriptor(parentCtor,p);if(descriptor)Object.defineProperty(childCtor,p,descriptor)}else childCtor[p]=parentCtor[p]}childCtor.superClass_=
parentCtor.prototype};
$jscomp.polyfill("WeakSet",function(NativeWeakSet){function isConformant(){if(!NativeWeakSet||!Object.seal)return false;try{var x=Object.seal({});var y=Object.seal({});var set=new NativeWeakSet([x]);if(!set.has(x)||set.has(y))return false;set.delete(x);set.add(y);return!set.has(x)&&set.has(y)}catch(err){return false}}if(isConformant())return NativeWeakSet;var PolyfillWeakSet=function(opt_iterable){this.map_=new WeakMap;if(opt_iterable){$jscomp.initSymbol();$jscomp.initSymbolIterator();var iter=$jscomp.makeIterator(opt_iterable);
var entry;while(!(entry=iter.next()).done){var item=entry.value;this.add(item)}}};PolyfillWeakSet.prototype.add=function(elem){this.map_.set(elem,true);return this};PolyfillWeakSet.prototype.has=function(elem){return this.map_.has(elem)};PolyfillWeakSet.prototype.delete=function(elem){return this.map_.delete(elem)};return PolyfillWeakSet},"es6","es3");goog.provide("grrUi.tests");goog.provide("grrUi.tests.browserTriggerEvent");goog.provide("grrUi.tests.browserTriggerKeyDown");goog.provide("grrUi.tests.stubDirective");
goog.provide("grrUi.tests.stubTranscludeDirective");goog.provide("grrUi.tests.stubUiTrait");goog.provide("grrUi.tests.testsModule");grrUi.tests.testsModule=angular.module("grrUi.tests",["ng","ui.bootstrap"]);var $animate;beforeEach(module("ngAnimateMock"));
grrUi.tests.testsModule.config(function($interpolateProvider,$qProvider,$uibModalProvider){$interpolateProvider.startSymbol("{$");$interpolateProvider.endSymbol("$}");$qProvider.errorOnUnhandledRejections(false);$uibModalProvider.options.animation=false}).run(function($injector){$animate=$injector.get("$animate")});
beforeEach(function(){module("grrUi.tests");var grrRoutingServiceMock={go:function(state,params){},href:function(state,params){return"#test/href"},uiOnParamsChanged:function(scope,paramNames,callback){},onStateChange:function(scope,callback){}};module(function($provide){$provide.factory("grrRoutingService",function(){return grrRoutingServiceMock})})});
grrUi.tests.browserTriggerEvent=function(element,eventType){if(element.injector)element=element[0];else if(element.prevObject)element=element[0];if(eventType==="change"){$(element).triggerHandler("change");if(element.type==="checkbox")$(element).triggerHandler("click")}else if(document.createEvent){var event=document.createEvent("MouseEvents");if(eventType==="mouseenter")eventType="mouseover";if(eventType==="mouseleave")eventType="mouseout";event.initMouseEvent(eventType,true,true,window,0,0,0,0,
0,false,false,false,false,0,null);element.dispatchEvent(event)}else element.fireEvent("on"+eventType);$animate.flush(true)};grrUi.tests.browserTriggerKeyDown=function(element,keyCode){var event=jQuery.Event("keypress");event.which=keyCode;element.trigger(event)};var directiveStubCounter=0;
grrUi.tests.stubDirective=function(directiveName){var moduleName="test.directives.stubs."+directiveStubCounter;directiveStubCounter+=1;angular.module(moduleName,[]).directive(directiveName,function(){return{priority:1E5+directiveStubCounter,terminal:true}});beforeEach(module(moduleName))};
grrUi.tests.stubTranscludeDirective=function(directiveName){var moduleName="test.directives.stubs."+directiveStubCounter;directiveStubCounter+=1;angular.module(moduleName,[]).directive(directiveName,function(){return{restrict:"E",scope:{},transclude:true,priority:1E5+directiveStubCounter,terminal:true,link:function($scope,$element,$attrs,controller,$transclude){function ngTranscludeCloneAttachFn(clone){if(clone.length){$element.empty();$element.append(clone)}}$transclude(ngTranscludeCloneAttachFn,
null,null)}}});beforeEach(module(moduleName))};
grrUi.tests.stubUiTrait=function(traitName){beforeEach(inject(function($injector){var $q=$injector.get("$q");var grrApiService=$injector.get("grrApiService");var deferred=$q.defer();var response={data:{value:{interface_traits:{value:{}}}}};response["data"]["value"]["interface_traits"]["value"][traitName]={value:true};deferred.resolve(response);var currentImpl=grrApiService.getCached;spyOn(grrApiService,"getCached").and.callFake(function(url,params){if(url=="users/me")return deferred.promise;else return currentImpl(url,
params)})}))};goog.loadModule(function(exports){"use strict";goog.module("grrUi.acl.requestApprovalDialogDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var0=goog.require("grrUi.acl.acl");var aclModule=$jscomp$destructuring$var0.aclModule;var $jscomp$destructuring$var1=goog.require("grrUi.tests");var browserTriggerEvent=$jscomp$destructuring$var1.browserTriggerEvent;var testsModule=$jscomp$destructuring$var1.testsModule;describe("request approval dialog",function(){var $compile;var $q;var $rootScope;
var closeSpy;var dismissSpy;var grrApiService;beforeEach(module("/static/angular-components/acl/"+"request-approval-dialog.html"));beforeEach(module("/static/angular-components/core/"+"confirmation-dialog.html"));beforeEach(module(aclModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$q=$injector.get("$q");$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");grrApiService=$injector.get("grrApiService");closeSpy=jasmine.createSpy("close");
dismissSpy=jasmine.createSpy("dismiss")}));var renderTestTemplate=function(approvalType,createUrl,createArgs,description){$rootScope.approvalType=approvalType;$rootScope.createUrl=createUrl;$rootScope.createArgs=createArgs;$rootScope.description=description;$rootScope.$close=closeSpy;$rootScope.$dismiss=dismissSpy;var template="<grr-request-approval-dialog "+'approval-type="approvalType" '+'create-request-url="createUrl" '+'create-request-args="createArgs" '+'access-error-description="description" />';
var element=$compile(template)($rootScope);$rootScope.$apply();return element};var approvals;var clientApprovalRequest;var configEntry;beforeEach(function(){clientApprovalRequest={client_id:"C:123456",approval:{}};approvals={data:{items:[{type:"ApiClientApproval",value:{reason:{type:"RDFString",value:"reason1"}}},{type:"ApiClientApproval",value:{reason:{type:"RDFString",value:"reason2"}}}]}};configEntry={data:{value:{type:"RDFString",value:"foo@bar.com, xyz@example.com"}}};var deferred=$q.defer();
deferred.resolve(configEntry);spyOn(grrApiService,"getCached").and.returnValue(deferred.promise);deferred=$q.defer();deferred.resolve(approvals);spyOn(grrApiService,"get").and.returnValue(deferred.promise)});it("shows a list of previous client reasons",function(){var element=renderTestTemplate("client");expect($("select option",element).length).toBe(3);expect($("select option:nth(0)",element).val()).toEqual("");expect($("select option:nth(1)",element).val()).toEqual("reason1");expect($("select option:nth(2)",
element).val()).toEqual("reason2")});it("doesn't show a list of CC addresses when not available",function(){configEntry["data"]["value"]["value"]=undefined;var element=renderTestTemplate("client");expect(element.text()).not.toContain("CC");expect($("input[name=cc_approval]",element).length).toBe(0)});it("shows a list of CC addresses when they're available",function(){var element=renderTestTemplate("client");expect(element.text()).toContain("CC foo@bar.com, xyz@example.com");expect($("input[name=cc_approval]",
element).length).toBe(1)});it("disables reason field when dropdown reason is selected",function(){var element=renderTestTemplate("client");$("select",element).val("reason1");browserTriggerEvent($("select",element),"change");expect($("input[name=acl_reason]",element).attr("disabled")).toBeTruthy()});it('doesn\'t show keep-alive checkbox for "hunt"approval type',function(){var element=renderTestTemplate("hunt");expect($("input[name=keepalive]",element).length).toBe(0)});it('shows keep-alive checkbox for "client" approval type',
function(){var element=renderTestTemplate("client");expect($("input[name=keepalive]",element).length).toBe(1)});it("includes approvers into request if CC-checbox is selected",function(){spyOn(grrApiService,"post").and.returnValue($q.defer().promise);var element=renderTestTemplate("client","foo/bar",clientApprovalRequest);$("input[name=acl_approver]",element).val("foo");browserTriggerEvent($("input[name=acl_approver]",element),"change");$("input[name=acl_reason]",element).val("bar");browserTriggerEvent($("input[name=acl_reason]",
element),"change");$("input[name=cc_approval]",element).prop("checked",true);browserTriggerEvent($("input[name=cc_approval]",element),"change");browserTriggerEvent($("button[name=Proceed]",element),"click");expect(grrApiService.post).toHaveBeenCalledWith("foo/bar",{client_id:"C:123456",approval:{reason:"bar",notified_users:["foo"],email_cc_addresses:["foo@bar.com","xyz@example.com"]},keep_client_alive:true})});it("includes keep_client_alive into request if checkbox is selected",function(){spyOn(grrApiService,
"post").and.returnValue($q.defer().promise);var element=renderTestTemplate("client","foo/bar",clientApprovalRequest);$("input[name=acl_approver]",element).val("foo");browserTriggerEvent($("input[name=acl_approver]",element),"change");$("input[name=acl_reason]",element).val("bar");browserTriggerEvent($("input[name=acl_reason]",element),"change");browserTriggerEvent($("input[name=cc_approval]",element).prop("checked",false),"change");browserTriggerEvent($("input[name=keepalive]",element).prop("checked",
true),"change");browserTriggerEvent($("button[name=Proceed]",element),"click");expect(grrApiService.post).toHaveBeenCalledWith("foo/bar",{client_id:"C:123456",approval:{reason:"bar",notified_users:["foo"]},keep_client_alive:true})});it("includes dropdown reason into request",function(){spyOn(grrApiService,"post").and.returnValue($q.defer().promise);var element=renderTestTemplate("client","foo/bar",clientApprovalRequest);$("input[name=acl_approver]",element).val("foo");browserTriggerEvent($("input[name=acl_approver]",
element),"change");$("input[name=acl_reason]",element).val("bar");browserTriggerEvent($("input[name=acl_reason]",element),"change");browserTriggerEvent($("input[name=cc_approval]",element).prop("checked",false),"change");$("select",element).val("reason2");browserTriggerEvent($("select",element),"change");browserTriggerEvent($("button[name=Proceed]",element),"click");expect(grrApiService.post).toHaveBeenCalledWith("foo/bar",{client_id:"C:123456",approval:{reason:"reason2",notified_users:["foo"]},keep_client_alive:true})})});
exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.artifact.artifactDescriptorServiceTest");goog.setTestOnly();var $jscomp$destructuring$var2=goog.require("grrUi.artifact.artifactDescriptorsService");var ArtifactDescriptorsService=$jscomp$destructuring$var2.ArtifactDescriptorsService;var $jscomp$destructuring$var3=goog.require("grrUi.artifact.artifact");var artifactModule=$jscomp$destructuring$var3.artifactModule;var $jscomp$destructuring$var4=goog.require("grrUi.tests");var testsModule=
$jscomp$destructuring$var4.testsModule;describe("grrArtifactDescriptorsService service",function(){var $q;var $rootScope;var grrApiServiceMock;var grrArtifactDescriptorsService;beforeEach(module(artifactModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$rootScope=$injector.get("$rootScope");$q=$injector.get("$q");grrApiServiceMock={get:function(){}};grrArtifactDescriptorsService=$injector.instantiate(ArtifactDescriptorsService,{"grrApiService":grrApiServiceMock})}));
var successResponse={data:{items:[{type:"ArtifactDescriptor",value:{artifact:{value:{name:{value:"foo"}}}}},{type:"ArtifactDescriptor",value:{artifact:{value:{name:{value:"bar"}}}}}]}};var failureResponse={data:{message:"Oh no!"}};describe("listDescriptors()",function(){it("resolves to a dictionary of descriptors on success",function(done){var deferred=$q.defer();deferred.resolve(successResponse);spyOn(grrApiServiceMock,"get").and.returnValue(deferred.promise);grrArtifactDescriptorsService.listDescriptors().then(function(descriptors){expect(Object.keys(descriptors)).toEqual(["foo",
"bar"]);done()});$rootScope.$apply()});it("resolves to an error message on error",function(done){var deferred=$q.defer();deferred.reject(failureResponse);spyOn(grrApiServiceMock,"get").and.returnValue(deferred.promise);grrArtifactDescriptorsService.listDescriptors().then(function(){},function(message){expect(message).toBe("Oh no!");done()});$rootScope.$apply()});it("does not start more than one API requests",function(){var deferred1=$q.defer();var deferred2=$q.defer();spyOn(grrApiServiceMock,"get").and.returnValues(deferred1.promise,
deferred2.promise);grrArtifactDescriptorsService.listDescriptors();grrArtifactDescriptorsService.listDescriptors();expect(grrApiServiceMock.get.calls.count()).toBe(1)})});describe("getDescriptorByName()",function(){it("resolves to a descriptor",function(done){var deferred=$q.defer();deferred.resolve(successResponse);spyOn(grrApiServiceMock,"get").and.returnValue(deferred.promise);grrArtifactDescriptorsService.getDescriptorByName("foo").then(function(descriptor){expect(descriptor).toEqual(successResponse.data.items[0]);
done()});$rootScope.$apply()});it("resolves to undefined if descriptor not found",function(done){var deferred=$q.defer();deferred.resolve(successResponse);spyOn(grrApiServiceMock,"get").and.returnValue(deferred.promise);grrArtifactDescriptorsService.getDescriptorByName("something").then(function(descriptor){expect(descriptor).toBeUndefined();done()});$rootScope.$apply()});it("resolve to an error message in case of error",function(done){var deferred=$q.defer();deferred.reject(failureResponse);spyOn(grrApiServiceMock,
"get").and.returnValue(deferred.promise);grrArtifactDescriptorsService.getDescriptorByName("something").then(function(){},function(message){expect(message).toBe("Oh no!");done()});$rootScope.$apply()})});describe("clearCache()",function(){it("forces next listDescriptors call to do an API request",function(){var deferred1=$q.defer();deferred1.resolve(successResponse);var deferred2=$q.defer();deferred2.resolve(successResponse);spyOn(grrApiServiceMock,"get").and.returnValues(deferred1.promise,deferred2.promise);
grrArtifactDescriptorsService.listDescriptors();$rootScope.$apply();grrArtifactDescriptorsService.clearCache();grrArtifactDescriptorsService.listDescriptors();$rootScope.$apply();expect(grrApiServiceMock.get.calls.count()).toBe(2)})})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.artifact.artifactNameDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var5=goog.require("grrUi.artifact.artifact");var artifactModule=$jscomp$destructuring$var5.artifactModule;var $jscomp$destructuring$var6=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var6.testsModule;describe("grr-artifact-name directive",function(){var $compile;var $q;var $rootScope;var grrArtifactDescriptorsService;beforeEach(module("/static/angular-components/artifact/artifact-name.html"));
beforeEach(module(artifactModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");$q=$injector.get("$q");grrArtifactDescriptorsService=$injector.get("grrArtifactDescriptorsService")}));var renderTestTemplate=function(value){$rootScope.value=value;var template='<grr-artifact-name value="value" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};var systemDescriptor=
{type:"ArtifactDescriptor",value:{artifact:{value:{name:{value:"foo"}}},is_custom:{value:false}}};var userDescriptor={type:"ArtifactDescriptor",value:{artifact:{value:{name:{value:"foo"}}},is_custom:{value:true}}};it("shows artifact name as a string before it's resolved",function(){var deferred=$q.defer();spyOn(grrArtifactDescriptorsService,"getDescriptorByName").and.returnValue(deferred.promise);var element=renderTestTemplate({value:"foo"});expect($("span.system",element).length).toBe(0);expect($("span.user",
element).length).toBe(0);expect($("span.icon",element).length).toBe(0);expect(element.text()).toContain("foo")});it("marks system artifacts with .system class and no icon",function(){var deferred=$q.defer();deferred.resolve(systemDescriptor);spyOn(grrArtifactDescriptorsService,"getDescriptorByName").and.returnValue(deferred.promise);var element=renderTestTemplate({value:"foo"});expect($("span.system",element).length).toBe(1);expect($("span.user",element).length).toBe(0);expect($("span.icon",element).length).toBe(0);
expect(element.text()).toContain("foo")});it("marks user artifacts with .user class and an icon",function(){var deferred=$q.defer();deferred.resolve(userDescriptor);spyOn(grrArtifactDescriptorsService,"getDescriptorByName").and.returnValue(deferred.promise);var element=renderTestTemplate({value:"foo"});expect($("span.system",element).length).toBe(0);expect($("span.user",element).length).toBe(1);expect(element.text()).toContain("foo")});it("does not mark unknown artifacts",function(){var deferred=
$q.defer();deferred.resolve(undefined);spyOn(grrArtifactDescriptorsService,"getDescriptorByName").and.returnValue(deferred.promise);var element=renderTestTemplate({value:"foo"});expect($("span.system",element).length).toBe(0);expect($("span.user",element).length).toBe(0);expect($("span.icon",element).length).toBe(0);expect(element.text()).toContain("foo")})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.artifact.artifactsListFormDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var7=goog.require("grrUi.artifact.artifact");var artifactModule=$jscomp$destructuring$var7.artifactModule;var $jscomp$destructuring$var8=goog.require("grrUi.tests");var browserTriggerEvent=$jscomp$destructuring$var8.browserTriggerEvent;var stubDirective=$jscomp$destructuring$var8.stubDirective;var testsModule=$jscomp$destructuring$var8.testsModule;
describe("artifacts list form directive",function(){var $compile;var $q;var $rootScope;var grrArtifactDescriptorsService;var descriptorDarwinWindows;var descriptorLinux;beforeEach(module("/static/angular-components/artifact/artifacts-list-form.html"));beforeEach(module(artifactModule.name));beforeEach(module(testsModule.name));stubDirective("grrSemanticValue");beforeEach(inject(function($injector){$q=$injector.get("$q");$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");grrArtifactDescriptorsService=
$injector.get("grrArtifactDescriptorsService")}));var renderTestTemplate=function(value){$rootScope.value=value;$rootScope.descriptor={default:{type:"ArtifactName",value:""}};var template='<grr-artifacts-list-form descriptor="descriptor" '+'value="value" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it('shows "Loading artifacts..." while artifacts are being loaded',function(){var deferred=$q.defer();spyOn(grrArtifactDescriptorsService,"listDescriptors").and.returnValue(deferred.promise);
var element=renderTestTemplate([]);expect(element.text()).toContain("Loading artifacts...")});describe("when descriptors listing fails",function(){beforeEach(function(){spyOn(grrArtifactDescriptorsService,"listDescriptors").and.callFake(function(){var deferred=$q.defer();deferred.reject("Oh no!");return deferred.promise})});it('hides "Loading artifacts..." message',function(){var element=renderTestTemplate([]);expect(element.text()).not.toContain("Loading artifacts...")});it("shows a failure message on artifacts fetch failure",
function(){var element=renderTestTemplate([]);expect(element.text()).toContain("Oh no!")})});describe("when descriptors listing succeeds",function(){beforeEach(function(){descriptorLinux={type:"ArtifactDescriptor",value:{artifact:{type:"Artifact",value:{name:{type:"ArtifactName",value:"FooLinux"},supported_os:[{type:"RDFString",value:"Linux"}]}}}};descriptorDarwinWindows={type:"ArtifactDescriptor",value:{artifact:{type:"Artifact",value:{name:{type:"ArtifactName",value:"BarDarwinWindows"},supported_os:[{type:"RDFString",
value:"Darwin"},{type:"RDFString",value:"Windows"}]}}}};spyOn(grrArtifactDescriptorsService,"listDescriptors").and.callFake(function(){var deferred=$q.defer();deferred.resolve({"FooLinux":descriptorLinux,"BarDarwinWindows":descriptorDarwinWindows});return deferred.promise})});it('hides "Loading artifacts..." message',function(){var element=renderTestTemplate([]);expect(element.text()).not.toContain("Loading artifacts...")});it("shows all artifacts for selection by default",function(){var element=
renderTestTemplate([]);expect(element.text()).toContain("FooLinux");expect(element.text()).toContain("BarDarwinWindows")});it("prefills selection list from model",function(){var element=renderTestTemplate([{type:"ArtifactName",value:"FooLinux"}]);expect(element.find("table[name=SelectedArtifacts] "+'tr:contains("FooLinux")').length).toBe(1)});it("filters artifacts by platform",function(){var element=renderTestTemplate([]);browserTriggerEvent(element.find('a:contains("Darwin")'),"click");expect(element.text()).not.toContain("FooLinux");
expect(element.text()).toContain("BarDarwinWindows");browserTriggerEvent(element.find('a:contains("Windows")'),"click");expect(element.text()).not.toContain("FooLinux");expect(element.text()).toContain("BarDarwinWindows");browserTriggerEvent(element.find('a:contains("Linux")'),"click");expect(element.text()).toContain("FooLinux");expect(element.text()).not.toContain("BarDarwinWindows")});it("checks sources platform when filtering by platform",function(){descriptorLinux={type:"ArtifactDescriptor",
value:{artifact:{type:"Artifact",value:{name:{type:"ArtifactName",value:"FooLinux"},sources:[{type:"ArtifactSource",value:{supported_os:[{type:"RDFString",value:"Linux"}]}}]}}}};descriptorDarwinWindows={type:"ArtifactDescriptor",value:{artifact:{type:"Artifact",value:{name:{type:"ArtifactName",value:"BarDarwinWindows"},sources:[{type:"ArtifactSource",value:{supported_os:[{type:"RDFString",value:"Darwin"},{type:"RDFString",value:"Windows"}]}}]}}}};var element=renderTestTemplate([]);browserTriggerEvent(element.find('a:contains("Darwin")'),
"click");expect(element.text()).not.toContain("FooLinux");expect(element.text()).toContain("BarDarwinWindows");browserTriggerEvent(element.find('a:contains("Windows")'),"click");expect(element.text()).not.toContain("FooLinux");expect(element.text()).toContain("BarDarwinWindows");browserTriggerEvent(element.find('a:contains("Linux")'),"click");expect(element.text()).toContain("FooLinux");expect(element.text()).not.toContain("BarDarwinWindows")});it("filters artifacts by name",function(){var element=
renderTestTemplate([]);element.find("input[name=Search]").val("bar");browserTriggerEvent(element.find("input[name=Search]"),"change");$rootScope.$apply();expect(element.text()).not.toContain("FooLinux");expect(element.text()).toContain("BarDarwinWindows")});it("shows artifact descriptor info for selected artifact",function(){var element=renderTestTemplate([]);var infoDirective;browserTriggerEvent(element.find('td:contains("FooLinux")'),"click");infoDirective=element.find("grr-semantic-value");expect(infoDirective.scope().$eval(infoDirective.attr("value"))).toEqual(descriptorLinux);
browserTriggerEvent(element.find('td:contains("BarDarwinWindows")'),"click");infoDirective=element.find("grr-semantic-value");expect(infoDirective.scope().$eval(infoDirective.attr("value"))).toEqual(descriptorDarwinWindows)});it("picks the artifact when Add is pressed",function(){var element=renderTestTemplate([]);browserTriggerEvent(element.find("table[name=Artifacts] "+'td:contains("FooLinux")'),"click");browserTriggerEvent(element.find('button:contains("Add")'),"click");expect(element.find("table[name=Artifacts] "+
'td:contains("FooLinux")').length).toBe(0);expect(element.find("table[name=SelectedArtifacts] "+'td:contains("FooLinux")').length).toBe(1)});it("picks the artifact on double click",function(){var element=renderTestTemplate([]);browserTriggerEvent(element.find("table[name=Artifacts] "+'td:contains("FooLinux")'),"dblclick");expect(element.find("table[name=Artifacts] "+'td:contains("FooLinux")').length).toBe(0);expect(element.find("table[name=SelectedArtifacts] "+'td:contains("FooLinux")').length).toBe(1)});
it("updates the model when artifact is picked",function(){var element=renderTestTemplate([]);browserTriggerEvent(element.find("table[name=Artifacts] "+'td:contains("FooLinux")'),"dblclick");expect(angular.equals($rootScope.value,[{type:"ArtifactName",value:"FooLinux"}]))});it("unpicks the artifact when Remove is pressed",function(){var element=renderTestTemplate([{type:"ArtifactName",value:"FooLinux"}]);browserTriggerEvent(element.find("table[name=SelectedArtifacts] "+'td:contains("FooLinux")'),"click");
browserTriggerEvent(element.find('button:contains("Remove")'),"click");expect(element.find("table[name=Artifacts] "+'td:contains("FooLinux")').length).toBe(1);expect(element.find("table[name=SelectedArtifacts] "+'td:contains("FooLinux")').length).toBe(0)});it("unpicks the artifact on double click",function(){var element=renderTestTemplate([{type:"ArtifactName",value:"FooLinux"}]);browserTriggerEvent(element.find("table[name=SelectedArtifacts] "+'td:contains("FooLinux")'),"dblclick");expect(element.find("table[name=Artifacts] "+
'td:contains("FooLinux")').length).toBe(1);expect(element.find("table[name=SelectedArtifacts] "+'td:contains("FooLinux")').length).toBe(0)});it("updates the model when artifact is unpicked",function(){var element=renderTestTemplate([{type:"ArtifactName",value:"FooLinux"}]);browserTriggerEvent(element.find("table[name=SelectedArtifacts] "+'td:contains("FooLinux")'),"dblclick");expect(angular.equals($rootScope.value,[]))});it("clears list of picked artifacts when Clear is pressed",function(){var element=
renderTestTemplate([{type:"ArtifactName",value:"FooLinux"},{type:"ArtifactName",value:"BarDarwinWindows"}]);browserTriggerEvent(element.find('button:contains("Clear")'),"click");expect(element.find("table[name=SelectedArtifacts] "+'td:contains("FooLinux")').length).toBe(0);expect(element.find("table[name=SelectedArtifacts] "+'td:contains("BarDarwinWindows")').length).toBe(0)});it("updates the model when selection list is cleared",function(){var element=renderTestTemplate([{type:"ArtifactName",value:"FooLinux"},
{type:"ArtifactName",value:"BarDarwinWindows"}]);browserTriggerEvent(element.find('button:contains("Clear")'),"click");expect(angular.equals($rootScope.value,[]))})})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.client.addClientsLabelsDialogDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var9=goog.require("grrUi.tests");var browserTriggerEvent=$jscomp$destructuring$var9.browserTriggerEvent;var testsModule=$jscomp$destructuring$var9.testsModule;var $jscomp$destructuring$var10=goog.require("grrUi.client.client");var clientModule=$jscomp$destructuring$var10.clientModule;describe("add clients labels dialog",function(){var $compile;
var $q;var $rootScope;var closeSpy;var dismissSpy;var grrApiService;beforeEach(module("/static/angular-components/client/"+"add-clients-labels-dialog.html"));beforeEach(module("/static/angular-components/core/"+"confirmation-dialog.html"));beforeEach(module("/static/angular-components/semantic/"+"client-urn.html"));beforeEach(module(clientModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$q=$injector.get("$q");$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");
grrApiService=$injector.get("grrApiService");closeSpy=jasmine.createSpy("close");dismissSpy=jasmine.createSpy("dismiss")}));var clients=[{type:"ApiClient",value:{urn:{value:"aff4:/C.0000111122223333",type:"RDFURN"},client_id:{value:"C.0000111122223333",type:"ApiClientId"}}},{type:"ApiClient",value:{urn:{value:"aff4:/C.1111222233334444",type:"RDFURN"},client_id:{value:"C.1111222233334444",type:"ApiClientId"}}}];var renderTestTemplate=function(clients){$rootScope.clients=clients;$rootScope.$close=closeSpy;
$rootScope.$dismiss=dismissSpy;var template="<grr-add-clients-labels-dialog "+'clients="clients" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("shows list of affected clients",function(){var element=renderTestTemplate(clients);expect(element.text()).toContain("C.0000111122223333");expect(element.text()).toContain("C.1111222233334444")});it('calls dismiss callback when "Cancel" is pressed',function(){var element=renderTestTemplate(clients);browserTriggerEvent($("button[name=Cancel]",
element),"click");expect(dismissSpy).toHaveBeenCalled()});it("disables Proceed if no label name is entered",function(){var element=renderTestTemplate(clients);expect($("input[name=labelBox]",element).val()).toEqual("");expect($("button[name=Proceed][disabled]",element).length).toBe(1)});it("enables Proceed if label name is entered",function(){var element=renderTestTemplate(clients);$("input[name=labelBox]",element).val("foobar");browserTriggerEvent($("input[name=labelBox]",element),"change");$rootScope.$apply();
expect($("button[name=Proceed][disabled]",element).length).toBe(0)});it("sends request when Proceed is clicked",function(){var deferred=$q.defer();spyOn(grrApiService,"post").and.returnValue(deferred.promise);var element=renderTestTemplate(clients);$("input[name=labelBox]",element).val("foobar");browserTriggerEvent($("input[name=labelBox]",element),"change");$rootScope.$apply();browserTriggerEvent($("button[name=Proceed]",element),"click");expect(grrApiService.post).toHaveBeenCalledWith("/clients/labels/add",
{client_ids:["C.0000111122223333","C.1111222233334444"],labels:["foobar"]})});it("shows failure warning on failure",function(){var deferred=$q.defer();spyOn(grrApiService,"post").and.returnValue(deferred.promise);var element=renderTestTemplate(clients);$("input[name=labelBox]",element).val("foobar");browserTriggerEvent($("input[name=labelBox]",element),"change");$rootScope.$apply();browserTriggerEvent($("button[name=Proceed]",element),"click");deferred.reject({data:{message:"NOT OK"}});$rootScope.$apply();
expect(element.text()).toContain("NOT OK")});it("shows success message on success",function(){var deferred=$q.defer();spyOn(grrApiService,"post").and.returnValue(deferred.promise);var element=renderTestTemplate(clients);$("input[name=labelBox]",element).val("foobar");browserTriggerEvent($("input[name=labelBox]",element),"change");$rootScope.$apply();browserTriggerEvent($("button[name=Proceed]",element),"click");deferred.resolve("OK");$rootScope.$apply();expect(element.text()).toContain("Label was successfully added")});
it("calls on-close callback when closed after success",function(){var deferred=$q.defer();spyOn(grrApiService,"post").and.returnValue(deferred.promise);var element=renderTestTemplate(clients);$("input[name=labelBox]",element).val("foobar");browserTriggerEvent($("input[name=labelBox]",element),"change");$rootScope.$apply();browserTriggerEvent($("button[name=Proceed]",element),"click");deferred.resolve("OK");$rootScope.$apply();browserTriggerEvent($("button[name=Close]",element),"click");expect(closeSpy).toHaveBeenCalled()})});
exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.client.checkClientAccessDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var11=goog.require("grrUi.client.client");var clientModule=$jscomp$destructuring$var11.clientModule;var $jscomp$destructuring$var12=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var12.testsModule;describe("grr-check-client-access directive",function(){var $compile;var $q;var $rootScope;var $timeout;var grrApiService;var grrRoutingService;
beforeEach(module("/static/angular-components/client/"+"check-client-access.html"));beforeEach(module(clientModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$q=$injector.get("$q");$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");$timeout=$injector.get("$timeout");grrApiService=$injector.get("grrApiService");grrRoutingService=$injector.get("grrRoutingService")}));var renderTestTemplate=function(noRedirect,omitClientId){$rootScope.noRedirect=
noRedirect;if(!omitClientId)$rootScope.clientId="C.0001000200030004";$rootScope.outHasAccess=undefined;var template='<grr-check-client-access no-redirect="noRedirect" '+'client-id="clientId" out-has-access="outHasAccess">foo-bar'+"</grr-check-client-access>";var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("doesn't assign .access-disabled class when clientId is undefined",function(){spyOn(grrApiService,"head").and.returnValue($q.defer().promise);var element=renderTestTemplate(false,
true);expect(element.find("div.access-disabled").length).toBe(0)});it("shows transcluded content",function(){spyOn(grrApiService,"head").and.returnValue($q.defer().promise);var element=renderTestTemplate();expect(element.text()).toContain("foo-bar")});it("sends HEAD request to check access",function(){spyOn(grrApiService,"head").and.returnValue($q.defer().promise);renderTestTemplate();expect(grrApiService.head).toHaveBeenCalledWith("clients/C.0001000200030004/flows")});it('updates the "outHasAccess" binding when access is permitted',
function(){var deferred=$q.defer();deferred.resolve();spyOn(grrApiService,"head").and.returnValue(deferred.promise);renderTestTemplate();expect($rootScope.outHasAccess).toBe(true)});it("doesn't assign .access-disabled class to container div when access is permitted",function(){var deferred=$q.defer();deferred.resolve();spyOn(grrApiService,"head").and.returnValue(deferred.promise);var element=renderTestTemplate();expect(element.find("div.access-disabled").length).toBe(0)});it('updates the "outHasAccess" binding when access is rejected',
function(){var deferred=$q.defer();deferred.reject();spyOn(grrApiService,"head").and.returnValue(deferred.promise);renderTestTemplate();expect($rootScope.outHasAccess).toBe(false)});it("assigns .access-disabled class to container div when access is rejected",function(){var deferred=$q.defer();deferred.reject();spyOn(grrApiService,"head").and.returnValue(deferred.promise);var element=renderTestTemplate();expect(element.find("div.access-disabled").length).toBe(1)});it('redirects to "client" state after 1s if noRedirect!=true and access is rejected',
function(){var deferred=$q.defer();deferred.reject();spyOn(grrApiService,"head").and.returnValue(deferred.promise);renderTestTemplate();spyOn(grrRoutingService,"go");$timeout.flush();expect(grrRoutingService.go).toHaveBeenCalledWith("client",{clientId:"C.0001000200030004"})});it("does not redirect after 1s if noRedirect=true and access is rejected",function(){var deferred=$q.defer();deferred.resolve();spyOn(grrApiService,"head").and.returnValue(deferred.promise);renderTestTemplate();spyOn(grrRoutingService,
"go");$timeout.flush();expect(grrRoutingService.go).not.toHaveBeenCalled()})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.client.clientStatusIconsDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var13=goog.require("grrUi.client.client");var clientModule=$jscomp$destructuring$var13.clientModule;var $jscomp$destructuring$var14=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var14.testsModule;describe("client status icons",function(){var $compile;var $rootScope;var grrTimeService;beforeEach(module("/static/angular-components/client/client-status-icons.html"));
beforeEach(module(clientModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");grrTimeService=$injector.get("grrTimeService")}));var render=function(client){$rootScope.client=client;var template='<grr-client-status-icons client="client" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("shows online icon when last ping is 1 minute ago",function(){var client=
{type:"ApiClient",value:{"last_seen_at":{value:42*1E6}}};grrTimeService.getCurrentTimeMs=function(){return(42+60)*1E3};var element=render(client);var iconElement=$("img[name=clientStatusIcon]",element);expect(iconElement.length).toBe(1);expect(iconElement[0].src).toContain("online.png");expect(iconElement[0].title).toBe("1 minutes ago")});it("shows online-1day icon when last ping is 23 hours ago",function(){var client={type:"ApiClient",value:{"last_seen_at":{value:42*1E6}}};grrTimeService.getCurrentTimeMs=
function(){return(42+60*60*23)*1E3};var element=render(client);var iconElement=$("img[name=clientStatusIcon]",element);expect(iconElement.length).toBe(1);expect(iconElement[0].src).toContain("online-1d.png");expect(iconElement[0].title).toBe("23 hours ago")});it("shows offline icon when last ping is is 3 days ago",function(){var client={type:"ApiClient",value:{"last_seen_at":{value:42*1E6}}};grrTimeService.getCurrentTimeMs=function(){return(42+60*60*24*3)*1E3};var element=render(client);var iconElement=
$("img[name=clientStatusIcon]",element);expect(iconElement.length).toBe(1);expect(iconElement[0].src).toContain("offline.png");expect(iconElement[0].title).toBe("3 days ago")});it("does not show crash icon if no crash happened",function(){var client={type:"ApiClient",value:{}};var element=render(client);var iconElement=$("img[name=clientCrashIcon]",element);expect(iconElement.length).toBe(0)});it("does not show crash icon if crash happened 1 week ago",function(){var client={type:"ApiClient",value:{"last_crash_at":{value:42*
1E6}}};grrTimeService.getCurrentTimeMs=function(){return(42+60*60*24*7)*1E3};var element=render(client);var iconElement=$("img[name=clientCrashIcon]",element);expect(iconElement.length).toBe(0)});it("shows crash icon if crash happened 1 hour ago",function(){var client={type:"ApiClient",value:{"last_crash_at":{value:42*1E6}}};grrTimeService.getCurrentTimeMs=function(){return(42+60*60)*1E3};var element=render(client);var iconElement=$("img[name=clientCrashIcon]",element);expect(iconElement.length).toBe(1);
expect(iconElement[0].src).toContain("skull-icon.png");expect(iconElement[0].title).toBe("1 hours ago")});it("shows no disk warning icon if none are present",function(){var element=render({type:"ApiClient",value:{}});var warningElement=$("img[name=clientDiskWarnings]",element);expect(warningElement.length).toBe(0)});it("shows disk warning icon if some are present",function(){var volume1={name:{value:"/Volume/A"},total_allocation_units:{value:100},actual_available_allocation_units:{value:3}};var volume2=
{name:{value:"C:"},total_allocation_units:{value:100},actual_available_allocation_units:{value:4}};var client={type:"ApiClient",value:{volumes:[{type:"Volume",value:volume1},{type:"Volume",value:volume2}]}};var element=render(client);var warningElement=$("img[name=clientDiskWarnings]",element);expect(warningElement.length).toBe(1)})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.client.clientUsernamesDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var15=goog.require("grrUi.client.client");var clientModule=$jscomp$destructuring$var15.clientModule;var $jscomp$destructuring$var16=goog.require("grrUi.semantic.semantic");var semanticModule=$jscomp$destructuring$var16.semanticModule;var $jscomp$destructuring$var17=goog.require("grrUi.tests");var stubDirective=$jscomp$destructuring$var17.stubDirective;
var testsModule=$jscomp$destructuring$var17.testsModule;describe("client usernames",function(){var $compile;var $rootScope;beforeEach(module(clientModule.name));beforeEach(module(semanticModule.name));beforeEach(module(testsModule.name));stubDirective("grrSemanticValue");beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope")}));var render=function(value){$rootScope.value=value;var template='<grr-client-usernames value="value" />';var element=
$compile(template)($rootScope);$rootScope.$apply();return element};it("List client usernames with grr-semantic-value",function(){var usernames={value:"test_1 test_2 test_3"};var element=render(usernames);var directive=element.find("grr-semantic-value");expect(directive.scope().$eval("usernames").length).toEqual(3);expect(directive.scope().$eval("usernames")[0].value).toEqual("test_1");expect(directive.scope().$eval("usernames")[1].value).toEqual("test_2");expect(directive.scope().$eval("usernames")[2].value).toEqual("test_3");
expect(directive.scope().$eval("usernames")[0].type).toEqual("RDFString");expect(directive.scope().$eval("usernames")[1].type).toEqual("RDFString");expect(directive.scope().$eval("usernames")[2].type).toEqual("RDFString")})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.client.clientsListDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var18=goog.require("grrUi.client.client");var clientModule=$jscomp$destructuring$var18.clientModule;var $jscomp$destructuring$var19=goog.require("grrUi.tests");var stubDirective=$jscomp$destructuring$var19.stubDirective;var testsModule=$jscomp$destructuring$var19.testsModule;describe("clients list",function(){var $compile;var $interval;var $q;var $rootScope;
var grrApiService;var grrRoutingService;var grrReflectionService;beforeEach(module("/static/angular-components/client/clients-list.html"));beforeEach(module(clientModule.name));beforeEach(module(testsModule.name));stubDirective("grrClientStatusIcons");stubDirective("grrSemanticValue");stubDirective("grrDisableIfNoTrait");beforeEach(inject(function($injector){$q=$injector.get("$q");$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");$interval=$injector.get("$interval");grrApiService=
$injector.get("grrApiService");grrReflectionService=$injector.get("grrReflectionService");grrRoutingService=$injector.get("grrRoutingService");grrReflectionService.getRDFValueDescriptor=function(valueType){var deferred=$q.defer();deferred.resolve({name:valueType,mro:[valueType]});return deferred.promise}}));afterEach(function(){$(document.body).html("")});var render=function(query){var template="<grr-clients-list />";var element=$compile(template)($rootScope);$rootScope.$apply();$("body").append(element);
$interval.flush(1E3);return element};var mockApiService=function(value){if(value)spyOn(grrApiService,"get").and.returnValues($q.when({data:value}),$q.defer().promise);else spyOn(grrApiService,"get").and.returnValue($q.defer().promise)};var mockRoutingService=function(query){spyOn(grrRoutingService,"uiOnParamsChanged").and.callFake(function(s,p,cb){cb(query)})};it("sends request with a query to the server",function(){mockApiService();mockRoutingService(".");render();expect(grrApiService.get).toHaveBeenCalledWith("/clients",
{query:".",offset:0,count:50})});it("renders list with one client correctly",function(){var clientsResponse={items:[{type:"VFSGRRClient",value:{client_id:{value:"C.0000000000000001",type:"ApiClientId"},first_seen_at:{value:0x4d368b34aa2eb,type:"RDFDatetime"},last_clock:{value:0x51287f9771b73,type:"RDFDatetime"},os_info:{value:{fqdn:{value:"localhost.com",type:"RDFString"},version:{value:"10.9.5",type:"VersionString"},install_date:{value:1385377629E6,type:"RDFDatetime"}},type:"ClientInformation"},
labels:[{"value":{"owner":{"value":"GRR","type":"unicode","age":0},"name":{"value":"foobar-label","type":"unicode","age":0}}}],interfaces:[{type:"Interface",value:{mac_address:"<mac address>"}}],users:[{type:"User",value:{username:{type:"RDFString",value:"user_foo"}}},{type:"User",value:{type:"RDFString",value:"user_bar"}}]}}]};mockApiService(clientsResponse);mockRoutingService(".");var element=render();expect($("grr-client-status-icons",element).length).toBe(1)});it("ignores interfaces without mac addresses",
function(){var clientsResponse={items:[{type:"VFSGRRClient",value:{client_id:{value:"C.0000000000000001",type:"ApiClientId"},interfaces:[{type:"Interface1",value:{mac_address:"<mac address 1>"}},{type:"Interface Without Mac Address",value:{}},{type:"Interface2",value:{mac_address:"<mac address 2>"}}]}}]};mockApiService(clientsResponse);mockRoutingService(".");var element=render();var macTableColumn=$("th:contains(MAC)",element).index();var macCell=$("tr td",element)[macTableColumn];var macDirective=
$("grr-semantic-value",macCell);var macDirectiveScope=macDirective.scope();var addresses=macDirectiveScope.$eval(macDirective.attr("value"));expect(addresses).toEqual(["<mac address 1>","<mac address 2>"])})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.client.hostHistoryDialogDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var20=goog.require("grrUi.client.client");var clientModule=$jscomp$destructuring$var20.clientModule;var $jscomp$destructuring$var21=goog.require("grrUi.tests");var stubDirective=$jscomp$destructuring$var21.stubDirective;var testsModule=$jscomp$destructuring$var21.testsModule;describe("semantic versioned proto directive",function(){var $compile;var $q;
var $rootScope;var grrApiService;var grrTimeService;beforeEach(module("/static/angular-components/client/"+"host-history-dialog.html"));beforeEach(module(clientModule.name));beforeEach(module(testsModule.name));stubDirective("grrSemanticValue");beforeEach(inject(function($injector){$q=$injector.get("$q");$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");grrApiService=$injector.get("grrApiService");grrTimeService=$injector.get("grrTimeService")}));var renderTestTemplate=function(fieldPath){$rootScope.clientId=
"C.00000000000000001";$rootScope.fieldPath=fieldPath;$rootScope.close=function(){};var template="<grr-host-history-dialog "+'client-id="clientId" field-path="fieldPath" '+'close="close()" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("fetches data for the last year",function(){spyOn(grrTimeService,"getCurrentTimeMs").and.returnValue(31536000001);spyOn(grrApiService,"get").and.returnValue($q.defer().promise);renderTestTemplate("foo");expect(grrApiService.get).toHaveBeenCalledWith("/clients/C.00000000000000001/versions",
{mode:"DIFF",start:1E3,end:31536000001E3})});it("correctly shows data for field path with 1 component",function(){var deferred=$q.defer();spyOn(grrApiService,"get").and.returnValue(deferred.promise);deferred.resolve({data:{items:[{type:"Foo",value:{field:{type:"RDFString",value:"bar1"},age:{type:"RDFDatetime",value:1}}},{type:"Foo",value:{age:{type:"RDFDatetime",value:2}}},{type:"Foo",value:{field:{type:"RDFString",value:"bar2"},age:{type:"RDFDatetime",value:3}}}]}});var element=renderTestTemplate("field");
expect(element.find("td.version grr-semantic-value").length).toBe(2);var directive=element.find("td.version:nth(0) grr-semantic-value");var value=directive.scope().$eval(directive.attr("value"));expect(value).toEqual({type:"RDFString",value:"bar2"});directive=element.find("td.version:nth(1) grr-semantic-value");value=directive.scope().$eval(directive.attr("value"));expect(value).toEqual({type:"RDFString",value:"bar1"})});it("correctly shows data for field path with 2 components",function(){var deferred=
$q.defer();spyOn(grrApiService,"get").and.returnValue(deferred.promise);deferred.resolve({data:{items:[{type:"Foo",value:{field1:{type:"Bar",value:{field2:{type:"RDFString",value:"oh1"}}},age:{type:"RDFDatetime",value:1}}},{type:"Foo",value:{age:{type:"RDFDatetime",value:2}}},{type:"Foo",value:{field1:{type:"Bar",value:{field2:{type:"RDFString",value:"oh2"}}},age:{type:"RDFDatetime",value:3}}}]}});var element=renderTestTemplate("field1.field2");expect(element.find("td.version grr-semantic-value").length).toBe(2);
var directive=element.find("td.version:nth(0) grr-semantic-value");var value=directive.scope().$eval(directive.attr("value"));expect(value).toEqual({type:"RDFString",value:"oh2"});directive=element.find("td.version:nth(1) grr-semantic-value");value=directive.scope().$eval(directive.attr("value"));expect(value).toEqual({type:"RDFString",value:"oh1"})})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.client.removeClientsLabelsDialogDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var22=goog.require("grrUi.tests");var browserTriggerEvent=$jscomp$destructuring$var22.browserTriggerEvent;var testsModule=$jscomp$destructuring$var22.testsModule;var $jscomp$destructuring$var23=goog.require("grrUi.client.client");var clientModule=$jscomp$destructuring$var23.clientModule;describe("remove clients labels dialog",function(){var $compile;
var $q;var $rootScope;var closeSpy;var dismissSpy;var grrApiService;beforeEach(module("/static/angular-components/client/"+"remove-clients-labels-dialog.html"));beforeEach(module("/static/angular-components/core/"+"confirmation-dialog.html"));beforeEach(module("/static/angular-components/semantic/"+"client-urn.html"));beforeEach(module(clientModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$q=$injector.get("$q");$compile=$injector.get("$compile");$rootScope=
$injector.get("$rootScope");grrApiService=$injector.get("grrApiService");closeSpy=jasmine.createSpy("close");dismissSpy=jasmine.createSpy("dismiss")}));var renderTestTemplate=function(clients){$rootScope.clients=clients;$rootScope.$close=closeSpy;$rootScope.$dismiss=dismissSpy;var template="<grr-remove-clients-labels-dialog "+'clients="clients" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("shows list of affected clients",function(){var clients=[{type:"ApiClient",
value:{urn:{value:"aff4:/C.0000111122223333",type:"RDFURN"},client_id:{value:"C.0000111122223333",type:"ApiClientId"}}},{type:"ApiClient",value:{urn:{value:"aff4:/C.1111222233334444",type:"RDFURN"},client_id:{value:"C.1111222233334444",type:"ApiClientId"}}}];var element=renderTestTemplate(clients);expect(element.text()).toContain("C.0000111122223333");expect(element.text()).toContain("C.1111222233334444")});var clientsWithTwoUserLabels=[{type:"ApiClient",value:{urn:{value:"aff4:/C.0000111122223333",
type:"RDFURN"},client_id:{value:"C.0000111122223333",type:"ApiClientId"},labels:[{value:{name:{value:"foo"},owner:{value:"test2"}}}]}},{type:"ApiClient",value:{urn:{value:"aff4:/C.1111222233334444",type:"RDFURN"},client_id:{value:"C.1111222233334444",type:"ApiClientId"},labels:[{value:{name:{value:"bar"},owner:{value:"test2"}}}]}}];var clientsWithOneUserLabelAndOneSystemLabel=[{type:"ApiClient",value:{urn:{value:"aff4:/C.0000111122223333",type:"RDFURN"},client_id:{value:"C.0000111122223333",type:"ApiClientId"},
labels:[{value:{name:{value:"foo"},owner:{value:"GRR"}}}]}},{type:"ApiClient",value:{urn:{value:"aff4:/C.1111222233334444",type:"RDFURN"},client_id:{value:"C.1111222233334444",type:"ApiClientId"},labels:[{value:{name:{value:"bar"},owner:{value:"test2"}}}]}}];it("shows dropdown with a union of labels from all clients",function(){var element=renderTestTemplate(clientsWithTwoUserLabels);expect($("select option",element).length).toBe(2);expect($("select option[label=foo]",element).length).toBe(1);expect($("select option[label=bar]",
element).length).toBe(1)});it("does not show system labels in the list",function(){var element=renderTestTemplate(clientsWithOneUserLabelAndOneSystemLabel);expect($("select option",element).length).toBe(1);expect($("select option[label=foo]",element).length).toBe(0);expect($("select option[label=bar]",element).length).toBe(1)});it("has a label selected by default",function(){var element=renderTestTemplate(clientsWithTwoUserLabels);var selected=$(":selected",element).text();expect(selected).toBeDefined()});
it('calls dismiss callback when "Cancel" is pressed',function(){var element=renderTestTemplate(clientsWithTwoUserLabels);browserTriggerEvent($("button[name=Cancel]",element),"click");expect(dismissSpy).toHaveBeenCalled()});it("sends request when proceed is clicked",function(){var deferred=$q.defer();spyOn(grrApiService,"post").and.returnValue(deferred.promise);var element=renderTestTemplate(clientsWithTwoUserLabels);browserTriggerEvent($("button[name=Proceed]",element),"click");expect(grrApiService.post).toHaveBeenCalledWith("/clients/labels/remove",
{client_ids:["C.0000111122223333","C.1111222233334444"],labels:["foo"]})});it("shows failure warning on failure",function(){var deferred=$q.defer();spyOn(grrApiService,"post").and.returnValue(deferred.promise);var element=renderTestTemplate(clientsWithTwoUserLabels);browserTriggerEvent($("button[name=Proceed]",element),"click");deferred.reject({data:{message:"NOT OK"}});$rootScope.$apply();expect(element.text()).toContain("NOT OK")});it("shows success message on success",function(){var deferred=$q.defer();
spyOn(grrApiService,"post").and.returnValue(deferred.promise);var element=renderTestTemplate(clientsWithTwoUserLabels);browserTriggerEvent($("button[name=Proceed]",element),"click");deferred.resolve("OK");$rootScope.$apply();expect(element.text()).toContain("Label was successfully removed")});it("calls on-close callback when closed after success",function(){var deferred=$q.defer();spyOn(grrApiService,"post").and.returnValue(deferred.promise);var element=renderTestTemplate(clientsWithTwoUserLabels);
browserTriggerEvent($("button[name=Proceed]",element),"click");deferred.resolve("OK");$rootScope.$apply();browserTriggerEvent($("button[name=Close]",element),"click");expect(closeSpy).toHaveBeenCalled()})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.config.binariesListDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var24=goog.require("grrUi.tests");var browserTriggerEvent=$jscomp$destructuring$var24.browserTriggerEvent;var testsModule=$jscomp$destructuring$var24.testsModule;var $jscomp$destructuring$var25=goog.require("grrUi.config.config");var configModule=$jscomp$destructuring$var25.configModule;var $jscomp$destructuring$var26=goog.require("grrUi.config.binariesListDirective");
var sortBinaries=$jscomp$destructuring$var26.sortBinaries;describe("grr-binaries-list directive",function(){describe("sortBinaries()",function(){it("adds correct metadata to binaries without slashes in path",function(){var binaries=sortBinaries([{value:{path:{value:"foo"}}}]);expect(binaries[0]["pathLen"]).toBe(1);expect(binaries[0]["dirName"]).toBe("");expect(binaries[0]["baseName"]).toBe("foo")});it("adds correct metadata to binaries with slashes in path",function(){var binaries=sortBinaries([{value:{path:{value:"foo/bar/42"}}}]);
expect(binaries[0]["pathLen"]).toBe(3);expect(binaries[0]["dirName"]).toBe("foo/bar");expect(binaries[0]["baseName"]).toBe("42")});it("puts paths with more slashes first",function(){var binaries=sortBinaries([{value:{path:{value:"foo"}}},{value:{path:{value:"foo/bar"}}},{value:{path:{value:"foo/bar/42"}}}]);expect(binaries[0]["value"]["path"]["value"]).toBe("foo/bar/42");expect(binaries[1]["value"]["path"]["value"]).toBe("foo/bar");expect(binaries[2]["value"]["path"]["value"]).toBe("foo")});it("sorts paths with same number of slashes alphabetically",
function(){var binaries=sortBinaries([{value:{path:{value:"foo/b"}}},{value:{path:{value:"foo/c"}}},{value:{path:{value:"foo/a"}}}]);expect(binaries[0]["value"]["path"]["value"]).toBe("foo/a");expect(binaries[1]["value"]["path"]["value"]).toBe("foo/b");expect(binaries[2]["value"]["path"]["value"]).toBe("foo/c")})});var $compile;var $q;var $rootScope;var grrApiService;beforeEach(module("/static/angular-components/config/binaries-list.html"));beforeEach(module(configModule.name));beforeEach(module(testsModule.name));
beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");$q=$injector.get("$q");grrApiService=$injector.get("grrApiService")}));var render=function(binaries,typeFilter){$rootScope.binaries=binaries;$rootScope.typeFilter=typeFilter;var template='<grr-binaries-list binaries="binaries" '+'type-filter="{$ typeFilter $}" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("triggers download when row is clicked",function(){var element=
render([{value:{path:{value:"foo/bar"},type:{value:"PYTHON_HACK"}}}],"PYTHON_HACK");var deferred=$q.defer();spyOn(grrApiService,"downloadFile").and.returnValue(deferred.promise);browserTriggerEvent(element.find('tr:contains("foo")'),"click");expect(grrApiService.downloadFile).toHaveBeenCalledWith("/config/binaries-blobs/PYTHON_HACK/foo/bar")})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.core.apiItemsProviderDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var27=goog.require("grrUi.core.apiItemsProviderDirective");var ApiItemsProviderController=$jscomp$destructuring$var27.ApiItemsProviderController;var $jscomp$destructuring$var28=goog.require("grrUi.core.core");var coreModule=$jscomp$destructuring$var28.coreModule;var $jscomp$destructuring$var29=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var29.testsModule;
describe("API items provider directive",function(){var $compile;var $q;var $rootScope;var grrApiServiceMock;beforeEach(module(coreModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$q=$injector.get("$q");$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");grrApiServiceMock={get:function(){}}}));var getController=function(url,queryParams,transformItems,testResponse){var controller;$rootScope.testUrl=url;$rootScope.testQueryParams=queryParams;
$rootScope.testTransformItems=transformItems;inject(function($injector){controller=$injector.instantiate(ApiItemsProviderController,{"$scope":$rootScope,"$attrs":{"url":"testUrl","queryParams":"testQueryParams","transformItems":transformItems?"testTransformItems(items)":undefined},"grrApiService":grrApiServiceMock})});var deferred=$q.defer();deferred.resolve(testResponse);spyOn(grrApiServiceMock,"get").and.returnValue(deferred.promise);$rootScope.$apply();return controller};it("fetches ranges of items according to offset and count",
function(){var controller=getController("some/api/path",undefined,undefined);controller.fetchItems(0,10);expect(grrApiServiceMock.get).toHaveBeenCalledWith("some/api/path",{offset:0,count:10})});it("does not fetch total count when opt_withTotalCount is true",function(){var controller=getController("some/api/path",undefined,undefined);controller.fetchItems(0,10,true);expect(grrApiServiceMock.get).toHaveBeenCalledWith("some/api/path",{offset:0,count:10})});it('adds "filter" to query when fetching filtered items',
function(){var controller=getController("some/api/path",undefined,undefined);controller.fetchFilteredItems("some",0,10);expect(grrApiServiceMock.get).toHaveBeenCalledWith("some/api/path",{offset:0,count:10,filter:"some"})})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.core.apiServiceTest");goog.setTestOnly();var $jscomp$destructuring$var30=goog.require("grrUi.core.core");var coreModule=$jscomp$destructuring$var30.coreModule;var $jscomp$destructuring$var31=goog.require("grrUi.core.apiService");var encodeUrlPath=$jscomp$destructuring$var31.encodeUrlPath;var stripTypeInfo=$jscomp$destructuring$var31.stripTypeInfo;var UNAUTHORIZED_API_RESPONSE_EVENT=$jscomp$destructuring$var31.UNAUTHORIZED_API_RESPONSE_EVENT;
describe("API service",function(){var $httpBackend;var $interval;var $q;var $rootScope;var grrApiService;beforeEach(module(coreModule.name));beforeEach(inject(function($injector){$rootScope=$injector.get("$rootScope");$q=$injector.get("$q");$httpBackend=$injector.get("$httpBackend");$interval=$injector.get("$interval");grrApiService=$injector.get("grrApiService");grrApiService.markAuthDone()}));afterEach(function(){$httpBackend.verifyNoOutstandingExpectation();$httpBackend.verifyNoOutstandingRequest()});
describe("encodeUrlPath() function",function(){it("does not touch slashes and normal characters",function(){expect(encodeUrlPath("////")).toBe("////");expect(encodeUrlPath("/a/b/c/d/")).toBe("/a/b/c/d/")});it('encodes "?", "&" and "+" characters',function(){expect(encodeUrlPath("/foo?bar=a+b")).toBe("/foo%3Fbar%3Da%2Bb")})});describe("stripTypeInfo() function",function(){it("converts richly typed primitive into a primitive value",function(){var richData={"age":0,"mro":["RDFString","object"],"type":"unicode",
"value":"label2"};expect(stripTypeInfo(richData)).toEqual("label2")});it("converts typed structure into a primitive dictionary",function(){var richData={"age":0,"mro":["AFF4ObjectLabel","RDFProtoStruct","RDFStruct","RDFValue","object"],"type":"AFF4ObjectLabel","value":{"name":{"age":0,"mro":["unicode","basestring","object"],"type":"unicode","value":"label2"}}};expect(stripTypeInfo(richData)).toEqual({"name":"label2"})});it("converts richly typed list into list of primitives",function(){var richData=
[{"age":0,"mro":["RDFString","object"],"type":"unicode","value":"label2"},{"age":0,"mro":["RDFString","object"],"type":"unicode","value":"label3"}];expect(stripTypeInfo(richData)).toEqual(["label2","label3"])});it("converts list structure field into list of primitives",function(){var richData={"age":0,"mro":["AFF4ObjectLabel","RDFProtoStruct","RDFStruct","RDFValue","object"],"type":"AFF4ObjectLabel","value":{"name":[{"age":0,"mro":["unicode","basestring","object"],"type":"unicode","value":"label2"},
{"age":0,"mro":["unicode","basestring","object"],"type":"unicode","value":"label3"}]}};expect(stripTypeInfo(richData)).toEqual({"name":["label2","label3"]})})});describe("head() method",function(){it('adds "/api/" to a given url',function(){$httpBackend.whenHEAD("/api/some/path").respond(200);grrApiService.head("some/path");$httpBackend.flush()});it('adds "/api/" to a given url starting with "/"',function(){$httpBackend.whenHEAD("/api/some/path").respond(200);grrApiService.head("/some/path");$httpBackend.flush()});
it("passes user-provided headers in the request",function(){$httpBackend.whenHEAD("/api/some/path?key1=value1&key2=value2").respond(200);grrApiService.head("some/path",{key1:"value1",key2:"value2"});$httpBackend.flush()});it("passes user-provided headers in the request",function(){$httpBackend.whenHEAD("/api/some/path?"+"key1=value1&key2=value2").respond(200);grrApiService.head("some/path",{key1:"value1",key2:"value2"});$httpBackend.flush()});it("url-escapes the path",function(){$httpBackend.whenHEAD("/api/some/path%3Ffoo%26bar?key1=value1&key2=value2").respond(200);
grrApiService.head("some/path?foo&bar",{key1:"value1",key2:"value2"});$httpBackend.flush()})});describe("get() method",function(){it('adds "/api/" to a given url',function(){$httpBackend.whenGET("/api/some/path").respond(200);grrApiService.get("some/path");$httpBackend.flush()});it('adds "/api/" to a given url starting with "/"',function(){$httpBackend.whenGET("/api/some/path").respond(200);grrApiService.get("/some/path");$httpBackend.flush()});it("passes user-provided headers in the request",function(){$httpBackend.whenGET("/api/some/path?key1=value1&key2=value2").respond(200);
grrApiService.get("some/path",{key1:"value1",key2:"value2"});$httpBackend.flush()});it("passes user-provided headers in the request",function(){$httpBackend.whenGET("/api/some/path?"+"key1=value1&key2=value2").respond(200);grrApiService.get("some/path",{key1:"value1",key2:"value2"});$httpBackend.flush()});it("url-escapes the path",function(){$httpBackend.whenGET("/api/some/path%3Ffoo%26bar?key1=value1&key2=value2").respond(200);grrApiService.get("some/path?foo&bar",{key1:"value1",key2:"value2"});
$httpBackend.flush()})});describe("poll() method",function(){it("triggers url once if condition is immediately satisfied",function(){$httpBackend.expectGET("/api/some/path").respond(200,{"state":"FINISHED"});grrApiService.poll("some/path",1E3);$httpBackend.flush();$interval.flush(2E3)});it("does not call callbacks when cancelled via cancelPoll()",function(){$httpBackend.expectGET("/api/some/path").respond(200,{});var successHandlerCalled=false;var failureHandlerCalled=false;var finallyHandlerCalled=
false;var pollPromise=grrApiService.poll("some/path",1E3);pollPromise.then(function(){successHandlerCalled=true},function(){failureHandlerCalled=true}).finally(function(){finallyHandlerCalled=true});grrApiService.cancelPoll(pollPromise);$httpBackend.flush();expect(successHandlerCalled).toBe(false);expect(failureHandlerCalled).toBe(false);expect(finallyHandlerCalled).toBe(false)});it("succeeds and returns response if first try succeeds",function(){$httpBackend.expectGET("/api/some/path").respond(200,
{"foo":"bar","state":"FINISHED"});var successHandlerCalled=false;grrApiService.poll("some/path",1E3).then(function(response){expect(response["data"]).toEqual({"foo":"bar","state":"FINISHED"});successHandlerCalled=true});$httpBackend.flush();expect(successHandlerCalled).toBe(true)});it("triggers url multiple times if condition is not satisfied",function(){$httpBackend.expectGET("/api/some/path").respond(200,{});grrApiService.poll("some/path",1E3);$httpBackend.flush();$httpBackend.expectGET("/api/some/path").respond(200,
{});$interval.flush(2E3);$httpBackend.flush()});it("succeeds and returns response if second try succeeds",function(){$httpBackend.expectGET("/api/some/path").respond(200,{});var successHandlerCalled=false;grrApiService.poll("some/path",1E3).then(function(response){expect(response["data"]).toEqual({"foo":"bar","state":"FINISHED"});successHandlerCalled=true});$httpBackend.flush();$httpBackend.expectGET("/api/some/path").respond(200,{"foo":"bar","state":"FINISHED"});$interval.flush(2E3);$httpBackend.flush();
expect(successHandlerCalled).toBe(true)});it("fails if first try fails",function(){$httpBackend.expectGET("/api/some/path").respond(500);var failureHandleCalled=false;grrApiService.poll("some/path",1E3).then(function(){},function(){failureHandleCalled=true});$httpBackend.flush();expect(failureHandleCalled).toBe(true)});it("fails if first try is correct, but second one fails",function(){$httpBackend.expectGET("/api/some/path").respond(200,{});var failureHandleCalled=false;grrApiService.poll("some/path",
1E3).then(function(){},function(){failureHandleCalled=true});$httpBackend.flush();$httpBackend.expectGET("/api/some/path").respond(500);$interval.flush(2E3);$httpBackend.flush();expect(failureHandleCalled).toBe(true)});it("returns response payload on failure",function(){$httpBackend.expectGET("/api/some/path").respond(500,{"foo":"bar"});grrApiService.poll("some/path",1E3).then(function(){},function(response){expect(response["data"]).toEqual({"foo":"bar"})});$httpBackend.flush()});it("notifies on every intermediate poll result",
function(){$httpBackend.expectGET("/api/some/path").respond(200,{});var notificationCount=0;grrApiService.poll("some/path",1E3).then(undefined,undefined,function(data){notificationCount+=1});expect(notificationCount).toBe(0);$httpBackend.flush();expect(notificationCount).toBe(1);$interval.flush(500);expect(notificationCount).toBe(1);$httpBackend.expectGET("/api/some/path").respond(200,{});$interval.flush(500);$httpBackend.flush();expect(notificationCount).toBe(2)});it("does not allow API requests to overlap",
function(){var deferred=$q.defer();spyOn(grrApiService,"get").and.returnValue(deferred.promise);grrApiService.poll("some/path",1E3);expect(grrApiService.get).toHaveBeenCalledTimes(1);$interval.flush(2E3);expect(grrApiService.get).toHaveBeenCalledTimes(1)});it("does not resolve the promise after cancelPoll() call",function(){$httpBackend.expectGET("/api/some/path").respond(200,{"foo":"bar","state":"FINISHED"});var successHandlerCalled=false;var promise=grrApiService.poll("some/path",1E3).then(function(response){successHandlerCalled=
true});grrApiService.cancelPoll(promise);$httpBackend.flush();expect(successHandlerCalled).toBe(false)});it("works correctly on a chained promise",function(){$httpBackend.expectGET("/api/some/path").respond(200,{"foo":"bar","state":"FINISHED"});var successHandlerCalled=false;var finallyHandlerCalled=false;grrApiService.poll("some/path",1E3).then(function(){successHandlerCalled=true}).catch(function(){}).finally(function(){finallyHandlerCalled=true});$httpBackend.flush();expect(finallyHandlerCalled).toBe(true);
expect(successHandlerCalled).toBe(true)});it("allows cancelPoll to be called on a chained promise",function(){$httpBackend.expectGET("/api/some/path").respond(200,{"foo":"bar","state":"FINISHED"});var successHandlerCalled=false;var finallyHandlerCalled=false;var promise=grrApiService.poll("some/path",1E3).then(function(){successHandlerCalled=true}).catch(function(){}).finally(function(){finallyHandlerCalled=true});grrApiService.cancelPoll(promise);$httpBackend.flush();expect(finallyHandlerCalled).toBe(false);
expect(successHandlerCalled).toBe(false)})});describe("cancelPoll() method",function(){it('raises if the promise does not have "cancel" attribute',function(){var deferred=$q.defer();expect(function(){grrApiService.cancelPoll(deferred.promise)}).toThrow(new Error("Invalid promise to cancel: not cancelable."))})});describe("delete() method",function(){it('adds "/api/" to a given url',function(){$httpBackend.expectDELETE("/api/some/path").respond(200);grrApiService.delete("some/path");$httpBackend.flush()});
it('adds "/api/" to a given url starting with "/"',function(){$httpBackend.expectDELETE("/api/some/path").respond(200);grrApiService.delete("/some/path");$httpBackend.flush()});it("passes user-provided data in the request",function(){$httpBackend.expect("DELETE","/api/some/path",{key1:"value1",key2:"value2"}).respond(200);grrApiService.delete("some/path",{key1:"value1",key2:"value2"});$httpBackend.flush()});it("url-escapes the path",function(){$httpBackend.expectDELETE("/api/some/path%3Ffoo%26bar").respond(200);
grrApiService.delete("some/path?foo&bar");$httpBackend.flush()});it("doesn't send request body if no payload provided",function(){$httpBackend.expect("DELETE","/api/some/path",function(data){return angular.isUndefined(data)}).respond(200);grrApiService.delete("some/path");$httpBackend.flush()})});describe("patch() method",function(){it('adds "/api/" to a given url',function(){$httpBackend.expectPATCH("/api/some/path").respond(200);grrApiService.patch("some/path");$httpBackend.flush()});it('adds "/api/" to a given url starting with "/"',
function(){$httpBackend.expectPATCH("/api/some/path").respond(200);grrApiService.patch("/some/path");$httpBackend.flush()});it("passes user-provided data in the request",function(){$httpBackend.expect("PATCH","/api/some/path",{key1:"value1",key2:"value2"}).respond(200);grrApiService.patch("some/path",{key1:"value1",key2:"value2"});$httpBackend.flush()});it("url-escapes the path",function(){$httpBackend.expectPATCH("/api/some/path%3Ffoo%26bar").respond(200);grrApiService.patch("some/path?foo&bar");
$httpBackend.flush()})});describe("post() method",function(){it('adds "/api/" to a given url',function(){$httpBackend.whenPOST("/api/some/path").respond(200);grrApiService.post("some/path");$httpBackend.flush()});it('adds "/api/" to a given url starting with "/"',function(){$httpBackend.whenPOST("/api/some/path").respond(200);grrApiService.post("/some/path",{});$httpBackend.flush()});it("strips type info from params if opt_stripTypeInfo is true",function(){var richData={"age":0,"mro":["AFF4ObjectLabel",
"RDFProtoStruct","RDFStruct","RDFValue","object"],"type":"AFF4ObjectLabel","value":{"name":{"age":0,"mro":["unicode","basestring","object"],"type":"unicode","value":"label2"}}};$httpBackend.whenPOST("/api/some/path",{name:"label2"}).respond(200);grrApiService.post("some/path",richData,true);$httpBackend.flush()});it("passes user-provided headers in the request",function(){$httpBackend.expectPOST("/api/some/path",{key1:"value1",key2:"value2"}).respond(200);grrApiService.post("some/path",{key1:"value1",
key2:"value2"});$httpBackend.flush()});it("url-escapes the path",function(){$httpBackend.whenPOST("/api/some/path%3Ffoo%26bar").respond(200);grrApiService.post("some/path?foo&bar",{});$httpBackend.flush()});it("url-escapes the path when files are uploaded",function(){$httpBackend.whenPOST("/api/some/path%3Ffoo%26bar").respond(200);grrApiService.post("some/path?foo&bar",{},false,{"file1":"blah"});$httpBackend.flush()})});describe("downloadFile() method",function(){afterEach(function(){$(document.body).html("")});
it("sends HEAD request first to check if URL is accessible",function(){$httpBackend.expectHEAD("/api/some/path").respond(200);grrApiService.downloadFile("some/path");$httpBackend.flush()});it("sends query parameters in the HEAD request",function(){$httpBackend.expectHEAD("/api/some/path?abra=cadabra&foo=bar").respond(200);grrApiService.downloadFile("some/path",{"foo":"bar","abra":"cadabra"});$httpBackend.flush()});it("url-escapes the path",function(){$httpBackend.expectHEAD("/api/some/path%3Ffoo%26bar?key1=value1&key2=value2").respond(200);
grrApiService.downloadFile("some/path?foo&bar",{key1:"value1",key2:"value2"});$httpBackend.flush()});it("rejects promise if HEAD request fails",function(){$httpBackend.whenHEAD("/api/some/path").respond(500);var promiseRejected=false;var promise=grrApiService.downloadFile("some/path");promise.then(function(){},function(){promiseRejected=true});$httpBackend.flush();expect(promiseRejected).toBe(true)});it("broadcasts subject/reason from UnauthorizedAccess HEAD response",function(){$httpBackend.whenHEAD("/api/some/path").respond(403,
{},{"x-grr-unauthorized-access-subject":"some subject","x-grr-unauthorized-access-reason":"some reason"});spyOn($rootScope,"$broadcast");grrApiService.downloadFile("some/path");$httpBackend.flush();expect($rootScope.$broadcast).toHaveBeenCalledWith(UNAUTHORIZED_API_RESPONSE_EVENT,{subject:"some subject",reason:"some reason"})});it("creates an iframe request if HEAD succeeds",function(){$httpBackend.whenHEAD("/api/some/path").respond(200);grrApiService.downloadFile("some/path");$httpBackend.flush();
expect($("iframe").attr("src")).toBe("/api/some/path")});it('propagates query option to iframe "src" attribute',function(){$httpBackend.whenHEAD("/api/some/path?abra=cadabra&foo=bar").respond(200);grrApiService.downloadFile("some/path",{"foo":"bar","abra":"cadabra"});$httpBackend.flush();expect($("iframe").attr("src")).toBe("/api/some/path?abra=cadabra&foo=bar")});it("fails if same-origin-policy error is thrown when accessing iframe",function(){$httpBackend.whenHEAD("/api/some/path").respond(200);
var promiseRejected=false;var promise=grrApiService.downloadFile("some/path");promise.then(function(){},function(){promiseRejected=true});$httpBackend.flush();Object.defineProperty($("iframe")[0].contentWindow.document,"readyState",{__proto__:null,get:function(){throw new Error("Same origin policy error");}});$interval.flush(1E3);expect(promiseRejected).toBe(true)});it("cancels the interval timer if iframe request fails",function(){$httpBackend.whenHEAD("/api/some/path").respond(200);spyOn($interval,
"cancel").and.returnValue();grrApiService.downloadFile("some/path");$httpBackend.flush();Object.defineProperty($("iframe")[0].contentWindow.document,"readyState",{__proto__:null,get:function(){throw new Error("Same origin policy error");}});$interval.flush(1E3);expect($interval.cancel).toHaveBeenCalled()});it("succeeds if iframe request succeeds",function(){$httpBackend.whenHEAD("/api/some/path").respond(200);var promiseSucceeded=false;var promise=grrApiService.downloadFile("some/path");promise.then(function(){promiseSucceeded=
true});$httpBackend.flush();Object.defineProperty($("iframe")[0].contentWindow.document,"readyState",{__proto__:null,get:function(){return"complete"}});$interval.flush(1E3);expect(promiseSucceeded).toBe(true)});it("cancels the interval timer if iframe request succeeds",function(){$httpBackend.whenHEAD("/api/some/path").respond(200);spyOn($interval,"cancel").and.returnValue();grrApiService.downloadFile("some/path");$httpBackend.flush();Object.defineProperty($("iframe")[0].contentWindow.document,"readyState",
{__proto__:null,get:function(){return"complete"}});$interval.flush(1E3);expect($interval.cancel).toHaveBeenCalled()})})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.core.bindKeyDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var32=goog.require("grrUi.tests");var browserTriggerKeyDown=$jscomp$destructuring$var32.browserTriggerKeyDown;var testsModule=$jscomp$destructuring$var32.testsModule;var $jscomp$destructuring$var33=goog.require("grrUi.core.core");var coreModule=$jscomp$destructuring$var33.coreModule;describe("bind key directive",function(){var $compile;var $rootScope;beforeEach(module(coreModule.name));
beforeEach(module(testsModule.name));beforeEach(inject(function($injector,_$interval_){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope")}));var render=function(callback,key){$rootScope.callback=callback;var template='<input type="text" grr-bind-key="callback()" key="'+key+'" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("calls the specified function on keydown",function(done){var element=render(done,13);browserTriggerKeyDown(element,
13)});it("calls the specified function only on specified keydown",function(){var callback=function(){fail("Callback should not be called")};var element=render(callback,13);browserTriggerKeyDown(element,15)})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.core.bytesToHexFilterTest");goog.setTestOnly();var $jscomp$destructuring$var34=goog.require("grrUi.core.bytesToHexFilter");var BytesToHexFilter=$jscomp$destructuring$var34.BytesToHexFilter;var $jscomp$destructuring$var35=goog.require("grrUi.core.core");var coreModule=$jscomp$destructuring$var35.coreModule;var $jscomp$destructuring$var36=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var36.testsModule;describe("grrBytesToHex filter",
function(){var grrBytesToHexFilter;beforeEach(module(coreModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){grrBytesToHexFilter=$injector.instantiate(BytesToHexFilter)}));it("returns the correct hex for different input bytes",function(){var result=grrBytesToHexFilter("some text");expect(result).toBe("736f6d652074657874");result=grrBytesToHexFilter("123abc");expect(result).toBe("313233616263")})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.core.canaryOnlyDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var37=goog.require("grrUi.core.core");var coreModule=$jscomp$destructuring$var37.coreModule;var $jscomp$destructuring$var38=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var38.testsModule;describe("The canaryOnlyDirective package",function(){var $compile;var $q;var $rootScope;var grrApiService;beforeEach(module(coreModule.name));beforeEach(module(testsModule.name));
beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");$q=$injector.get("$q");grrApiService=$injector.get("grrApiService")}));var renderTestTemplate=function(){var template="<grr-canary-only>"+"This text is being canaried."+"</grr-canary-only>"+"<grr-non-canary-only>"+"This text is being deprecated."+"</grr-non-canary-only>";var element=$compile(template)($rootScope);$rootScope.$apply();return element};var setMockedCanaryModeValue=function(newValue){var deferred=
$q.defer();deferred.resolve({data:{value:{settings:{value:{canary_mode:{value:newValue}}}}}});spyOn(grrApiService,"getCached").and.returnValue(deferred.promise)};it("renders the grr-canary-only element in canary mode",function(){setMockedCanaryModeValue(true);var element=renderTestTemplate();expect(element.text()).toContain("This text is being canaried.")});it("doesn't render the grr-canary-only element in non-canary mode",function(){setMockedCanaryModeValue(false);var element=renderTestTemplate();
expect(element.text()).not.toContain("This text is being canaried.")});it("renders the grr-non-canary-only element in non-canary mode",function(){setMockedCanaryModeValue(false);var element=renderTestTemplate();expect(element.text()).toContain("This text is being deprecated.")});it("doesn't render the grr-non-canary-only element in canary mode",function(){setMockedCanaryModeValue(true);var element=renderTestTemplate();expect(element.text()).not.toContain("This text is being deprecated.")})});exports=
{};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.core.clockDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var39=goog.require("grrUi.core.core");var coreModule=$jscomp$destructuring$var39.coreModule;var $jscomp$destructuring$var40=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var40.testsModule;describe("clock directive",function(){var $compile;var $interval;var $rootScope;var grrTimeService;beforeEach(module(coreModule.name));beforeEach(module(testsModule.name));
beforeEach(inject(function($injector,_$interval_){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");$interval=_$interval_;grrTimeService=$injector.get("grrTimeService")}));afterEach(inject(function($injector){grrTimeService=$injector.get("grrTimeService")}));var renderTestTemplate=function(){var template="<grr-live-clock />";var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("shows the current time in a clock",function(){var time="2015-01-02 03:04:05";
grrTimeService.formatAsUTC=function(){return time+" UTC"};var newElement=renderTestTemplate();expect(newElement.text()).toContain("2015-01-02 03:04:05 UTC");time="2015-01-02 03:04:06";$interval.flush(6E4);expect(newElement.text()).toContain("03:04:06")})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.core.confirmationDialogDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var41=goog.require("grrUi.tests");var browserTriggerEvent=$jscomp$destructuring$var41.browserTriggerEvent;var testsModule=$jscomp$destructuring$var41.testsModule;var $jscomp$destructuring$var42=goog.require("grrUi.core.core");var coreModule=$jscomp$destructuring$var42.coreModule;describe("confirmation dialog directive",function(){var $compile;var $q;
var $rootScope;beforeEach(module("/static/angular-components/core/confirmation-dialog.html"));beforeEach(module(coreModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");$q=$injector.get("$q")}));var render=function(title,message,proceedCallback,buttonClass){$rootScope.title=title;$rootScope.message=message;$rootScope.proceed=proceedCallback;$rootScope.buttonClass=buttonClass;var template=
"<grr-confirmation-dialog "+'    title="title" '+'    proceed="proceed()"'+'    proceed-class="buttonClass">'+"  {$ message $}"+"</grr-confirmation-dialog>";var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("shows title and message",function(){var title="Test Title";var message="Test Content Message";var element=render(title,message);expect(element.find(".modal-header h3").text().trim()).toBe(title);expect(element.find(".modal-body").text().trim()).toContain(message)});
it('applies given style to "proceed" button',function(){var element=render("title","message",undefined,"btn-warning");expect(element.find("button.btn-warning")).not.toBe(undefined)});it("shows success on proceed promise resolve",function(){var successMessage="Some action just happened successfully";var proceed=function(){return $q.when(successMessage)};var element=render("","",proceed);spyOn($rootScope,"proceed").and.callThrough();browserTriggerEvent(element.find('button[name="Proceed"]'),"click");
$rootScope.$apply();expect($rootScope.proceed).toHaveBeenCalled();expect(element.find(".modal-footer .text-success").text().trim()).toBe(successMessage);expect(element.find('button[name="Close"]').length).toBe(1)});it("shows error on proceed promise reject",function(){var errorMessage="Some action could not be performed";var proceed=function(){return $q.reject(errorMessage)};var element=render("","",proceed);spyOn($rootScope,"proceed").and.callThrough();browserTriggerEvent(element.find('button[name="Proceed"]'),
"click");$rootScope.$apply();expect($rootScope.proceed).toHaveBeenCalled();expect(element.find(".modal-footer .text-danger").text().trim()).toBe(errorMessage)});it("shows a disabled proceed button when canProceed is false",function(){var buttonEnabled=false;$rootScope.canProceed=function(){return buttonEnabled};var template='<grr-confirmation-dialog can-proceed="canProceed()">'+"</grr-confirmation-dialog>";var element=$compile(template)($rootScope);$rootScope.$apply();expect($("button[name=Proceed][disabled]",
element).length).toBe(1);buttonEnabled=true;$rootScope.$apply();expect($("button[name=Proceed][disabled]",element).length).toBe(0)})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.core.disableIfNoTraitDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var43=goog.require("grrUi.core.core");var coreModule=$jscomp$destructuring$var43.coreModule;var $jscomp$destructuring$var44=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var44.testsModule;describe("grr-disable-if-no-trait directive",function(){var $compile;var $q;var $rootScope;var grrApiService;beforeEach(module(coreModule.name));
beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");$q=$injector.get("$q");grrApiService=$injector.get("grrApiService")}));var renderTestTemplate=function(){var template='<span grr-disable-if-no-trait="trait_foo"></span>';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it('applied "disabled" attribute if trait is missing',function(){var deferred=$q.defer();deferred.resolve({data:{value:{interface_traits:{value:{}}}}});
spyOn(grrApiService,"getCached").and.returnValue(deferred.promise);var element=renderTestTemplate();expect(element.attr("disabled")).toBe("disabled")});it('applied "disabled" attribute if trait is false',function(){var deferred=$q.defer();deferred.resolve({data:{value:{interface_traits:{value:{trait_foo:{value:false}}}}}});spyOn(grrApiService,"getCached").and.returnValue(deferred.promise);var element=renderTestTemplate();expect(element.attr("disabled")).toBe("disabled")});it("does nothing if trait is true",
function(){var deferred=$q.defer();deferred.resolve({data:{value:{interface_traits:{value:{trait_foo:{value:true}}}}}});spyOn(grrApiService,"getCached").and.returnValue(deferred.promise);var element=renderTestTemplate();expect(element.attr("disabled")).toBe(undefined)})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.core.downloadCollectionAsDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var45=goog.require("grrUi.tests");var browserTriggerEvent=$jscomp$destructuring$var45.browserTriggerEvent;var testsModule=$jscomp$destructuring$var45.testsModule;var $jscomp$destructuring$var46=goog.require("grrUi.core.core");var coreModule=$jscomp$destructuring$var46.coreModule;describe('"download collection as" panel',function(){var $compile;var $q;
var $rootScope;var grrApiService;beforeEach(module("/static/angular-components/core/download-collection-as.html"));beforeEach(module(coreModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$q=$injector.get("$q");$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");grrApiService=$injector.get("grrApiService")}));var renderTestTemplate=function(baseUrl){$rootScope.baseUrl=baseUrl||"foo/bar";var template="<grr-download-collection-as "+'base-url="baseUrl" />';
var element=$compile(template)($rootScope);$rootScope.$apply();return element};var testDownloadAsType=function(plugin){return function(){var deferred=$q.defer();spyOn(grrApiService,"downloadFile").and.returnValue(deferred.promise);var element=renderTestTemplate();element.find("#plugin-select").val("string:"+plugin).change();browserTriggerEvent(element.find('button[name="download-as"]'),"click");expect(grrApiService.downloadFile).toHaveBeenCalledWith("foo/bar/"+plugin)}};it("sends correct request for CSV download",
testDownloadAsType("csv-zip"));it("sends correct request for flattened YAML download",testDownloadAsType("flattened-yaml-zip"));it("sends correct request for sqlite download",testDownloadAsType("sqlite-zip"))});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.core.downloadCollectionFilesDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var47=goog.require("grrUi.core.core");var coreModule=$jscomp$destructuring$var47.coreModule;var $jscomp$destructuring$var48=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var48.testsModule;describe("download collection files directive",function(){var $compile;var $q;var $rootScope;var grrApiService;var $window={navigator:{}};
beforeEach(module(function($provide){$provide.value("$window",$window)}));beforeEach(module("/static/angular-components/core/"+"download-collection-files.html"));beforeEach(module(coreModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=$injector.get("$compile");$q=$injector.get("$q");$rootScope=$injector.get("$rootScope");grrApiService=$injector.get("grrApiService")}));var renderTestTemplate=function(opt_withExportCommand){$rootScope.downloadUrl="some/download/url";
if(opt_withExportCommand)$rootScope.exportCommandUrl="some/export-command/url";var template="<grr-download-collection-files "+'download-url="downloadUrl" export-command-url="exportCommandUrl" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("shows TAR.GZ as default option on Mac",function(){$window.navigator.appVersion="Mac";var element=renderTestTemplate();expect(element.find("button").text()).toContain("Generate TAR.GZ");expect(element.find("ul.dropdown-menu li").text()).toContain("Generate ZIP")});
it("shows ZIP as default option on Linux",function(){$window.navigator.appVersion="Linux";var element=renderTestTemplate();expect(element.find("button").text()).toContain("Generate ZIP");expect(element.find("ul.dropdown-menu li").text()).toContain("Generate TAR.GZ")});it("sends TAR.GZ generation request when button clicked on Mac",function(){$window.navigator.appVersion="Mac";var deferred=$q.defer();spyOn(grrApiService,"downloadFile").and.returnValue(deferred.promise);var element=renderTestTemplate();
element.find("button").click();expect(grrApiService.downloadFile).toHaveBeenCalledWith("some/download/url",{archive_format:"TAR_GZ"})});it("sends ZIP generation request when dropdownclicked on Mac",function(){$window.navigator.appVersion="Mac";var deferred=$q.defer();spyOn(grrApiService,"downloadFile").and.returnValue(deferred.promise);var element=renderTestTemplate();element.find("ul.dropdown-menu li a").click();expect(grrApiService.downloadFile).toHaveBeenCalledWith("some/download/url",{archive_format:"ZIP"})});
it("sends ZIP generation request when button is clicked on Linux",function(){$window.navigator.appVersion="Linux";var deferred=$q.defer();spyOn(grrApiService,"downloadFile").and.returnValue(deferred.promise);var element=renderTestTemplate();element.find("button").click();expect(grrApiService.downloadFile).toHaveBeenCalledWith("some/download/url",{archive_format:"ZIP"})});it("sends TAR.GZ generation request when dropdown clicked on Linux",function(){$window.navigator.appVersion="Linux";var deferred=
$q.defer();spyOn(grrApiService,"downloadFile").and.returnValue(deferred.promise);var element=renderTestTemplate();element.find("ul.dropdown-menu li a").click();expect(grrApiService.downloadFile).toHaveBeenCalledWith("some/download/url",{archive_format:"TAR_GZ"})});it("disables the button after request is sent",function(){var deferred=$q.defer();spyOn(grrApiService,"downloadFile").and.returnValue(deferred.promise);var element=renderTestTemplate();expect(element.find("button[disabled]").length).toBe(0);
element.find("ul.dropdown-menu li a").click();expect(element.find("button[disabled]").length).not.toBe(0)});it("shows success message if request succeeds",function(){var deferred=$q.defer();spyOn(grrApiService,"downloadFile").and.returnValue(deferred.promise);var element=renderTestTemplate();element.find("button").click();deferred.resolve({status:"OK"});$rootScope.$apply();expect(element.text()).toContain("Generation has started.")});it("shows failure message if request fails",function(){var deferred=
$q.defer();spyOn(grrApiService,"downloadFile").and.returnValue(deferred.promise);var element=renderTestTemplate();element.find("button").click();deferred.reject({data:{message:"FAIL"}});$rootScope.$apply();expect(element.text()).toContain("Can't generate archive: FAIL")});describe("with export command url provided",function(){var exportCommandDeferred;beforeEach(function(){$window.navigator.appVersion="Mac";exportCommandDeferred=$q.defer();spyOn(grrApiService,"get").and.returnValue(exportCommandDeferred.promise)});
it("fetches export command",function(){renderTestTemplate(true);expect(grrApiService.get).toHaveBeenCalledWith("some/export-command/url")});it('shows "Show export command" link',function(){exportCommandDeferred.resolve({data:{command:"blah --foo"}});var element=renderTestTemplate(true);expect($('a:contains("Show export command")',element).length).toBe(1)});it("renders export command",function(){exportCommandDeferred.resolve({data:{command:"blah --foo"}});var element=renderTestTemplate(true);expect($('pre:contains("blah --foo")',
element).length).toBe(1)})})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.core.fileDownloadUtilsTest");goog.setTestOnly();var $jscomp$destructuring$var49=goog.require("grrUi.core.fileDownloadUtils");var getPathSpecFromValue=$jscomp$destructuring$var49.getPathSpecFromValue;var makeValueDownloadable=$jscomp$destructuring$var49.makeValueDownloadable;var pathSpecToAff4Path=$jscomp$destructuring$var49.pathSpecToAff4Path;describe("statEntryDirective.buildAff4Path",function(){it("converts os+tsk pathspec correctly",
function(){var pathspec={type:"PathSpec",value:{path:{value:"\\\\.\\Volume{1234}\\",type:"RDFString"},pathtype:{value:"OS",type:"EnumNamedValue"},mount_point:"/c:/",nested_path:{type:"PathSpec",value:{path:{value:"/windows",type:"RDFString"},pathtype:{value:"TSK",type:"EnumNamedValue"}}}}};expect(pathSpecToAff4Path(pathspec,"C.1234567812345678")).toBe("aff4:/C.1234567812345678/fs/tsk/\\\\.\\Volume{1234}\\/windows")});it("converts os+tsk ADS pathspec correctly",function(){var pathspec={type:"PathSpec",
value:{path:{value:"\\\\.\\Volume{1234}\\",type:"RDFString"},pathtype:{value:"OS",type:"EnumNamedValue"},mount_point:"/c:/",nested_path:{type:"PathSpec",value:{path:{value:"/Test Directory/notes.txt:ads",type:"RDFString"},pathtype:{value:"TSK",type:"EnumNamedValue"},inode:{value:66,type:"int"},ntfs_type:{value:128,type:"int"},ntfs_id:{value:2,type:"int"}}}}};expect(pathSpecToAff4Path(pathspec,"C.1234567812345678")).toBe("aff4:/C.1234567812345678/fs/tsk/\\\\.\\Volume{1234}\\/Test Directory/notes.txt:ads")})});
describe("fileDownloadUtils",function(){var artifactFilesDownloaderResult;var fileFinderResult;var pathspec;var rdfstring;var statEntry;beforeEach(function(){pathspec={value:{path:{type:"RDFString",value:"foo/bar"}},type:"Pathspec"};statEntry={value:{pathspec:pathspec},type:"StatEntry"};fileFinderResult={value:{stat_entry:angular.copy(statEntry)},type:"FileFinderResult"};artifactFilesDownloaderResult={value:{downloaded_file:angular.copy(statEntry)},type:"ArtifactFilesDownloaderResult"};rdfstring=
{value:"blah",type:"RDFString"}});describe("getPathSpecFromValue",function(){it("returns null if argument is null or undefined",function(){expect(getPathSpecFromValue(null)).toBe(null);expect(getPathSpecFromValue(undefined)).toBe(null)});it("extracts pathspec from StatEntry",function(){expect(getPathSpecFromValue(statEntry)).toEqual(pathspec)});it("extracts pathspec from FileFinderResult",function(){expect(getPathSpecFromValue(fileFinderResult)).toEqual(pathspec)});it("extracts pathspec from ArtifactFilesDownloaderResult",
function(){expect(getPathSpecFromValue(artifactFilesDownloaderResult)).toEqual(pathspec)});it("extracts pathspec recursively from ApiFlowResult",function(){var apiFlowResult={value:{payload:angular.copy(statEntry)},type:"ApiFlowResult"};expect(getPathSpecFromValue(apiFlowResult)).toEqual(pathspec);apiFlowResult={value:{payload:angular.copy(fileFinderResult)},type:"ApiFlowResult"};expect(getPathSpecFromValue(apiFlowResult)).toEqual(pathspec);apiFlowResult={value:{payload:angular.copy(artifactFilesDownloaderResult)},
type:"ApiFlowResult"};expect(getPathSpecFromValue(apiFlowResult)).toEqual(pathspec)});it("extracts pathspec recursively from ApiHuntResult",function(){var apiHuntResult={value:{payload:angular.copy(statEntry)},type:"ApiHuntResult"};expect(getPathSpecFromValue(apiHuntResult)).toEqual(pathspec);apiHuntResult={value:{payload:angular.copy(fileFinderResult)},type:"ApiHuntResult"};expect(getPathSpecFromValue(apiHuntResult)).toEqual(pathspec);apiHuntResult={value:{payload:angular.copy(artifactFilesDownloaderResult)},
type:"ApiHuntResult"};expect(getPathSpecFromValue(apiHuntResult)).toEqual(pathspec)});it("returns null for other aff4 types",function(){expect(getPathSpecFromValue(rdfstring)).toBe(null)});it("returns null for other types wrapped in ApiFlowResult",function(){var apiFlowResult={value:{payload:angular.copy(rdfstring)},type:"ApiFlowResult"};expect(getPathSpecFromValue(apiFlowResult)).toBe(null)});it("returns null for other types wrapped in ApiHuntResult",function(){var apiHuntResult={value:{payload:angular.copy(rdfstring)},
type:"ApiHuntResult"};expect(getPathSpecFromValue(apiHuntResult)).toBe(null)})});describe("makeValueDownloadable",function(){var downloadUrl="download/foo/bar";var downloadParams={foo:"bar",blah:"blah"};it("does nothing if argument is null or undefned",function(){expect(makeValueDownloadable(null,downloadUrl,downloadParams)).toBe(false);expect(makeValueDownloadable(undefined,downloadUrl,downloadParams)).toBe(false)});it("replaces aff4path in StatEntry",function(){var originalStatEntry=angular.copy(statEntry);
expect(makeValueDownloadable(statEntry,downloadUrl,downloadParams)).toBe(true);expect(statEntry).toEqual({downloadUrl:downloadUrl,downloadParams:downloadParams,originalValue:originalStatEntry,type:"__DownloadableStatEntry"})});it("replaces aff4path in FileFinderResult",function(){var originalFileFinderResult=angular.copy(fileFinderResult);expect(makeValueDownloadable(fileFinderResult,downloadUrl,downloadParams)).toBe(true);expect(fileFinderResult.value.stat_entry).toEqual({downloadUrl:downloadUrl,
downloadParams:downloadParams,originalValue:originalFileFinderResult.value.stat_entry,type:"__DownloadableStatEntry"})});it("replaces aff4path in ArtifactFilesDownloaderResult",function(){var original=angular.copy(artifactFilesDownloaderResult);expect(makeValueDownloadable(artifactFilesDownloaderResult,downloadUrl,downloadParams)).toBe(true);expect(artifactFilesDownloaderResult.value.downloaded_file).toEqual({downloadUrl:downloadUrl,downloadParams:downloadParams,originalValue:original.value.downloaded_file,
type:"__DownloadableStatEntry"})});it("replaces aff4path recursively in ApiFlowResult",function(){var apiFlowResult={value:{payload:angular.copy(statEntry)},type:"ApiFlowResult"};expect(makeValueDownloadable(apiFlowResult,downloadUrl,downloadParams)).toBe(true);expect(apiFlowResult.value.payload).toEqual({downloadUrl:downloadUrl,downloadParams:downloadParams,originalValue:statEntry,type:"__DownloadableStatEntry"})});it("replaces aff4path recursively in ApiHuntResult",function(){var apiHuntResult=
{value:{payload:angular.copy(statEntry)},type:"ApiHuntResult"};expect(makeValueDownloadable(apiHuntResult,downloadUrl,downloadParams)).toBe(true);expect(apiHuntResult.value.payload).toEqual({downloadUrl:downloadUrl,downloadParams:downloadParams,originalValue:statEntry,type:"__DownloadableStatEntry"})});it("does nothing in other aff4 types",function(){var original=angular.copy(rdfstring);expect(makeValueDownloadable(original,downloadUrl,downloadParams)).toBe(false)});it("does nothing for other types wrapped in ApiFlowResult",
function(){var apiFlowResult={value:{payload:angular.copy(rdfstring)},type:"ApiFlowResult"};expect(makeValueDownloadable(apiFlowResult,downloadUrl,downloadParams)).toBe(false)});it("does nothing for other types wrapped in ApiHuntResult",function(){var apiHuntResult={value:{payload:angular.copy(rdfstring)},type:"ApiHuntResult"};expect(makeValueDownloadable(apiHuntResult,downloadUrl,downloadParams)).toBe(false)})})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.core.firebaseServiceTest");goog.setTestOnly();var $jscomp$destructuring$var50=goog.require("grrUi.core.core");var coreModule=$jscomp$destructuring$var50.coreModule;window.firebase=window.firebase||{};describe("API service",function(){var $http;var $q;var $rootScope;var grrApiService;var grrFirebaseService;var fbAuthResult;var redirectDeferred;beforeEach(module(coreModule.name));beforeEach(inject(function($injector){$rootScope=$injector.get("$rootScope");
$http=$injector.get("$http");$q=$injector.get("$q");grrApiService=$injector.get("grrApiService");grrFirebaseService=$injector.get("grrFirebaseService");redirectDeferred=$q.defer();fbAuthResult={getRedirectResult:jasmine.createSpy("getRedirectResult").and.returnValue(redirectDeferred.promise),onAuthStateChanged:jasmine.createSpy("onAuthStateChanged"),signInWithRedirect:jasmine.createSpy("signInWithRedirect")};firebase={auth:jasmine.createSpy("auth").and.returnValue(fbAuthResult),apps:[{options:{authProvider:"GoogleAuthProvider"}}]};
firebase.auth.GoogleAuthProvider=jasmine.createSpy("GoogleAuthProvider")}));it("does nothing and marks auth done on no firebase apps",function(){firebase.apps=[];spyOn(grrApiService,"markAuthDone");grrFirebaseService.setupIfNeeded();$rootScope.$apply();expect(firebase.auth).not.toHaveBeenCalled();expect(grrApiService.markAuthDone).toHaveBeenCalled()});it("adjusts headers and marks auth done when user authenticates",function(){var tokenDeferred=$q.defer();tokenDeferred.resolve("blah");var user={getToken:jasmine.createSpy("getToken").and.returnValue(tokenDeferred.promise)};
fbAuthResult.onAuthStateChanged.and.callFake(function(fn){fn(user)});spyOn(grrApiService,"markAuthDone");grrFirebaseService.setupIfNeeded();$rootScope.$apply();expect(fbAuthResult.onAuthStateChanged).toHaveBeenCalled();expect(fbAuthResult.signInWithRedirect).not.toHaveBeenCalled();expect(grrApiService.markAuthDone).toHaveBeenCalled();expect($http.defaults.headers["common"]["Authorization"]).toBe("Bearer blah")});it("redirects to sign-in flow if the user is not authenticated",function(){fbAuthResult.onAuthStateChanged.and.callFake(function(fn){fn(undefined)});
spyOn(grrApiService,"markAuthDone");grrFirebaseService.setupIfNeeded();$rootScope.$apply();expect(fbAuthResult.onAuthStateChanged).toHaveBeenCalled();expect(fbAuthResult.signInWithRedirect).toHaveBeenCalled();expect(grrApiService.markAuthDone).not.toHaveBeenCalled()});it("marks auth done and does not redirect again on auth error",function(){var redirectDeferred=$q.defer();redirectDeferred.reject("blah");fbAuthResult.getRedirectResult.and.returnValue(redirectDeferred.promise);spyOn(grrApiService,"markAuthDone");
grrFirebaseService.setupIfNeeded();$rootScope.$apply();expect(grrApiService.markAuthDone).toHaveBeenCalled();expect(fbAuthResult.signInWithRedirect).not.toHaveBeenCalled()})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.core.forceRefreshDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var51=goog.require("grrUi.core.core");var coreModule=$jscomp$destructuring$var51.coreModule;var $jscomp$destructuring$var52=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var52.testsModule;describe("grr-force-refresh directive",function(){var $compile;var $rootScope;beforeEach(module(coreModule.name));beforeEach(module(testsModule.name));
beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");$rootScope.value=42}));var render=function(objectEquality){$rootScope.objectEquality=objectEquality;var template='<grr-force-refresh object-equality="objectEquality" '+'refresh-trigger="value">'+"{$ ::value $}</grr-force-refresh>";var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("shows transcluded template immediately",function(){var element=render();expect(element.text()).toContain("42")});
it("reloads children elements effectively updating one-time bindings",function(){var element=render();expect(element.text()).toContain("42");$rootScope.value=43;$rootScope.$apply();expect(element.text()).toContain("43")});it("reloads on object-level changes",function(){$rootScope.value={a:"a"};var element=render(true);expect(element.text()).toContain('{"a":"a"}');$rootScope.value["a"]="b";$rootScope.$apply();expect(element.text()).toContain('{"a":"b"}')})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.core.globalNotificationsDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var53=goog.require("grrUi.core.globalNotificationsDirective");var GlobalNotificationsDirective=$jscomp$destructuring$var53.GlobalNotificationsDirective;var $jscomp$destructuring$var54=goog.require("grrUi.tests");var browserTriggerEvent=$jscomp$destructuring$var54.browserTriggerEvent;var testsModule=$jscomp$destructuring$var54.testsModule;var $jscomp$destructuring$var55=
goog.require("grrUi.core.core");var coreModule=$jscomp$destructuring$var55.coreModule;describe("Global notifications directive",function(){var $compile;var $interval;var $q;var $rootScope;var grrApiService;var FETCH_INTERVAL=GlobalNotificationsDirective.fetch_interval;beforeEach(module("/static/angular-components/core/global-notifications.html"));beforeEach(module(coreModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$q=$injector.get("$q");$compile=$injector.get("$compile");
$rootScope=$injector.get("$rootScope");$interval=$injector.get("$interval");grrApiService=$injector.get("grrApiService")}));var render=function(){var template="<grr-global-notifications />";var element=$compile(template)($rootScope);$rootScope.$apply();return element};var mockApiServiceResponse=function(items){spyOn(grrApiService,"get").and.callFake(function(){return $q.when({data:{items:items}})})};it("fetches pending gobal notifications and displays them",function(){var items=[{"value":{"content":{"value":"Houston, Houston, we have a prob..."},
"header":{"value":"Oh no, we're doomed!"},"link":{"value":"http://www.google.com"},"type":{"value":"ERROR"}}}];mockApiServiceResponse(items);var element=render();$interval.flush(FETCH_INTERVAL);var url="users/me/notifications/pending/global";expect(grrApiService.get).toHaveBeenCalledWith(url);var alertElement=element.find(".alert.alert-error");expect(alertElement.length).toBe(1);expect(alertElement.find("h4").text().trim()).toBe("Oh no, we're doomed!");expect(alertElement.find("p").text().trim()).toBe("Houston, Houston, we have a prob...");
expect(alertElement.find('a[href="http://www.google.com"]').length).toBe(1)});it("shows all notifications if multiple are returned",function(){var items=[{"value":{"content":{"value":"Houston, Houston, we have a prob..."},"header":{"value":"Oh no, we're doomed!"},"link":{"value":"http://www.google.com"},"type":{"value":"ERROR"}}},{"value":{"content":{"value":"The word is nukular."},"header":{"value":"In case you didn't know!"},"type":{"value":"INFO"}}}];mockApiServiceResponse(items);var element=render();
$interval.flush(FETCH_INTERVAL);var url="users/me/notifications/pending/global";expect(grrApiService.get).toHaveBeenCalledWith(url);var errorAlertElement=element.find(".alert.alert-error");expect(errorAlertElement.length).toBe(1);var infoAlertElement=element.find(".alert.alert-info");expect(infoAlertElement.length).toBe(1);expect(infoAlertElement.find("a").length).toBe(0)});it("deletes a notification when the close button is clicked",function(){var items=[{"value":{"content":{"value":"The word is nukular."},
"header":{"value":"In case you didn't know!"},"type":{"value":"INFO"}}}];mockApiServiceResponse(items);spyOn(grrApiService,"delete");var element=render();$interval.flush(FETCH_INTERVAL);browserTriggerEvent(element.find("button.close"),"click");expect(grrApiService.delete).toHaveBeenCalledWith("users/me/notifications/pending/global/INFO")})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.core.hexNumberFilterTest");goog.setTestOnly();var $jscomp$destructuring$var56=goog.require("grrUi.core.hexNumberFilter");var HexNumberFilter=$jscomp$destructuring$var56.HexNumberFilter;var $jscomp$destructuring$var57=goog.require("grrUi.core.core");var coreModule=$jscomp$destructuring$var57.coreModule;var $jscomp$destructuring$var58=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var58.testsModule;describe("grrHexNumber filter",
function(){var grrHexNumberFilter;beforeEach(module(coreModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){grrHexNumberFilter=$injector.instantiate(HexNumberFilter)}));it("returns the correct hex for different input numbers",function(){var result=grrHexNumberFilter(0);expect(result).toBe("0x00000000");result=grrHexNumberFilter(255);expect(result).toBe("0x000000ff");result=grrHexNumberFilter(1010101);expect(result).toBe("0x000f69b5");result=grrHexNumberFilter(4294967296-
1);expect(result).toBe("0xffffffff")});it("inserts leading 0s to always return a multiple of eight places",function(){var result=grrHexNumberFilter(1);expect(result).toBe("0x00000001");result=grrHexNumberFilter(4294967296);expect(result).toBe("0x0000000100000000")})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.core.infiniteTableDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var59=goog.require("grrUi.core.infiniteTableDirective");var InfiniteTableController=$jscomp$destructuring$var59.InfiniteTableController;var $jscomp$destructuring$var60=goog.require("grrUi.core.memoryItemsProviderDirective");var MemoryItemsProviderController=$jscomp$destructuring$var60.MemoryItemsProviderController;var $jscomp$destructuring$var61=goog.require("grrUi.core.core");
var coreModule=$jscomp$destructuring$var61.coreModule;var $jscomp$destructuring$var62=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var62.testsModule;describe("infinite table",function(){var $compile;var $interval;var $q;var $rootScope;beforeEach(module(coreModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");$interval=$injector.get("$interval");$q=$injector.get("$q")}));
afterEach(function(){$(document.body).html("")});var render=function(items,noDomAppend,filterValue,withAutoRefresh){$rootScope.testItems=items;if(filterValue)$rootScope.filterValue=filterValue;var template="<div>"+"<table>"+"<tbody>"+"<tr grr-infinite-table grr-memory-items-provider "+'    items="testItems" page-size="5"'+(withAutoRefresh?'    auto-refresh-interval="1" ':"")+'    filter-value="filterValue"'+'    trigger-update="triggerUpdate">'+"  <td>{$ ::item.timestamp $}</td>"+"  <td>{$ ::item.message $}</td>"+
"</tr>"+"</tbody"+"</table>"+"</div>";var element=$compile(template)($rootScope);$rootScope.$apply();if(!noDomAppend){$("body").append(element);$interval.flush(1E3)}return element};it("throws if items provider is not specified",function(){var template="<table><tbody><tr grr-infinite-table />"+"</tbody></table>";var compiledTemplate=$compile(template);expect(function(){compiledTemplate($rootScope)}).toThrow(Error("Data provider not specified."))});it("shows empty table when there are no elements",
function(){var element=render([]);expect($("table",element).length).toBe(1);expect($("table tr",element).length).toBe(0)});it("shows 2 rows for 2 items",function(){var element=render([{timestamp:42,message:"foo"},{timestamp:43,message:"bar"}]);expect($("table",element).length).toBe(1);expect($("table tr",element).length).toBe(2);expect($("table tr:eq(0) td:eq(0):contains(42)",element).length).toBe(1);expect($("table tr:eq(0) td:eq(1):contains(foo)",element).length).toBe(1);expect($("table tr:eq(1) td:eq(0):contains(43)",
element).length).toBe(1);expect($("table tr:eq(1) td:eq(1):contains(bar)",element).length).toBe(1)});it('does nothing when "Loading..." row is not seen',function(){var element=render([{timestamp:42,message:"foo"},{timestamp:43,message:"bar"}],true);expect($("table",element).length).toBe(1);expect($("table tr",element).length).toBe(1);expect($('table tr:contains("Loading...")',element).length).toBe(1);$interval.flush(1E3);expect($("table tr",element).length).toBe(1);expect($('table tr:contains("Loading...")',
element).length).toBe(1);$("body").append(element);$interval.flush(1E3);expect($("table tr",element).length).toBe(2);expect($('table tr:contains("Loading...")',element).length).toBe(0);expect($("table tr:eq(0) td:eq(0):contains(42)",element).length).toBe(1);expect($("table tr:eq(0) td:eq(1):contains(foo)",element).length).toBe(1);expect($("table tr:eq(1) td:eq(0):contains(43)",element).length).toBe(1);expect($("table tr:eq(1) td:eq(1):contains(bar)",element).length).toBe(1)});it("applies the filter when a filter value is set",
function(){var element=render([{timestamp:42,message:"foo"},{timestamp:43,message:"bar"}],false,"foo");expect($("table",element).length).toBe(1);expect($("table tr",element).length).toBe(1);expect($("table tr:eq(0) td:eq(0):contains(42)",element).length).toBe(1);expect($("table tr:eq(0) td:eq(1):contains(foo)",element).length).toBe(1)});it("shows an empty table when the filter removes all items",function(){var element=render([{timestamp:42,message:"foo"},{timestamp:43,message:"bar"}],false,"xxx");
expect($("table",element).length).toBe(1);expect($("table tr",element).length).toBe(0)});it("cancels an in-flight request when trigger-update is called",function(){var deferred1=$q.defer();var deferred2=$q.defer();spyOn(MemoryItemsProviderController.prototype,"fetchItems").and.returnValues(deferred1.promise,deferred2.promise);var element=render([]);expect($("table tr",element).length).toBe(1);$rootScope.triggerUpdate();$interval.flush(1E3);deferred2.resolve({offset:0,items:[{timestamp:44,message:"foo2"},
{timestamp:45,message:"bar2"}]});$rootScope.$apply();deferred1.resolve({offset:0,items:[{timestamp:42,message:"foo1"},{timestamp:43,message:"bar1"}]});$rootScope.$apply();expect($('td:contains("foo2")',element).length).toBe(1);expect($('td:contains("bar2")',element).length).toBe(1);expect($('td:contains("bar1")',element).length).toBe(0);expect($('td:contains("bar1")',element).length).toBe(0)});describe("with auto refresh turned on",function(){var TABLE_KEY=InfiniteTableController.UNIQUE_KEY_NAME;
var ROW_HASH=InfiniteTableController.ROW_HASH_NAME;var transformItems=function(items){for(var i=0;i<items.length;++i){var item=items[i];item[TABLE_KEY]=item["message"];item[ROW_HASH]=item["timestamp"]}return items};it("adds new element to the beginning of the list",function(){var element=render(transformItems([{timestamp:42,message:"foo"},{timestamp:43,message:"bar"}]),undefined,undefined,true);expect($("table",element).length).toBe(1);expect($("table tr",element).length).toBe(2);$rootScope.testItems.push(transformItems([{timestamp:44,
message:"blah"}])[0]);$interval.flush(1E3);expect($("table tr",element).length).toBe(3);expect($("table tr:eq(0) td:eq(0):contains(44)",element).length).toBe(1);expect($("table tr:eq(0) td:eq(1):contains(blah)",element).length).toBe(1);$interval.flush(2E3);expect($("table tr",element).length).toBe(3);expect($("table tr:eq(0) td:eq(0):contains(44)",element).length).toBe(1);expect($("table tr:eq(0) td:eq(1):contains(blah)",element).length).toBe(1);expect($("table tr:eq(1) td:eq(0):contains(42)",element).length).toBe(1);
expect($("table tr:eq(1) td:eq(1):contains(foo)",element).length).toBe(1);expect($("table tr:eq(2) td:eq(0):contains(43)",element).length).toBe(1);expect($("table tr:eq(2) td:eq(1):contains(bar)",element).length).toBe(1)});it("adds multiple new elements in the right order",function(){var element=render([],undefined,undefined,true);expect($("table tr",element).length).toBe(0);Array.prototype.push.apply($rootScope.testItems,transformItems([{timestamp:42,message:"foo"},{timestamp:43,message:"bar"}]));
$interval.flush(1E3);expect($("table tr",element).length).toBe(2);expect($("table tr:eq(0) td:eq(1):contains(foo)",element).length).toBe(1);expect($("table tr:eq(1) td:eq(1):contains(bar)",element).length).toBe(1)});it("does nothing with the row if row hash has not changed",function(){var element=render(transformItems([{timestamp:42,message:"foo"},{timestamp:43,message:"bar"}]),undefined,undefined,true);expect($("table tr:eq(0) td:eq(0):contains(42)",element).length).toBe(1);$rootScope.testItems[0]["timestamp"]=
88;$interval.flush(2E3);expect($("table tr:eq(0) td:eq(0):contains(42)",element).length).toBe(1)});it("updates the row if row hash has changed",function(){var element=render(transformItems([{timestamp:42,message:"foo"},{timestamp:43,message:"bar"}]),undefined,undefined,true);expect($("table tr:eq(0) td:eq(0):contains(42)",element).length).toBe(1);$rootScope.testItems[0]["timestamp"]=88;transformItems($rootScope.testItems);$interval.flush(2E3);expect($("table tr:eq(0) td:eq(0):contains(88)",element).length).toBe(1)})})});
exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.core.loadingIndicatorDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var63=goog.require("grrUi.core.loadingIndicatorDirective");var LoadingIndicatorDirective=$jscomp$destructuring$var63.LoadingIndicatorDirective;var $jscomp$destructuring$var64=goog.require("grrUi.core.core");var coreModule=$jscomp$destructuring$var64.coreModule;var $jscomp$destructuring$var65=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var65.testsModule;
describe("loading indicator directive",function(){var LOADING_STARTED_EVENT_NAME=LoadingIndicatorDirective.loading_started_event_name;var LOADING_FINISHED_EVENT_NAME=LoadingIndicatorDirective.loading_finished_event_name;var $compile;var $rootScope;var $scope;beforeEach(module(coreModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");$scope=$rootScope.$new()}));var render=function(){var template=
"<grr-loading-indicator />";var element=$compile(template)($scope);$scope.$apply();return element};var isVisible=function(element){return!element.find(".ajax_spinner").hasClass("ng-hide")};var broadcast=function(event,key){$rootScope.$apply(function(){$rootScope.$broadcast(event,key)})};it("should be hidden by default",function(){var element=render();expect(isVisible(element)).toBe(false)});it("should turn visible once a loading started event is fired",function(){var element=render();expect(isVisible(element)).toBe(false);
broadcast(LOADING_STARTED_EVENT_NAME,"some key");expect(isVisible(element)).toBe(true)});it("should turn invisible once a corresponding loading finished event is fired",function(){var element=render();expect(isVisible(element)).toBe(false);broadcast(LOADING_STARTED_EVENT_NAME,"some key");expect(isVisible(element)).toBe(true);broadcast(LOADING_FINISHED_EVENT_NAME,"some key");expect(isVisible(element)).toBe(false)});it("should ignore unrelated loading finished events",function(){var element=render();
expect(isVisible(element)).toBe(false);broadcast(LOADING_STARTED_EVENT_NAME,"some key");expect(isVisible(element)).toBe(true);broadcast(LOADING_FINISHED_EVENT_NAME,"some other key");expect(isVisible(element)).toBe(true)});it("should turn invisible once all loading finished events occurred",function(){var element=render();expect(isVisible(element)).toBe(false);broadcast(LOADING_STARTED_EVENT_NAME,"some key");broadcast(LOADING_STARTED_EVENT_NAME,"some other key");broadcast(LOADING_STARTED_EVENT_NAME,
"one more key");expect(isVisible(element)).toBe(true);broadcast(LOADING_FINISHED_EVENT_NAME,"one more key");expect(isVisible(element)).toBe(true);broadcast(LOADING_FINISHED_EVENT_NAME,"some key");expect(isVisible(element)).toBe(true);broadcast(LOADING_FINISHED_EVENT_NAME,"some other key");expect(isVisible(element)).toBe(false)})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.core.markdownDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var66=goog.require("grrUi.core.core");var coreModule=$jscomp$destructuring$var66.coreModule;var $jscomp$destructuring$var67=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var67.testsModule;describe("markdown directive",function(){var $compile;var $rootScope;beforeEach(module(coreModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=
$injector.get("$compile");$rootScope=$injector.get("$rootScope")}));var renderTestTemplate=function(source){$rootScope.source=source;var template='<grr-markdown source="source"></grr-markdown>';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("renders markdown text",function(){var element=renderTestTemplate("*blah*");expect(element.html().trim()).toBe("<p><em>blah</em></p>")})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.core.memoryItemsProviderDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var68=goog.require("grrUi.core.memoryItemsProviderDirective");var MemoryItemsProviderController=$jscomp$destructuring$var68.MemoryItemsProviderController;describe("memory items provider directive",function(){var $rootScope;beforeEach(inject(function($injector){$rootScope=$injector.get("$rootScope")}));var getController=function(testItems){$rootScope.testItems=
testItems;var controller;inject(function($injector){controller=$injector.instantiate(MemoryItemsProviderController,{"$scope":$rootScope,"$attrs":{"items":"testItems"}})});$rootScope.$apply();return controller};it("fetches ranges of elements according to offset and count",function(){var controller=getController([0,1,2,3,4,5,6,7,8,9]);var items;controller.fetchItems(0,10).then(function(resultItems){items=resultItems});$rootScope.$apply();expect(items).toEqual({items:[0,1,2,3,4,5,6,7,8,9],offset:0});
controller.fetchItems(9,1).then(function(resultItems){items=resultItems});$rootScope.$apply();expect(items).toEqual({items:[9],offset:9});controller.fetchItems(9,2).then(function(resultItems){items=resultItems});$rootScope.$apply();expect(items).toEqual({items:[9],offset:9})});it("does not return total count when !opt_withTotalCount",function(){var controller=getController([0,1,2,3,4,5,6,7,8,9]);var items;controller.fetchItems(9,1).then(function(resultItems){items=resultItems});$rootScope.$apply();
expect(items.totalCount).toBeUndefined()});it("returns total count when opt_withTotalCount is true",function(){var controller=getController([0,1,2,3,4,5,6,7,8,9]);var items;controller.fetchItems(9,1,true).then(function(resultItems){items=resultItems});$rootScope.$apply();expect(items.totalCount).toEqual(10)});it("fetches ranges of filtered strings",function(){var controller=getController(["foo","bar","foobar","barfoo"]);var items;controller.fetchFilteredItems("foo",0,10).then(function(resultItems){items=
resultItems});$rootScope.$apply();expect(items).toEqual({items:["foo","foobar","barfoo"],offset:0});controller.fetchFilteredItems("foo",0,1).then(function(resultItems){items=resultItems});$rootScope.$apply();expect(items).toEqual({items:["foo"],offset:0});controller.fetchFilteredItems("foo",2,1).then(function(resultItems){items=resultItems});$rootScope.$apply();expect(items).toEqual({items:["barfoo"],offset:2})});it("ignores case when filtering strings",function(){var controller=getController(["FOO",
"Bar","fooBar","barfoo"]);var items;controller.fetchFilteredItems("foo",0,10).then(function(resultItems){items=resultItems});$rootScope.$apply();expect(items).toEqual({items:["FOO","fooBar","barfoo"],offset:0});controller.fetchFilteredItems("BAR",0,10).then(function(resultItems){items=resultItems});$rootScope.$apply();expect(items).toEqual({items:["Bar","fooBar","barfoo"],offset:0})});it("fetches ranges of filtered dictionaries",function(){var controller=getController([{message:"foo"},{message:"bar"},
{message:"foobar"},{message:"barfoo"}]);var items;controller.fetchFilteredItems("foo",0,10).then(function(resultItems){items=resultItems});$rootScope.$apply();expect(items).toEqual({items:[{message:"foo"},{message:"foobar"},{message:"barfoo"}],offset:0});controller.fetchFilteredItems("foo",0,1).then(function(resultItems){items=resultItems});$rootScope.$apply();expect(items).toEqual({items:[{message:"foo"}],offset:0});controller.fetchFilteredItems("foo",2,1).then(function(resultItems){items=resultItems});
$rootScope.$apply();expect(items).toEqual({items:[{message:"barfoo"}],offset:2})})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.core.pagedFilteredTableDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var69=goog.require("grrUi.core.memoryItemsProviderDirective");var MemoryItemsProviderController=$jscomp$destructuring$var69.MemoryItemsProviderController;var $jscomp$destructuring$var70=goog.require("grrUi.tests");var browserTriggerEvent=$jscomp$destructuring$var70.browserTriggerEvent;var testsModule=$jscomp$destructuring$var70.testsModule;var $jscomp$destructuring$var71=
goog.require("grrUi.core.core");var coreModule=$jscomp$destructuring$var71.coreModule;describe("paged filtered table",function(){var $compile;var $interval;var $q;var $rootScope;beforeEach(module("/static/angular-components/core/paged-filtered-table-top.html"));beforeEach(module("/static/angular-components/core/paged-filtered-table-bottom.html"));beforeEach(module(coreModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=
$injector.get("$rootScope");$q=$injector.get("$q");$interval=$injector.get("$interval")}));var render=function(items,withAutoRefresh){$rootScope.testItems=items;if(withAutoRefresh)$rootScope.autoRefreshInterval=1E3;var template="<div>"+"<table>"+"<tbody>"+"<tr grr-paged-filtered-table grr-memory-items-provider "+'items="testItems" page-size="5" '+'auto-refresh-interval="autoRefreshInterval">'+"<td>{$ item.timestamp $}</td>"+"<td>{$ item.message $}</td>"+"</tr>"+"</tbody"+"</table>"+"</div>";var element=
$compile(template)($rootScope);$rootScope.$apply();return element};it("throws if items provider is not specified",function(){var template="<div><table><tbody><tr grr-paged-filtered-table />"+"</tbody></table></div>";var compiledTemplate=$compile(template);expect(function(){compiledTemplate($rootScope)}).toThrow(Error("Data provider not specified."))});it("shows empty table when there are no elements",function(){var element=render([]);expect($("table",element).length).toBe(1);expect($("table tr",element).length).toBe(0)});
it("shows 2 rows for 2 items",function(){var element=render([{timestamp:42,message:"foo"},{timestamp:43,message:"bar"}]);expect($("table",element).length).toBe(1);expect($("table tr",element).length).toBe(2);expect(element.text()).toContain("2 entries");expect($("table tr:eq(0) td:eq(0):contains(42)",element).length).toBe(1);expect($("table tr:eq(0) td:eq(1):contains(foo)",element).length).toBe(1);expect($("table tr:eq(1) td:eq(0):contains(43)",element).length).toBe(1);expect($("table tr:eq(1) td:eq(1):contains(bar)",
element).length).toBe(1)});var checkItemsAreShown=function(itemsToCheck,element){angular.forEach(itemsToCheck,function(item){var foundElems=$("td:contains("+item.message+")",element);expect(foundElems.length).toBe(1)})};var checkItemsAreNotShown=function(itemsToCheck,element){angular.forEach(itemsToCheck,function(item){var foundElems=$("td:contains("+item.message+")",element);expect(foundElems.length).toBe(0)})};it("switches between pages correctly when there are 2 pages",function(){var items=[];
for(var i=0;i<10;++i)items.push({timestamp:i,message:"message_"+i.toString()});var element=render(items);checkItemsAreShown(items.slice(0,5),element);checkItemsAreNotShown(items.slice(5),element);browserTriggerEvent($("a:contains(Next)",element),"click");checkItemsAreNotShown(items.slice(0,5),element);checkItemsAreShown(items.slice(5),element);browserTriggerEvent($("a:contains(Previous)",element),"click");checkItemsAreShown(items.slice(0,5),element);checkItemsAreNotShown(items.slice(5),element)});
it("switches between pages correctly when there are 15 pages",function(){var items=[];for(var i=0;i<5*15;++i)items.push({timestamp:i,message:"message_"+i.toString()});var element=render(items);var $jscomp$loop$8={};$jscomp$loop$8.i$5=0;for(;$jscomp$loop$8.i$5<15;$jscomp$loop$8={i$5:$jscomp$loop$8.i$5},++$jscomp$loop$8.i$5){var pageLink=$("a",element).filter(function($jscomp$loop$8){return function(){return $(this).text()==($jscomp$loop$8.i$5+1).toString()}}($jscomp$loop$8));browserTriggerEvent(pageLink,
"click");checkItemsAreShown(items.slice($jscomp$loop$8.i$5*5,$jscomp$loop$8.i$5*5+5),element);if($jscomp$loop$8.i$5>0)checkItemsAreNotShown(items.slice(($jscomp$loop$8.i$5-1)*5,$jscomp$loop$8.i$5*5),element);if($jscomp$loop$8.i$5<14)checkItemsAreNotShown(items.slice(($jscomp$loop$8.i$5+1)*5,items.length),element)}});it("filters collection of 5 elements correctly",function(){var someItems=[{message:"some1"},{message:"some2"}];var otherItems=[{message:"other1"},{message:"other2"},{message:"other3"}];
var element=render(someItems.concat(otherItems));checkItemsAreShown(someItems,element);checkItemsAreShown(otherItems,element);$("input.search-query",element).val("some");browserTriggerEvent($("input.search-query",element),"input");browserTriggerEvent($("button:contains(Filter)",element),"click");expect(element.text()).toContain("Filtered by: some");checkItemsAreShown(someItems,element);checkItemsAreNotShown(otherItems,element);$("input.search-query",element).val("");browserTriggerEvent($("input.search-query",
element),"input");browserTriggerEvent($("button:contains(Filter)",element),"click");expect(element.text()).not.toContain("Filtered by");checkItemsAreShown(someItems,element);checkItemsAreShown(otherItems,element)});it('loads more filtered results when "Fetch More" is clicked',function(){var someItems=[{message:"some1"},{message:"some2"},{message:"some3"},{message:"some4"},{message:"some5"},{message:"some6"},{message:"some7"}];var otherItems=[{message:"other1"},{message:"other2"},{message:"other3"}];
var element=render(someItems.concat(otherItems));$("input.search-query",element).val("some");browserTriggerEvent($("input.search-query",element),"input");browserTriggerEvent($("button:contains(Filter)",element),"click");checkItemsAreShown(someItems.slice(0,5),element);checkItemsAreNotShown(someItems.slice(5),element);checkItemsAreNotShown(otherItems,element);browserTriggerEvent($('button:contains("Fetch More")',element),"click");checkItemsAreShown(someItems,element);checkItemsAreNotShown(otherItems,
element)});it('fetches 5 pages of filtered results when "Fetch 5" is clicked',function(){var someItems=[];for(var i=0;i<35;++i)someItems.push({message:"some_"+i.toString(36)});var otherItems=[];for(var i$6=0;i$6<20;++i$6)otherItems.push({message:"other"+i$6.toString(36)});var element=render(someItems.concat(otherItems));$("input.search-query",element).val("some");browserTriggerEvent($("input.search-query",element),"input");browserTriggerEvent($("button:contains(Filter)",element),"click");browserTriggerEvent($('a:contains("Fetch 25")',
element),"click");checkItemsAreShown(someItems.slice(0,30),element);checkItemsAreNotShown(someItems.slice(30,35),element);checkItemsAreNotShown(otherItems,element)});describe("with auto-refresh-interval set",function(){it("adds new element to the end of the list",function(){var someItems=[{message:"some1"},{message:"some2"}];var element=render(someItems,true);checkItemsAreShown(someItems,element);someItems.push({message:"some3"});$interval.flush(1E3);checkItemsAreShown(someItems,element)});it("updates total count",
function(){var someItems=[{message:"some1"},{message:"some2"}];var element=render(someItems,true);expect(element.text().indexOf("2 entries")!=-1).toBe(true);for(var i=0;i<5;++i)someItems.push({message:"somethingelse"});$interval.flush(1E3);expect(element.text().indexOf("7 entries")!=-1).toBe(true)});it("updates paging",function(){var someItems=[{message:"some1"},{message:"some2"}];var element=render(someItems,true);expect(element.find('ul.pagination li:contains("2")').length).toBe(0);for(var i=0;i<
5;++i)someItems.push({message:"somethingelse"});$interval.flush(1E3);expect(element.find('ul.pagination li:contains("2")').length).toBe(1)});it("does not auto-update in filtered mode",function(){var someItems=[{message:"some1"},{message:"some2"}];var element=render(someItems,true);$("input.search-query",element).val("some");browserTriggerEvent($("input.search-query",element),"input");browserTriggerEvent($("button:contains(Filter)",element),"click");checkItemsAreShown(someItems,element);someItems.push({message:"some3"});
$interval.flush(1E3);checkItemsAreShown(someItems.slice(0,2),element);checkItemsAreNotShown(someItems.slice(2,3),element)});it("does not auto-update if full page is shown",function(){var someItems=[{message:"some1"},{message:"some2"},{message:"some3"},{message:"some4"},{message:"some5"}];var element=render(someItems,true);checkItemsAreShown(someItems,element);someItems[0]={message:"someother"};someItems.push({message:"some6"});$interval.flush(1E3);checkItemsAreShown(someItems.slice(1,5),element);
checkItemsAreNotShown(someItems.slice(0,1),element);checkItemsAreNotShown(someItems.slice(5,6),element)});it("skips results of the obsolete request if page is changed",function(){var someItems=[{message:"some1"},{message:"some2"},{message:"some3"},{message:"some4"},{message:"some5"},{message:"some6"}];var element=render(someItems,true);browserTriggerEvent($("a:contains(Next)",element),"click");checkItemsAreShown(someItems.slice(5),element);var deferred1=$q.defer();var deferred2=$q.defer();spyOn(MemoryItemsProviderController.prototype,
"fetchItems").and.returnValue(deferred1.promise).and.returnValue(deferred2.promise);$interval.flush(1E3);browserTriggerEvent($("a:contains(Previous)",element),"click");deferred2.resolve({items:someItems.slice(0,5)});$rootScope.$apply();checkItemsAreShown(someItems.slice(0,5),element);deferred1.resolve({items:someItems.slice(5,6)});$rootScope.$apply();checkItemsAreShown(someItems.slice(0,5),element);checkItemsAreNotShown(someItems.slice(5,6),element)});it("does not start auto-update request if one is in progress",
function(){var someItems=[{message:"some1"}];render(someItems,true);var deferred=$q.defer();spyOn(MemoryItemsProviderController.prototype,"fetchItems").and.returnValue(deferred.promise);$interval.flush(1E3);$interval.flush(1E3);expect(MemoryItemsProviderController.prototype.fetchItems).toHaveBeenCalledTimes(1)})})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.core.periodicRefreshDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var72=goog.require("grrUi.core.core");var coreModule=$jscomp$destructuring$var72.coreModule;var $jscomp$destructuring$var73=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var73.testsModule;describe("grr-periodic-refresh directive",function(){var $compile;var $interval;var $rootScope;beforeEach(module(coreModule.name));beforeEach(module(testsModule.name));
beforeEach(inject(function($injector){$compile=$injector.get("$compile");$interval=$injector.get("$interval");$rootScope=$injector.get("$rootScope")}));it("reloads children elements effectively updating one-time bindings",function(){$rootScope.value=42;var template='<grr-periodic-refresh interval="1000">'+"{$ ::value $}</grr-periodic-refresh>";var element=$compile(template)($rootScope);$rootScope.$apply();expect(element.text()).toContain("42");$rootScope.value=43;$rootScope.$apply();expect(element.text()).toContain("42");
$interval.flush(1001);expect(element.text()).toContain("43")});it("calls a callback on timer",function(){$rootScope.callback=jasmine.createSpy("callback");var template='<grr-periodic-refresh interval="1000" '+'on-refresh="callback()"></grr-periodic-refresh>';$compile(template)($rootScope);$rootScope.$apply();expect($rootScope.callback).not.toHaveBeenCalled();$interval.flush(1001);expect($rootScope.callback).toHaveBeenCalled()})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.core.reflectionServiceTest");goog.setTestOnly();var $jscomp$destructuring$var74=goog.require("grrUi.core.reflectionService");var ReflectionService=$jscomp$destructuring$var74.ReflectionService;var $jscomp$destructuring$var75=goog.require("grrUi.core.core");var coreModule=$jscomp$destructuring$var75.coreModule;var $jscomp$destructuring$var76=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var76.testsModule;describe("AFF4 items provider directive",
function(){var $q;var $rootScope;var grrApiServiceMock;var grrReflectionService;beforeEach(module(coreModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$rootScope=$injector.get("$rootScope");$q=$injector.get("$q");grrApiServiceMock={get:function(){}};grrReflectionService=$injector.instantiate(ReflectionService,{"grrApiService":grrApiServiceMock})}));it("fetches data from the server only once",function(){var deferred=$q.defer();spyOn(grrApiServiceMock,"get").and.returnValue(deferred.promise);
grrReflectionService.getRDFValueDescriptor("Duration");grrReflectionService.getRDFValueDescriptor("RDFDatetime");expect(grrApiServiceMock.get.calls.count()).toBe(1)});it("queues requests until the data are fetched",function(){var deferred=$q.defer();spyOn(grrApiServiceMock,"get").and.returnValue(deferred.promise);var responses=[];grrReflectionService.getRDFValueDescriptor("Duration").then(function(response){responses.push(response)});grrReflectionService.getRDFValueDescriptor("RDFDatetime").then(function(response){responses.push(response)});
expect(responses.length).toBe(0);deferred.resolve({data:{items:[{"doc":"Duration value stored in seconds internally.","kind":"primitive","name":"Duration"},{"doc":"Date and time.","kind":"primitive","name":"RDFDatetime"}]}});$rootScope.$apply();expect(responses.length).toBe(2);expect(responses[0]).toEqual({"doc":"Duration value stored in seconds internally.","kind":"primitive","name":"Duration"});expect(responses[1]).toEqual({"doc":"Date and time.","kind":"primitive","name":"RDFDatetime"})});it("returns data with dependencies if opt_withDeps is true",
function(){var deferred=$q.defer();deferred.resolve({data:{items:[{"doc":"Sample struct.","kind":"struct","name":"Struct","fields":[{"type":"RDFInteger"}]},{"doc":"Sample integer.","kind":"primitive","name":"RDFInteger"}]}});spyOn(grrApiServiceMock,"get").and.returnValue(deferred.promise);var descriptors;grrReflectionService.getRDFValueDescriptor("Struct",true).then(function(response){descriptors=response});$rootScope.$apply();expect(descriptors["Struct"]).toBeDefined();expect(descriptors["RDFInteger"]).toBeDefined()})});
exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.core.searchBoxDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var77=goog.require("grrUi.tests");var browserTriggerEvent=$jscomp$destructuring$var77.browserTriggerEvent;var stubUiTrait=$jscomp$destructuring$var77.stubUiTrait;var testsModule=$jscomp$destructuring$var77.testsModule;var $jscomp$destructuring$var78=goog.require("grrUi.core.core");var coreModule=$jscomp$destructuring$var78.coreModule;describe("search box directive",
function(){var $compile;var $q;var $rootScope;var $scope;var grrApiService;var grrRoutingService;beforeEach(module("/static/angular-components/core/search-box.html"));beforeEach(module(coreModule.name));beforeEach(module(testsModule.name));stubUiTrait("search_clients_action_enabled");beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");$scope=$rootScope.$new();$q=$injector.get("$q");grrApiService=$injector.get("grrApiService");grrRoutingService=
$injector.get("grrRoutingService")}));var render=function(){var template="<grr-search-box />";var element=$compile(template)($scope);$scope.$apply();return element};var mockApiServiceResponse=function(results){results=results||{};spyOn(grrApiService,"get").and.callFake(function(apiPath,params){var value=results[apiPath];if(value)return $q.resolve({data:value});else return $q.reject("Invalid")})};var triggerSearch=function(element,query){$("input",element).val(query).trigger("input");browserTriggerEvent($("input",
element),"change");browserTriggerEvent($("button",element),"click")};var triggerSearchByKeyboard=function(element,query){element.find("input").val(query).trigger("input");$scope.$apply();var event=jQuery.Event("keypress");event.which=13;element.find("input").trigger(event)};it("should invoke client search on arbitrary input",function(){mockApiServiceResponse();spyOn(grrRoutingService,"go");var element=render();triggerSearch(element,"test query");expect(grrApiService.get).toHaveBeenCalledWith("/clients/labels");
expect(grrRoutingService.go).toHaveBeenCalledWith("search",{q:"test query"})});it("should invoke client search on ENTER in input",function(){mockApiServiceResponse();spyOn(grrRoutingService,"go");var element=render();triggerSearchByKeyboard(element,"test query");expect(grrApiService.get).toHaveBeenCalledWith("/clients/labels");expect(grrRoutingService.go).toHaveBeenCalledWith("search",{q:"test query"})});it("should request hunt details if a hunt id is detected",function(){mockApiServiceResponse();
var element=render();triggerSearch(element,"H:12345678");expect(grrApiService.get).toHaveBeenCalledWith("hunts/H:12345678")});it("should forward to the hunt details if a hunt was found",function(){mockApiServiceResponse({"hunts/H:12345678":{value:{hunt_id:{value:"H:12345678"}}}});spyOn(grrRoutingService,"go");var element=render();triggerSearch(element,"H:12345678");expect(grrApiService.get).toHaveBeenCalledWith("hunts/H:12345678");expect(grrRoutingService.go).toHaveBeenCalledWith("hunts",{huntId:"H:12345678"})});
it("should fall back to regular client search if no hunt was found",function(){mockApiServiceResponse();spyOn(grrRoutingService,"go");var element=render();triggerSearch(element,"H:12345678");expect(grrApiService.get).toHaveBeenCalledWith("hunts/H:12345678");expect(grrRoutingService.go).toHaveBeenCalledWith("search",{q:"H:12345678"})});it("should check that potential hunt ids cannot start with search keywords",function(){mockApiServiceResponse();spyOn(grrRoutingService,"go");var element=render();triggerSearch(element,
"HOST:12345678");triggerSearch(element,"FQDN:12345678");triggerSearch(element,"MAC:12345678");triggerSearch(element,"IP:12345678");triggerSearch(element,"USER:12345678");triggerSearch(element,"LABEL:12345678");expect(grrRoutingService.go).not.toHaveBeenCalledWith("hunts",{huntId:"HOST:12345678"});expect(grrRoutingService.go).not.toHaveBeenCalledWith("hunts",{huntId:"FQDN:12345678"});expect(grrRoutingService.go).not.toHaveBeenCalledWith("hunts",{huntId:"MAC:12345678"});expect(grrRoutingService.go).not.toHaveBeenCalledWith("hunts",
{huntId:"IP:12345678"});expect(grrRoutingService.go).not.toHaveBeenCalledWith("hunts",{huntId:"USER:12345678"});expect(grrRoutingService.go).not.toHaveBeenCalledWith("hunts",{huntId:"LABEL:12345678"});expect(grrRoutingService.go).toHaveBeenCalledWith("search",{q:"HOST:12345678"});expect(grrRoutingService.go).toHaveBeenCalledWith("search",{q:"FQDN:12345678"});expect(grrRoutingService.go).toHaveBeenCalledWith("search",{q:"MAC:12345678"});expect(grrRoutingService.go).toHaveBeenCalledWith("search",{q:"IP:12345678"});
expect(grrRoutingService.go).toHaveBeenCalledWith("search",{q:"USER:12345678"});expect(grrRoutingService.go).toHaveBeenCalledWith("search",{q:"LABEL:12345678"})})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.core.semanticRegistryServiceTest");goog.setTestOnly();var $jscomp$destructuring$var79=goog.require("grrUi.core.semanticRegistryService");var SemanticRegistryService=$jscomp$destructuring$var79.SemanticRegistryService;var $jscomp$destructuring$var80=goog.require("grrUi.core.core");var coreModule=$jscomp$destructuring$var80.coreModule;describe("Semantic registry",function(){var $q;var $rootScope;var grrReflectionService;var testRegistry;
beforeEach(module(coreModule.name));beforeEach(inject(function($injector){$rootScope=$injector.get("$rootScope");$q=$injector.get("$q");grrReflectionService=$injector.get("grrReflectionService");testRegistry=$injector.instantiate(SemanticRegistryService,{})}));describe("findDirectiveForMro",function(){it("finds previously registered directive",function(){testRegistry.registerDirective("SomeType",Object);var foundDirective=testRegistry.findDirectiveForMro(["SomeType"]);expect(foundDirective).toBe(Object)});
it("returns undefined when searching for not registered directive",function(){var foundDirective=testRegistry.findDirectiveForMro(["SomeType"]);expect(foundDirective).toBeUndefined()});it("returns more specific directive when multiple directives match",function(){var directive1=Object();var directive2=Object();testRegistry.registerDirective("SomeChildType",directive1);testRegistry.registerDirective("SomeParentType",directive2);var foundDirective=testRegistry.findDirectiveForMro(["SomeChildType","SomeParentType"]);
expect(foundDirective).toBe(directive1)});it("respects override for a type without directive",function(){var someDirective=Object();var foundDirective=testRegistry.findDirectiveForMro(["SomeType"],{"SomeType":someDirective});expect(foundDirective).toBe(someDirective)});it("respects override for a single and only MRO type",function(){var someDirective=Object();var directiveOverride=Object();testRegistry.registerDirective("SomeType",someDirective);var foundDirective=testRegistry.findDirectiveForMro(["SomeType"],
{"SomeType":directiveOverride});expect(foundDirective).toBe(directiveOverride)});it("respects override for a non-leaf MRO type",function(){var someDirective=Object();var directiveOverride=Object();testRegistry.registerDirective("SomeParentType",someDirective);var foundDirective=testRegistry.findDirectiveForMro(["SomeChildType","SomeParentType"],{"SomeParentType":directiveOverride});expect(foundDirective).toBe(directiveOverride)});it("respects override for a leaf MRO type",function(){var directive1=
Object();var directive2=Object();testRegistry.registerDirective("SomeChildType",directive1);testRegistry.registerDirective("SomeParentType",directive2);var directiveOverride=Object();var foundDirective=testRegistry.findDirectiveForMro(["SomeChildType","SomeParentType"],{"SomeChildType":directiveOverride});expect(foundDirective).toBe(directiveOverride)})});describe("findDirectiveByType",function(){it("returns registered directive without using reflection",function(done){testRegistry.registerDirective("SomeType",
Object);var promise=testRegistry.findDirectiveForType("SomeType");promise.then(function(value){expect(value).toBe(Object);done()});$rootScope.$apply()});it("returns overridden directive without using reflection",function(done){var someDirective=Object();var directiveOverride=Object();testRegistry.registerDirective("SomeType",someDirective);var promise=testRegistry.findDirectiveForType("SomeType",{"SomeType":directiveOverride});promise.then(function(value){expect(value).toBe(directiveOverride);done()});
$rootScope.$apply()});it("queries reflection service for MRO if type unregistered",function(done){testRegistry.registerDirective("SomeParentType",Object);var deferred=$q.defer();deferred.resolve({mro:["SomeChildType","SomeParentType"]});grrReflectionService.getRDFValueDescriptor=jasmine.createSpy("getRDFValueDescriptor").and.returnValue(deferred.promise);var promise=testRegistry.findDirectiveForType("SomeChildType");promise.then(function(value){expect(grrReflectionService.getRDFValueDescriptor).toHaveBeenCalled();
expect(value).toBe(Object);done()});$rootScope.$apply()});it("respects overrides for parent types",function(){var someDirective=Object();var directiveOverride=Object();testRegistry.registerDirective("SomeParentType",someDirective);var deferred=$q.defer();deferred.resolve({mro:["SomeChildType","SomeParentType"]});grrReflectionService.getRDFValueDescriptor=jasmine.createSpy("getRDFValueDescriptor").and.returnValue(deferred.promise);var promise=testRegistry.findDirectiveForType("SomeChildType",{"SomeParentType":directiveOverride});
promise.then(function(value){expect(grrReflectionService.getRDFValueDescriptor).toHaveBeenCalled();expect(value).toBe(directiveOverride);done()});$rootScope.$apply()})})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.core.serverErrorButtonDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var81=goog.require("grrUi.core.serverErrorButtonDirective");var ServerErrorButtonDirective=$jscomp$destructuring$var81.ServerErrorButtonDirective;var $jscomp$destructuring$var82=goog.require("grrUi.core.core");var coreModule=$jscomp$destructuring$var82.coreModule;var $jscomp$destructuring$var83=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var83.testsModule;
describe("server error button directive",function(){var ERROR_EVENT_NAME=ServerErrorButtonDirective.error_event_name;var $compile;var $rootScope;var $scope;beforeEach(module("/static/angular-components/core/server-error-button.html"));beforeEach(module(coreModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");$scope=$rootScope.$new()}));var render=function(){var template="<grr-server-error-button />";
var element=$compile(template)($scope);$scope.$apply();return element};var isVisible=function(element){return!element.hasClass("ng-hide")};it("should be hidden by default",function(){var element=render();expect(isVisible(element)).toBe(false)});it("should turn visible once a non-empty server error event is fired",function(){var element=render();expect(isVisible(element)).toBe(false);$scope.$apply(function(){$rootScope.$broadcast(ERROR_EVENT_NAME,{message:"some event value"})});expect(isVisible(element)).toBe(true)});
it("should ignore empty server error events",function(){var element=render();expect(isVisible(element)).toBe(false);$scope.$apply(function(){$rootScope.$broadcast(ERROR_EVENT_NAME)});expect(isVisible(element)).toBe(false)})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.core.serverErrorDialogDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var84=goog.require("grrUi.tests");var browserTriggerEvent=$jscomp$destructuring$var84.browserTriggerEvent;var testsModule=$jscomp$destructuring$var84.testsModule;var $jscomp$destructuring$var85=goog.require("grrUi.core.core");var coreModule=$jscomp$destructuring$var85.coreModule;describe("server error dialog directive",function(){var $compile;var $rootScope;
var $scope;beforeEach(module("/static/angular-components/core/server-error-dialog.html"));beforeEach(module(coreModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");$scope=$rootScope.$new()}));var render=function(message,traceBack){$scope.close=function(){};$scope.message=message;$scope.traceBack=traceBack;var template='<grr-server-error-dialog close="close()" message="message" trace-back="traceBack" />';
var element=$compile(template)($scope);$scope.$apply();return element};it("should show a basic error message and traceback",function(){var message="Some error message";var traceBack="Some trace back";var element=render(message,traceBack);expect(element.find(".modal-header h3").text()).toBe(message);expect(element.find(".modal-body pre").text()).toBe(traceBack)});it("should operate on empty input",function(){var message="";var traceBack="";var element=render(message,traceBack);expect(element.find(".modal-header h3").text()).toBe(message);
expect(element.find(".modal-body pre").text()).toBe(traceBack)});it("should call scope.close when clicking the X",function(){var message="...";var traceBack="...";var element=render(message,traceBack);spyOn($scope,"close");browserTriggerEvent(element.find(".modal-header button"),"click");expect($scope.close).toHaveBeenCalled()});it("should call scope.close when clicking the close button",function(){var message="...";var traceBack="...";var element=render(message,traceBack);spyOn($scope,"close");browserTriggerEvent(element.find(".modal-footer button"),
"click");expect($scope.close).toHaveBeenCalled()})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.core.serverErrorPreviewDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var86=goog.require("grrUi.core.serverErrorButtonDirective");var ServerErrorButtonDirective=$jscomp$destructuring$var86.ServerErrorButtonDirective;var $jscomp$destructuring$var87=goog.require("grrUi.core.core");var coreModule=$jscomp$destructuring$var87.coreModule;var $jscomp$destructuring$var88=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var88.testsModule;
describe("server error preview directive",function(){var ERROR_EVENT_NAME=ServerErrorButtonDirective.error_event_name;var $compile;var $rootScope;var $scope;beforeEach(module(coreModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");$scope=$rootScope.$new()}));var render=function(){var template="<grr-server-error-preview />";var element=$compile(template)($scope);$scope.$apply();return element};
var isVisible=function(element){return!element.hasClass("ng-hide")};it("should be hidden by default",function(){var element=render();expect(isVisible(element)).toBe(false)});it("should show error message once a non-empty server error event is fired",function(){var errorMessage="some event value";var element=render();expect(isVisible(element)).toBe(false);$scope.$apply(function(){$rootScope.$broadcast(ERROR_EVENT_NAME,{message:errorMessage})});expect(isVisible(element)).toBe(true);expect(element.text().trim()).toBe(errorMessage)});
it("should ignore empty server error events",function(){var element=render();expect(isVisible(element)).toBe(false);$scope.$apply(function(){$rootScope.$broadcast(ERROR_EVENT_NAME)});expect(isVisible(element)).toBe(false)})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.core.timeSinceFilterTest");goog.setTestOnly();var $jscomp$destructuring$var89=goog.require("grrUi.core.timeSinceFilter");var TimeSinceFilter=$jscomp$destructuring$var89.TimeSinceFilter;var $jscomp$destructuring$var90=goog.require("grrUi.client.client");var clientModule=$jscomp$destructuring$var90.clientModule;var $jscomp$destructuring$var91=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var91.testsModule;describe("grrTimeSince filter",
function(){var grrTimeSinceFilter;var referenceTime=5*60*60*24*1E6;beforeEach(module(clientModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){grrTimeSinceFilter=$injector.instantiate(TimeSinceFilter,{"grrTimeService":{"getCurrentTimeMs":function(){return referenceTime/1E3}}})}));it("returns seconds when value is 42 seconds ago",function(){var result=grrTimeSinceFilter(referenceTime-42*1E6);expect(result).toBe("42 seconds ago")});it("returns hours when value is 3 hours ago",
function(){var result=grrTimeSinceFilter(referenceTime-(60*60*3+42)*1E6);expect(result).toBe("3 hours ago")});it("returns days when value is 3 days ago",function(){var result=grrTimeSinceFilter(referenceTime-(60*60*24*3+42)*1E6);expect(result).toBe("3 days ago")});it("returns seconds when value is 42 seconds in the future",function(){var result=grrTimeSinceFilter(referenceTime+42*1E6);expect(result).toBe("in 42 seconds")});it("returns hours when value is 3 hours in the future",function(){var result=
grrTimeSinceFilter(referenceTime+(60*60*3+42)*1E6);expect(result).toBe("in 3 hours")});it("returns days when value is 3 days in the future",function(){var result=grrTimeSinceFilter(referenceTime+(60*60*24*3+42)*1E6);expect(result).toBe("in 3 days")});it("returns error message when value is 0",function(){var result=grrTimeSinceFilter(0);expect(result).toBe("<invalid time value>")})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.core.timestampFilterTest");goog.setTestOnly();var $jscomp$destructuring$var92=goog.require("grrUi.core.timestampFilter");var TimestampFilter=$jscomp$destructuring$var92.TimestampFilter;var $jscomp$destructuring$var93=goog.require("grrUi.core.core");var coreModule=$jscomp$destructuring$var93.coreModule;var $jscomp$destructuring$var94=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var94.testsModule;describe("grrTimestamp filter",
function(){var MICRO_IN_MILLI=1E3;var MILLI_IN_UNIT=1E3;var SECONDS=MICRO_IN_MILLI*MILLI_IN_UNIT;var MINUTES=60*SECONDS;var grrTimestampFilter;beforeEach(module(coreModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){grrTimestampFilter=$injector.instantiate(TimestampFilter)}));it("returns reference date on 0",function(){var result=grrTimestampFilter(0);expect(result).toBe("1970-01-01 00:00:00 UTC")});it("returns correct value for seconds",function(){var result=
grrTimestampFilter(42*SECONDS);expect(result).toBe("1970-01-01 00:00:42 UTC")});it("returns correct value for minutes",function(){var result=grrTimestampFilter(10*MINUTES+42*SECONDS);expect(result).toBe("1970-01-01 00:10:42 UTC")})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.core.troggleDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var95=goog.require("grrUi.core.troggleDirective");var TroggleDirective=$jscomp$destructuring$var95.TroggleDirective;var TroggleState=$jscomp$destructuring$var95.TroggleState;var $jscomp$destructuring$var96=goog.require("grrUi.core.core");var coreModule=$jscomp$destructuring$var96.coreModule;describe("Troggle",function(){var $compile;var $rootScope;beforeEach(module(TroggleDirective().templateUrl));
beforeEach(module(coreModule.name));beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope")}));var render=function(state){var template='<grr-troggle ng-model="state" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("correctly renders `VOID` state",function(){$rootScope.state=TroggleState.VOID;var element=render();expect(element.text().trim()).toBe("_")});it("correctly renders `SET` state",function(){$rootScope.state=
TroggleState.SET;var element=render();expect(element.text().trim()).toBe("\u2713")});it("correctly renders `UNSET` state",function(){$rootScope.state=TroggleState.UNSET;var element=render();expect(element.text().trim()).toBe("\u2715")});it("changes states when clicked",function(){$rootScope.state=TroggleState.VOID;var element=render();element.find(":first-child").click();expect(element.text().trim()).toBe("\u2713");expect($rootScope.state).toBe(TroggleState.SET);element.find(":first-child").click();
expect(element.text().trim()).toBe("\u2715");expect($rootScope.state).toBe(TroggleState.UNSET);element.find(":first-child").click();expect(element.text().trim()).toBe("_");expect($rootScope.state).toBe(TroggleState.VOID)})});return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.core.utilsTest");goog.setTestOnly();var $jscomp$destructuring$var97=goog.require("grrUi.core.utils");var camelCaseToDashDelimited=$jscomp$destructuring$var97.camelCaseToDashDelimited;var getLastPathComponent=$jscomp$destructuring$var97.getLastPathComponent;var stringToList=$jscomp$destructuring$var97.stringToList;describe("core utils",function(){describe("camelCaseToDashDelimited",function(){it("returns a dash delimited string on camel case input",
function(){var result=camelCaseToDashDelimited("someTestInput");expect(result).toBe("some-test-input")});it("replaces spaces with dashes",function(){var result=camelCaseToDashDelimited("some string with spaces");expect(result).toBe("some-string-with-spaces")});it("handles non-word characters by substitution with dash",function(){var result=camelCaseToDashDelimited("some string with $ symbols");expect(result).toBe("some-string-with-symbols")});it("handles uppercase abbreviations correctly",function(){var result=
camelCaseToDashDelimited("someDDirectiveName");expect(result).toBe("some-d-directive-name");result=camelCaseToDashDelimited("someDDDirectiveName");expect(result).toBe("some-d-d-directive-name")});it("handles string beginning with uppercase characters correctly",function(){var result=camelCaseToDashDelimited("SOMEUppercaseString");expect(result).toBe("s-o-m-e-uppercase-string")})});describe("stringToList",function(){it("returns empty list for empty string",function(){var result=stringToList("");expect(result).toEqual([])});
it("splits 3 items correctly",function(){var result=stringToList("a, b, c");expect(result).toEqual(["a","b","c"])});it("trims spaces from elements",function(){var result=stringToList("a  , b  ,c ");expect(result).toEqual(["a","b","c"])})});describe("getLastPathComponent",function(){it("returns empty string for an empty string",function(){expect(getLastPathComponent("")).toBe("")});it("returns correct last component",function(){expect(getLastPathComponent("foo")).toBe("foo");expect(getLastPathComponent("foo/bar")).toBe("bar");
expect(getLastPathComponent("foo/bar/blah")).toBe("blah")})})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.core.versionDropdownDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var98=goog.require("grrUi.core.versionDropdownDirective");var VersionDropdownDirective=$jscomp$destructuring$var98.VersionDropdownDirective;var $jscomp$destructuring$var99=goog.require("grrUi.core.core");var coreModule=$jscomp$destructuring$var99.coreModule;var $jscomp$destructuring$var100=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var100.testsModule;
describe("version dropdown directive",function(){var $compile;var $q;var $rootScope;var $scope;var grrApiService;var REFRESH_VERSIONS_EVENT=VersionDropdownDirective.REFRESH_VERSIONS_EVENT;beforeEach(module("/static/angular-components/core/version-dropdown.html"));beforeEach(module(coreModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");$q=$injector.get("$q");grrApiService=$injector.get("grrApiService");
$scope=$rootScope.$new()}));var render=function(url,version){$scope.url=url;$scope.version={data:version};var template='<grr-version-dropdown url="url" version="version.data" />';var element=$compile(template)($scope);$scope.$apply();return element};var mockApiService=function(responses){spyOn(grrApiService,"get").and.callFake(function(path){var response={times:responses[path]};return $q.when({data:response})})};it("shows HEAD as the first element in the versions list",function(){mockApiService({"some/url":[{value:10}]});
var element=render("some/url");expect(element.find("option").length).toBe(2);expect(element.find("option:nth(0)").val()).toBe("HEAD")});it("selects HEAD if not version specified",function(){mockApiService({"some/url":[{value:10}]});var element=render("some/url");expect(element.find("option[selected]").val()).toBe("HEAD")});it("should show all versions from server and select the passed one",function(){mockApiService({"some/url":[{value:10},{value:42},{value:50}]});var element=render("some/url",42);
expect(element.find("option").length).toBe(4);expect(element.find("option[selected]").val()).toBe("42");expect($scope.version.data).toBe(42)});it("should show add current version to the server versions list",function(){mockApiService({"some/url":[{value:10},{value:41},{value:50}]});var element=render("some/url",42);expect(element.find("option").length).toBe(5);expect(element.find("option[selected]").val()).toBe("42");expect($scope.version.data).toBe(42)});it("shows hint when a version other than the latest is shown",
function(){mockApiService({"some/url":[{value:10},{value:42},{value:50}]});var element=render("some/url",42);expect(element.find(".newer-version-hint").length).toBe(1)});it("does not show a hint when a newest version  is shown",function(){mockApiService({"some/url":[{value:10},{value:42},{value:50}]});var element=render("some/url",50);expect(element.find(".newer-version-hint").length).toBe(0)});it("should update the selected option on scope value change",function(){mockApiService({"some/url":[{value:10},
{value:42},{value:50}]});var element=render("some/url",42);expect(element.find("option").length).toBe(4);expect(element.find("option[selected]").val()).toBe("42");expect($scope.version.data).toBe(42);$scope.version.data=50;$scope.$apply();expect(element.find("option").length).toBe(4);expect(element.find("option[selected]").val()).toBe("50");$scope.version.data=99;$scope.$apply();expect(element.find("option").length).toBe(5);expect(element.find("option[selected]").val()).toBe("99")});it("should be disabled when no options are available",
function(){mockApiService({"some/url":[]});var element=render("some/url",42);expect(element.find("select[disabled]").length).toBe(1);expect(element.find("option[selected]").text().trim()).toBe("No versions available.");expect($scope.version.data).toBe(42)});it("should fetch versions again when a REFRESH_VERSIONS_EVENT is broadcasted",function(){var items=[];mockApiService({"some/url":items});var element=render("some/url");expect(element.find("select[disabled]").length).toBe(1);expect(element.find("option[selected]").text().trim()).toBe("No versions available.");
items.push({value:10});items.push({value:42});$rootScope.$broadcast(REFRESH_VERSIONS_EVENT,{});$rootScope.$apply();expect(element.find("select[disabled]").length).toBe(0);expect(element.find("option").length).toBe(3);expect(element.find("option[selected]").val()).toBe("HEAD");expect($scope.version.data).toBeUndefined()})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.core.wizardFormDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var101=goog.require("grrUi.tests");var browserTriggerEvent=$jscomp$destructuring$var101.browserTriggerEvent;var testsModule=$jscomp$destructuring$var101.testsModule;var $jscomp$destructuring$var102=goog.require("grrUi.core.core");var coreModule=$jscomp$destructuring$var102.coreModule;describe("grr-wizard-form directive",function(){var $compile;var $rootScope;
beforeEach(module("/static/angular-components/core/wizard-form.html"));beforeEach(module("/static/angular-components/core/wizard-form-page.html"));beforeEach(module(coreModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope")}));var renderTestTemplate=function(template){if(angular.isUndefined(template))template='<grr-wizard-form title="Test wizard form" '+'on-resolve="resolved = true" on-reject="rejected = true">'+
'<grr-wizard-form-page title="Page 1" next-button-label="go on!">'+"foo</grr-wizard-form-page>"+'<grr-wizard-form-page title="Page 2" prev-button-label="go back!">'+"bar</grr-wizard-form-page>"+"</grr-wizard-form>";var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("shows first page by default",function(){var element=renderTestTemplate();expect(element.text()).toContain("Page 1");expect(element.text()).not.toContain("Page 2")});it('clicking on "Next" button shows next page',
function(){var element=renderTestTemplate();browserTriggerEvent(element.find("button.Next"),"click");expect(element.text()).toContain("Page 2");expect(element.text()).not.toContain("Page 1")});it('clicking on "Back" button shows previous page',function(){var element=renderTestTemplate();browserTriggerEvent(element.find("button.Next"),"click");browserTriggerEvent(element.find("button.Back"),"click");expect(element.text()).toContain("Page 1");expect(element.text()).not.toContain("Page 2")});it('hides "Back" button on the first page',
function(){var element=renderTestTemplate();expect(element.find("button.Back[disabled]").length).toBe(0)});it('shows "Back" button on the second page',function(){var element=renderTestTemplate();browserTriggerEvent(element.find("button.Next"),"click");expect(element.find("button.Back[disabled]").length).toBe(0)});it('hides "Back" button if page\'s noBackButton is true',function(){var element=renderTestTemplate("<grr-wizard-form>"+'<grr-wizard-form-page title="Page 1">foo</grr-wizard-form-page>'+'<grr-wizard-form-page title="Page 2" no-back-button="flag">bar'+
"</grr-wizard-form-page>"+"</grr-wizard-form>");browserTriggerEvent(element.find("button.Next"),"click");expect(element.find("button.Back").length).toBe(1);$rootScope.flag=true;$rootScope.$apply();expect(element.find("button.Back").length).toBe(0)});it('disables "Next" button if current page reports as invalid',function(){var element=renderTestTemplate("<grr-wizard-form>"+'<grr-wizard-form-page title="Page 1" is-valid="flag">foo'+"</grr-wizard-form-page>"+"</grr-wizard-form>");expect(element.find("button.Next[disabled]").length).toBe(1);
$rootScope.flag=true;$rootScope.$apply();expect(element.find("button.Next:not([disabled])").length).toBe(1)});it('takes "Back" button label from page settings',function(){var element=renderTestTemplate();browserTriggerEvent(element.find("button.Next"),"click");expect(element.find("button.Back").text().trim()).toBe("go back!")});it('takes "Next" button label from page settings',function(){var element=renderTestTemplate();expect(element.find("button.Next").text().trim()).toBe("go on!")});it('calls "on-resolve" when "Next" is clicked on last page',
function(){var element=renderTestTemplate();expect($rootScope.resolved).toBeUndefined();browserTriggerEvent(element.find("button.Next"),"click");expect($rootScope.resolved).toBeUndefined();browserTriggerEvent(element.find("button.Next"),"click");expect($rootScope.resolved).toBe(true)});it('calls "on-reject" when "x" is clicked',function(){var element=renderTestTemplate();expect($rootScope.rejected).toBeUndefined();browserTriggerEvent(element.find("button.close"),"click");expect($rootScope.rejected).toBe(true)})});
exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.docs.apiHelperCurlServiceTest");goog.setTestOnly();var $jscomp$destructuring$var103=goog.require("grrUi.docs.docs");var docsModule=$jscomp$destructuring$var103.docsModule;describe("ApiHelperCurlService",function(){var $rootScope;var grrApiHelperCurlService;beforeEach(module(docsModule.name));beforeEach(module(function($provide){$provide.value("$window",{location:{origin:"http://localhost:42"}})}));beforeEach(inject(function($injector){$rootScope=
$injector.get("$rootScope");grrApiHelperCurlService=$injector.get("grrApiHelperCurlService")}));var startFlowRequest='CSRFTOKEN=`curl http://localhost:42 -o /dev/null -s -c - | grep csrftoken  | cut -f 7`; \\\n\tcurl -X POST -H "Content-Type: application/json" -H "X-CSRFToken: $CSRFTOKEN" \\\n\thttp://localhost:42/api/v2/clients/C.1111222233334444/flows -d @- << EOF\n{\n  "foo": "bar"\n}\nEOF';it("builds start flow request",function(done){grrApiHelperCurlService.buildStartFlow("C.1111222233334444",
{foo:"bar"}).then(function(cmd){expect(cmd).toBe(startFlowRequest);done()}.bind(this));$rootScope.$apply()})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.docs.apiHelperServiceTest");goog.setTestOnly();var $jscomp$destructuring$var104=goog.require("grrUi.docs.docs");var docsModule=$jscomp$destructuring$var104.docsModule;describe("ApiHelperService",function(){var $q;var $rootScope;var grrApiHelperService;var grrApiService;beforeEach(module(docsModule.name));beforeEach(inject(function($injector){$rootScope=$injector.get("$rootScope");$q=$injector.get("$q");grrApiService=$injector.get("grrApiService");
grrApiHelperService=$injector.get("grrApiHelperService");var deferred=$q.defer();deferred.resolve({data:{value:{type:"RDFString",value:"FooBarAuthManager"}}});spyOn(grrApiService,"getCached").and.returnValue(deferred.promise);grrApiHelperService.clear()}));var fooHelper={buildStartFlow:function(clientId,createFlowJson){var deferred=$q.defer();deferred.resolve("foo start "+clientId);return deferred.promise}};var barHelper={buildStartFlow:function(clientId,createFlowJson){var deferred=$q.defer();deferred.resolve("bar start "+
clientId);return deferred.promise}};it("builds start flow commands with helpers of all types",function(done){grrApiHelperService.registerHelper("Foo",null,fooHelper);grrApiHelperService.registerHelper("Bar",null,barHelper);grrApiHelperService.buildStartFlow("C.1111222233334444",{foo:"bar"}).then(function(result){expect(result).toEqual({"Foo":{webAuthType:null,data:"foo start C.1111222233334444"},"Bar":{webAuthType:null,data:"bar start C.1111222233334444"}});done()});$rootScope.$apply()});it("uses helper with a matching webAuthType, if available",
function(done){grrApiHelperService.registerHelper("Foo",null,fooHelper);grrApiHelperService.registerHelper("Foo","FooBarAuthManager",barHelper);grrApiHelperService.buildStartFlow("C.1111222233334444",{foo:"bar"}).then(function(result){expect(result).toEqual({"Foo":{webAuthType:"FooBarAuthManager",data:"bar start C.1111222233334444"}});done()});$rootScope.$apply()});it("uses helper with null webAuthType if no matches",function(done){grrApiHelperService.registerHelper("Foo",null,fooHelper);grrApiHelperService.registerHelper("Foo",
"SomeOtherAuthManager",barHelper);grrApiHelperService.buildStartFlow("C.1111222233334444",{foo:"bar"}).then(function(result){expect(result).toEqual({"Foo":{webAuthType:null,data:"foo start C.1111222233334444"}});done()});$rootScope.$apply()});it("ignores helpers if no matches and no helper with null webAuthType",function(done){grrApiHelperService.registerHelper("Foo","YetAnotherAuthManager",fooHelper);grrApiHelperService.registerHelper("Foo","SomeOtherAuthManager",barHelper);grrApiHelperService.buildStartFlow("C.1111222233334444",
{foo:"bar"}).then(function(result){expect(result).toEqual({});done()});$rootScope.$apply()})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.flow.copyFlowFormDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var105=goog.require("grrUi.flow.flow");var flowModule=$jscomp$destructuring$var105.flowModule;var $jscomp$destructuring$var106=goog.require("grrUi.tests");var stubDirective=$jscomp$destructuring$var106.stubDirective;var stubTranscludeDirective=$jscomp$destructuring$var106.stubTranscludeDirective;var testsModule=$jscomp$destructuring$var106.testsModule;describe("copy flow form directive",
function(){var $compile;var $q;var $rootScope;var grrApiService;var flowObject;beforeEach(module("/static/angular-components/flow/copy-flow-form.html"));beforeEach(module(flowModule.name));beforeEach(module(testsModule.name));stubDirective("grrFlowForm");stubTranscludeDirective("grrConfirmationDialog");beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");$q=$injector.get("$q");grrApiService=$injector.get("grrApiService");flowObject={type:"ApiFlow",
value:{args:{type:"FooFlowArgs",value:{aFoo:"aBar"}},runner_args:{type:"FlowRunnerArgs",value:{rFoo:"rBar"}}}};var deferred=$q.defer();deferred.resolve({data:flowObject});spyOn(grrApiService,"get").and.returnValue(deferred.promise)}));var renderTestTemplate=function(){$rootScope.clientId="C.0000111122223333";$rootScope.flowId="F:123456";var template="<grr-copy-flow-form "+'client-id="clientId" flow-id="flowId" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("fetches existing flow with correct client id and flow id",
function(){renderTestTemplate();expect(grrApiService.get).toHaveBeenCalledWith("clients/C.0000111122223333/flows/F:123456")});it("sends correct request when grr-confirmation-dialog triggers proceed",function(){var element=renderTestTemplate();var directive=element.find("grr-confirmation-dialog");var deferred=$q.defer();spyOn(grrApiService,"post").and.returnValue(deferred.promise);directive.scope().$eval(directive.attr("proceed"));expect(grrApiService.post).toHaveBeenCalledWith("clients/C.0000111122223333/flows",
{flow:{args:{aFoo:"aBar"},runner_args:{rFoo:"rBar"}},original_flow:{flow_id:"F:123456",client_id:"C.0000111122223333"}})})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.flow.flowDescriptorsTreeDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var107=goog.require("grrUi.tests");var browserTriggerEvent=$jscomp$destructuring$var107.browserTriggerEvent;var testsModule=$jscomp$destructuring$var107.testsModule;var $jscomp$destructuring$var108=goog.require("grrUi.flow.flow");var flowModule=$jscomp$destructuring$var108.flowModule;describe("flow descriptors tree directive",function(){var $compile;
var $q;var $rootScope;var grrApiService;var emptySettingsDeferred;beforeEach(module(flowModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");$q=$injector.get("$q");grrApiService=$injector.get("grrApiService");emptySettingsDeferred=$q.defer();emptySettingsDeferred.resolve({data:{value:{settings:{value:{}}}}})}));afterEach(function(){$(document.body).html("")});var renderTestTemplate=function(){var template=
"<grr-flow-descriptors-tree "+'selected-descriptor="selectedDescriptor.value" />';var element=$compile(template)($rootScope);$rootScope.selectedDescriptor={value:undefined};$rootScope.$apply();$(document.body).html("");$(document.body).append(element);$(element.children("div.tree")[0]).on("loaded.jstree",function(e,data){$(this).jstree("open_all")});return element};it("fetches descriptors from the server",function(){var deferred=$q.defer();spyOn(grrApiService,"get").and.returnValue(deferred.promise);
renderTestTemplate();expect(grrApiService.get).toHaveBeenCalledWith("/flows/descriptors")});it("fetches user settings from the server",function(){var deferred=$q.defer();spyOn(grrApiService,"get").and.returnValue(deferred.promise);renderTestTemplate();expect(grrApiService.get).toHaveBeenCalledWith("/users/me")});it("creates node per category",function(done){var deferred=$q.defer();spyOn(grrApiService,"get").and.callFake(function(url){if(url=="/users/me")return emptySettingsDeferred.promise;else return deferred.promise});
deferred.resolve({data:{items:[{type:"ApiFlowDescriptor",value:{category:{type:"RDFString",value:"Category foo"},name:{type:"RDFString",value:"foo"},friendly_name:{type:"RDFString",value:"friendly foo"},behaviours:[{type:"RDFString",value:"BASIC"}]}},{type:"ApiFlowDescriptor",value:{category:{type:"RDFString",value:"Category bar"},name:{type:"RDFString",value:"bar"},friendly_name:{type:"RDFString",value:"friendly bar"},behaviours:[{type:"RDFString",value:"BASIC"}]}}]}});var element=renderTestTemplate();
element.bind("DOMNodeInserted",function(e){if(element.text().indexOf("Category foo")!=-1&&element.text().indexOf("Category bar")!=-1)done()})});it("uses friendly name if available",function(done){var deferred=$q.defer();spyOn(grrApiService,"get").and.callFake(function(url){if(url=="/users/me")return emptySettingsDeferred.promise;else return deferred.promise});deferred.resolve({data:{items:[{type:"ApiFlowDescriptor",value:{category:{type:"RDFString",value:"Category foo"},name:{type:"RDFString",value:"foo"},
friendly_name:{type:"RDFString",value:"friendly foo"},behaviours:[{type:"RDFString",value:"BASIC"}]}}]}});var element=renderTestTemplate();element.bind("DOMNodeInserted",function(e){if(element.text().indexOf("friendly foo")!=-1)done()})});it("hides flows without specified behavior",function(done){var advancedSettingsDeferred=$q.defer();advancedSettingsDeferred.resolve({data:{value:{settings:{value:{mode:{value:"ADVANCED"}}}}}});var deferred=$q.defer();deferred.resolve({data:{items:[{type:"ApiFlowDescriptor",
value:{category:{type:"RDFString",value:"Category foo"},name:{type:"RDFString",value:"foo"},friendly_name:{type:"RDFString",value:"friendly foo"},behaviours:[{type:"RDFString",value:"BASIC"}]}},{type:"ApiFlowDescriptor",value:{category:{type:"RDFString",value:"Category bar"},name:{type:"RDFString",value:"bar"},friendly_name:{type:"RDFString",value:"friendly bar"},behaviours:[{type:"RDFString",value:"ADVANCED"}]}}]}});spyOn(grrApiService,"get").and.callFake(function(url){if(url=="/users/me")return advancedSettingsDeferred.promise;
else return deferred.promise});var element=renderTestTemplate();element.bind("DOMNodeInserted",function(e){if(element.text().indexOf("friendly bar")!=-1&&element.text().indexOf("friendly foo")==-1)done()})});describe("when clicked",function(){var element;beforeEach(function(done){var deferred=$q.defer();spyOn(grrApiService,"get").and.callFake(function(url){if(url=="/users/me")return emptySettingsDeferred.promise;else return deferred.promise});deferred.resolve({data:{items:[{type:"ApiFlowDescriptor",
value:{category:{type:"RDFString",value:"Category 1"},name:{type:"RDFString",value:"foo"},friendly_name:{type:"RDFString",value:"friendly foo"},behaviours:[{type:"RDFString",value:"BASIC"}]}}]}});element=renderTestTemplate();element.bind("DOMNodeInserted",function(e){if(element.text().indexOf("friendly foo")!=-1)done()})});it("updates selectedDescriptor binding",function(){expect($rootScope.selectedDescriptor.value).toBeUndefined();browserTriggerEvent(element.find('a:contains("Category 1")'),"click");
browserTriggerEvent(element.find('a:contains("friendly foo")'),"click");$rootScope.$apply();expect($rootScope.selectedDescriptor.value).toEqual({type:"ApiFlowDescriptor",value:{category:{type:"RDFString",value:"Category 1"},name:{type:"RDFString",value:"foo"},friendly_name:{type:"RDFString",value:"friendly foo"},behaviours:[{type:"RDFString",value:"BASIC"}]}})})})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.flow.flowFormDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var109=goog.require("grrUi.flow.flow");var flowModule=$jscomp$destructuring$var109.flowModule;var $jscomp$destructuring$var110=goog.require("grrUi.tests");var stubDirective=$jscomp$destructuring$var110.stubDirective;var testsModule=$jscomp$destructuring$var110.testsModule;describe("flow form directive",function(){var $compile;var $q;var $rootScope;var grrReflectionService;
beforeEach(module("/static/angular-components/flow/flow-form.html"));beforeEach(module(flowModule.name));beforeEach(module(testsModule.name));angular.forEach(["grrFormValue","grrFormProtoRepeatedField"],function(directiveName){stubDirective(directiveName)});beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");$q=$injector.get("$q");grrReflectionService=$injector.get("grrReflectionService");spyOn(grrReflectionService,"getRDFValueDescriptor").and.callFake(function(valueType){var deferred=
$q.defer();if(valueType=="FlowRunnerArgs")deferred.resolve({default:{type:"FlowRunnerArgs",value:{}},fields:[{name:"output_plugins",default:[],foo:"bar"}]});else if(valueType=="OutputPluginDescriptor")deferred.resolve({default:{type:"OutputPluginDescriptor",value:"OutputPluginDescriptor-default",foo:"bar"}});return deferred.promise})}));var renderTestTemplate=function(args,runnerArgs,withOutputPlugins){$rootScope.clientId="C.0000111122223333";$rootScope.args=args||{type:"FooFlowArgs",value:{foo:"bar"}};
$rootScope.runnerArgs=runnerArgs||{type:"FlowRunnerArgs",value:{flow_name:{type:"RDFString",value:"FooFlow"}}};if(angular.isUndefined(withOutputPlugins))withOutputPlugins=true;$rootScope.withOutputPlugins=withOutputPlugins;var template="<grr-flow-form "+'flow-args="args" flow-runner-args="runnerArgs" '+'with-output-plugins="withOutputPlugins" '+'has-errors="hasErrors" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("shows flow arguments form",function(){var element=
renderTestTemplate();var directive=element.find("grr-form-value:nth(0)");expect(directive.scope().$eval(directive.attr("value"))).toEqual($rootScope.args)});it("shows flow runner arguments form",function(){var element=renderTestTemplate();var directive=element.find("grr-form-value:nth(1)");var expected=angular.copy($rootScope.runnerArgs);expected["value"]["output_plugins"]=[];expect(directive.scope().$eval(directive.attr("value"))).toEqual(expected)});it("preserves existing output plugins list",function(){var runnerArgs=
{type:"FlowRunnerArgs",value:{flow_name:{type:"RDFString",value:"FooFlow"},output_plugins:[{type:"FooPluginArgs",value:{}}]}};var element=renderTestTemplate(undefined,angular.copy(runnerArgs));var directive=element.find("grr-form-value:nth(1)");expect(directive.scope().$eval(directive.attr("value"))).toEqual(runnerArgs)});it("does not show output plugins if with-output-plugns=false",function(){var element=renderTestTemplate(undefined,undefined,false);var directive=element.find("grr-form-value:nth(1)");
expect(directive.scope().$eval(directive.attr("value"))).toEqual(angular.copy($rootScope.runnerArgs));var pluginsDirective=element.find("grr-form-proto-repeated-field");expect(pluginsDirective.length).toBe(0)});it("shows output plugins list form",function(){var element=renderTestTemplate();var directive=element.find("grr-form-proto-repeated-field");expect(directive.scope().$eval(directive.attr("descriptor"))).toEqual({default:{type:"OutputPluginDescriptor",value:"OutputPluginDescriptor-default",foo:"bar"}});
expect(directive.scope().$eval(directive.attr("field"))).toEqual({name:"output_plugins",default:[],foo:"bar"});expect(directive.scope().$eval(directive.attr("value"))).toEqual([])});it("updates has-errors binding if flow arguments are invalid",function(){renderTestTemplate();expect($rootScope.hasErrors).toBe(false);$rootScope.args["validationError"]="Oh no!";$rootScope.$apply();expect($rootScope.hasErrors).toBe(true)});it("updates has-errors binding if runner arguments are invalid",function(){renderTestTemplate();
expect($rootScope.hasErrors).toBe(false);$rootScope.runnerArgs["validationError"]="Oh no!";$rootScope.$apply();expect($rootScope.hasErrors).toBe(true)})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.flow.flowResultsDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var111=goog.require("grrUi.flow.flow");var flowModule=$jscomp$destructuring$var111.flowModule;var $jscomp$destructuring$var112=goog.require("grrUi.tests");var stubDirective=$jscomp$destructuring$var112.stubDirective;var testsModule=$jscomp$destructuring$var112.testsModule;describe("flow results directive",function(){var $compile;var $rootScope;beforeEach(module("/static/angular-components/flow/flow-results.html"));
beforeEach(module(flowModule.name));beforeEach(module(testsModule.name));stubDirective("grrResultsCollection");beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope")}));var renderTestTemplate=function(flowId){$rootScope.flowId=flowId;$rootScope.apiBasePath="foo/bar";var template='<grr-flow-results flow-id="flowId" '+'api-base-path="apiBasePath" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("delegates rendering to grr-results-collection directive",
function(){var element=renderTestTemplate("F:1234");var directive=element.find("grr-results-collection:nth(0)");expect(directive.length).toBe(1)});it("builds grr-result-collection urls correctly",function(){var element=renderTestTemplate("F:1234");var directive=element.find("grr-results-collection:nth(0)");expect(directive.scope().$eval(directive.attr("results-url"))).toEqual("foo/bar/F:1234/results");expect(directive.scope().$eval(directive.attr("output-plugins-url"))).toEqual("foo/bar/F:1234/output-plugins");
expect(directive.scope().$eval(directive.attr("download-files-url"))).toEqual("foo/bar/F:1234/results/files-archive")})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.flow.flowStatusIconDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var113=goog.require("grrUi.flow.flow");var flowModule=$jscomp$destructuring$var113.flowModule;var $jscomp$destructuring$var114=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var114.testsModule;describe("grr-flow-status-icon directive",function(){var $compile;var $rootScope;beforeEach(module("/static/angular-components/flow/flow-status-icon.html"));
beforeEach(module(flowModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope")}));var renderTestTemplate=function(state){$rootScope.flow={type:"ApiFlow",value:{state:{type:"EnumNamedValue",value:state}}};var template='<grr-flow-status-icon flow="flow" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("shows an image for 4 possible flow states",function(){var states=
["TERMINATED","RUNNING","ERROR","CLIENT_CRASHED"];angular.forEach(states,function(state){var element=renderTestTemplate(state);expect($("img",element).length).toBe(1)})})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.flow.flowsListDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var115=goog.require("grrUi.flow.flowsListDirective");var flattenFlowsList=$jscomp$destructuring$var115.flattenFlowsList;var toggleFlowExpansion=$jscomp$destructuring$var115.toggleFlowExpansion;describe("grr-flows-list directive",function(){describe("flattenFlowsList()",function(){it("assigns zero depth when flows have no nested_flows",function(){var source=[{value:{foo:1}},
{value:{foo:2}},{value:{foo:3}}];expect(flattenFlowsList(source)).toEqual([{value:{foo:1},depth:0},{value:{foo:2},depth:0},{value:{foo:3},depth:0}])});it("assigns depths correctly for flows with nested_flows",function(){var source=[{value:{foo:1}},{value:{foo:2,nested_flows:[{value:{foo:21}},{value:{foo:22,nested_flows:[{value:{foo:223}},{value:{foo:224}}]}}]}},{foo:3}];expect(flattenFlowsList(source)).toEqual([{value:{foo:1},depth:0},{value:{foo:2},depth:0},{value:{foo:21},depth:1},{value:{foo:22},
depth:1},{value:{foo:223},depth:2},{value:{foo:224},depth:2},{foo:3,depth:0}])})});describe("toggleFlowExpansion()",function(){it("expands node with 2 children correctly",function(){var source=[{value:{foo:2},depth:0,shown:true},{value:{foo:21},depth:1,shown:false},{value:{foo:22},depth:1,shown:false}];expect(toggleFlowExpansion(source,0)).toEqual([{value:{foo:2},depth:0,shown:true,expanded:true},{value:{foo:21},depth:1,shown:true},{value:{foo:22},depth:1,shown:true}])});it("does not show adjacent items",
function(){var source=[{value:{foo:2},depth:0,shown:true},{value:{foo:21},depth:1,shown:false},{value:{foo:3},depth:0,shown:false}];expect(toggleFlowExpansion(source,0)).toEqual([{value:{foo:2},depth:0,shown:true,expanded:true},{value:{foo:21},depth:1,shown:true},{value:{foo:3},depth:0,shown:false}])});it("collapses node with 2 children correctly",function(){var source=[{value:{foo:2},depth:0,shown:true,expanded:true},{value:{foo:21},depth:1,shown:true},{value:{foo:22},depth:1,shown:true}];expect(toggleFlowExpansion(source,
0)).toEqual([{value:{foo:2},depth:0,shown:true,expanded:false},{value:{foo:21},depth:1,shown:false},{value:{foo:22},depth:1,shown:false}])});it("recursively shows expanded children",function(){var source=[{value:{foo:2},depth:0,shown:true,expanded:false},{value:{foo:21},depth:1,shown:false},{value:{foo:22},depth:1,shown:false,expanded:true},{value:{foo:223},depth:2,shown:false},{value:{foo:224},depth:2,shown:false}];expect(toggleFlowExpansion(source,0)).toEqual([{value:{foo:2},depth:0,shown:true,
expanded:true},{value:{foo:21},depth:1,shown:true},{value:{foo:22},depth:1,shown:true,expanded:true},{value:{foo:223},depth:2,shown:true},{value:{foo:224},depth:2,shown:true}])});it("does not recursively show collapsed children",function(){var source=[{value:{foo:2},depth:0,shown:true,expanded:false},{value:{foo:21},depth:1,shown:false},{value:{foo:22},depth:1,shown:false,expanded:false},{value:{foo:223},depth:2,shown:false},{value:{foo:224},depth:2,shown:false}];expect(toggleFlowExpansion(source,
0)).toEqual([{value:{foo:2},depth:0,shown:true,expanded:true},{value:{foo:21},depth:1,shown:true},{value:{foo:22},depth:1,shown:true,expanded:false},{value:{foo:223},depth:2,shown:false},{value:{foo:224},depth:2,shown:false}])})})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.flow.startFlowFormDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var116=goog.require("grrUi.tests");var browserTriggerEvent=$jscomp$destructuring$var116.browserTriggerEvent;var stubDirective=$jscomp$destructuring$var116.stubDirective;var testsModule=$jscomp$destructuring$var116.testsModule;var $jscomp$destructuring$var117=goog.require("grrUi.flow.flow");var flowModule=$jscomp$destructuring$var117.flowModule;describe("start flow form directive",
function(){var $compile;var $q;var $rootScope;var grrApiService;var grrReflectionService;var flowRunnerArgsDefault;beforeEach(module("/static/angular-components/flow/start-flow-form.html"));beforeEach(module(flowModule.name));beforeEach(module(testsModule.name));angular.forEach(["grrFlowForm","grrSemanticValue"],function(directiveName){stubDirective(directiveName)});beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");$q=$injector.get("$q");
grrApiService=$injector.get("grrApiService");grrReflectionService=$injector.get("grrReflectionService");flowRunnerArgsDefault={type:"FlowRunnerArgs",value:{flow_name:{type:"RDFString",value:"FooFlow"},output_plugins:[{foo:"bar"}],foo:"bar"}};var deferred=$q.defer();deferred.resolve({default:flowRunnerArgsDefault});spyOn(grrReflectionService,"getRDFValueDescriptor").and.returnValue(deferred.promise)}));var renderTestTemplate=function(){$rootScope.clientId="C.0000111122223333";$rootScope.descriptor=
{type:"ApiFlowDescriptor",value:{name:{type:"RDFString",value:"FooFlow"},default_args:{type:"FooFlowArgs",value:{foo:"bar"}}}};var template="<grr-start-flow-form "+'client-id="clientId" descriptor="descriptor" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("shows flow arguments form",function(){var element=renderTestTemplate();var directive=element.find("grr-flow-form");expect(directive.scope().$eval(directive.attr("flow-args"))).toEqual($rootScope.descriptor["value"]["default_args"]);
expect(directive.scope().$eval(directive.attr("flow-runner-args"))).toEqual(flowRunnerArgsDefault)});it("sends request when Launch button is clicked",function(){var element=renderTestTemplate();var deferred=$q.defer();spyOn(grrApiService,"post").and.returnValue(deferred.promise);browserTriggerEvent(element.find("button.Launch"),"click");expect(grrApiService.post).toHaveBeenCalledWith("/clients/C.0000111122223333/flows",{flow:{runner_args:{flow_name:"FooFlow",output_plugins:[{foo:"bar"}],foo:"bar"},
args:{foo:"bar"}}})});it("respects changes in form data when sending request",function(){var element=renderTestTemplate();var directive=element.find("grr-flow-form:nth(0)");directive.scope().$eval(directive.attr("flow-args"))["value"]["changed"]=true;directive.scope().$eval(directive.attr("flow-runner-args"))["value"]["changed"]=true;directive.scope().$eval(directive.attr("flow-runner-args"))["value"]["output_plugins"].push(42);$rootScope.$apply();var deferred=$q.defer();spyOn(grrApiService,"post").and.returnValue(deferred.promise);
browserTriggerEvent(element.find("button.Launch"),"click");expect(grrApiService.post).toHaveBeenCalledWith("/clients/C.0000111122223333/flows",{flow:{runner_args:{flow_name:"FooFlow",output_plugins:[{foo:"bar"},42],changed:true,foo:"bar"},args:{foo:"bar",changed:true}}})});it("shows progress message when request is processed",function(){var element=renderTestTemplate();var deferred=$q.defer();spyOn(grrApiService,"post").and.returnValue(deferred.promise);browserTriggerEvent(element.find("button.Launch"),
"click");expect(element.text()).toContain("Launching flow FooFlow...")});it("shows flow summary when launch succeeds",function(){var element=renderTestTemplate();var deferred=$q.defer();spyOn(grrApiService,"post").and.returnValue(deferred.promise);browserTriggerEvent(element.find("button.Launch"),"click");var flow={args:{"foo1":"bar1"},runner_args:{"foo2":"bar2"}};deferred.resolve({data:flow});$rootScope.$apply();var directive=element.find("grr-semantic-value:nth(0)");expect(directive.scope().$eval(directive.attr("value"))).toEqual(flow)});
it("shows failure message when launch fails",function(){var element=renderTestTemplate();var deferred=$q.defer();spyOn(grrApiService,"post").and.returnValue(deferred.promise);browserTriggerEvent(element.find("button.Launch"),"click");deferred.reject({data:{message:"Something is wrong"}});$rootScope.$apply();expect(element.text()).toContain("Something is wrong")})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.forms.autoGeneratedAes128KeyFormDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var118=goog.require("grrUi.forms.forms");var formsModule=$jscomp$destructuring$var118.formsModule;var $jscomp$destructuring$var119=goog.require("grrUi.forms.autoGeneratedAes128KeyFormDirective");var generateRandomBytes=$jscomp$destructuring$var119.generateRandomBytes;var $jscomp$destructuring$var120=goog.require("grrUi.tests");var stubDirective=
$jscomp$destructuring$var120.stubDirective;var testsModule=$jscomp$destructuring$var120.testsModule;describe("grr-form-auto-generated-aes128key form directive",function(){beforeEach(function(){var i=0;var step=1/16;spyOn(Math,"random").and.callFake(function(){var result=step*i+step/2;if(++i>=16)i=0;return result})});describe("generateRandomBytes()",function(){it("correctly generates 4-bytes string",function(){expect(generateRandomBytes(4)).toBe("01234567")});it("correctly generates 16 bytes string",
function(){expect(generateRandomBytes(16)).toBe("0123456789abcdef0123456789abcdef")})});var $compile;var $rootScope;beforeEach(module("/static/angular-components/forms/"+"auto-generated-aes128-key-form.html"));beforeEach(module(formsModule.name));beforeEach(module(testsModule.name));stubDirective("grrFormPrimitive");beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope")}));var renderTestTemplate=function(value){$rootScope.value=value;var template=
'<grr-form-auto-generated-aes128-key value="value" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("delegates rendering to grr-form-primitive",function(){var element=renderTestTemplate({type:"AutoGeneratedAES128Key",value:""});var directive=element.find("grr-form-primitive");expect(directive.length).toBe(1)});it("prefills auto-generated key if value is empty",function(){renderTestTemplate({type:"AutoGeneratedAES128Key",value:""});expect($rootScope.value.value).toBe("0123456789abcdef0123456789abcdef")});
it("preserves value if it's set",function(){renderTestTemplate({type:"AutoGeneratedAES128Key",value:"blah"});expect($rootScope.value.value).toBe("blah")})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.forms.bytesFormDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var121=goog.require("grrUi.tests");var browserTriggerEvent=$jscomp$destructuring$var121.browserTriggerEvent;var testsModule=$jscomp$destructuring$var121.testsModule;var $jscomp$destructuring$var122=goog.require("grrUi.forms.bytesFormDirective");var bytesToHexEncodedString=$jscomp$destructuring$var122.bytesToHexEncodedString;var hexEncodedStringToBytes=$jscomp$destructuring$var122.hexEncodedStringToBytes;
var isByteString=$jscomp$destructuring$var122.isByteString;var $jscomp$destructuring$var123=goog.require("grrUi.forms.forms");var formsModule=$jscomp$destructuring$var123.formsModule;var hexChars=String.fromCharCode(13)+String.fromCharCode(200);var encodedHexChars="\\x0d\\xc8";var nonHexChars="foo";describe("bytesToHexEncodedString()",function(){it("does nothing with an empty string",function(){expect(bytesToHexEncodedString("")).toBe("")});it("doesn't encode characters with codes from 32 to 126",
function(){var s="";for(var i=32;i<=126;++i)s+=String.fromCharCode(i);expect(bytesToHexEncodedString(s)).toBe(s)});it("encodes characters with codes from 0 to 31 and from 127 to 255",function(){for(var i=0;i<=31;++i){var s=String.fromCharCode(i);expect(bytesToHexEncodedString(s)).toMatch(/\\x[0-9A-Fa-f]{2}/)}});it("encodes hex chars in the beginning of the string",function(){expect(bytesToHexEncodedString(hexChars+nonHexChars)).toBe(encodedHexChars+nonHexChars)});it("encodes hex chars in the middle of the string",
function(){expect(bytesToHexEncodedString(nonHexChars+hexChars+nonHexChars)).toBe(nonHexChars+encodedHexChars+nonHexChars)});it("encodes hex chars in the end of the string",function(){expect(bytesToHexEncodedString(nonHexChars+hexChars)).toBe(nonHexChars+encodedHexChars)});it("encodes hex chars in the beginning and end of the string",function(){expect(bytesToHexEncodedString(hexChars+nonHexChars+hexChars)).toBe(encodedHexChars+nonHexChars+encodedHexChars)})});describe("hexEncodedStringToBytes()",
function(){it("does nothing with an empty string",function(){expect(hexEncodedStringToBytes("")).toBe("")});it("decodes all possible characters",function(){for(var i=0;i<256;++i){var s=i.toString(16);if(s.length==1)s="0"+s;s="\\x"+s;expect(hexEncodedStringToBytes(s)).toBe(String.fromCharCode(i))}});it("decodes hex chars in the beginning of the string",function(){expect(hexEncodedStringToBytes(encodedHexChars+nonHexChars)).toBe(hexChars+nonHexChars)});it("decodes hex chars in the middle of the string",
function(){expect(hexEncodedStringToBytes(nonHexChars+encodedHexChars+nonHexChars)).toBe(nonHexChars+hexChars+nonHexChars)});it("decodes hex chars in the end of the string",function(){expect(hexEncodedStringToBytes(nonHexChars+encodedHexChars)).toBe(nonHexChars+hexChars)});it("decodes hex chars in the beginning and end of the string",function(){expect(hexEncodedStringToBytes(encodedHexChars+nonHexChars+encodedHexChars)).toBe(hexChars+nonHexChars+hexChars)})});describe("isByteString()",function(){it("returns true if a string had only characters with car code < 256",
function(){var s="";for(var i=0;i<256;++i)s+=String.fromCharCode(i);expect(isByteString(s)).toBe(true)});it("returns false if a string has a character with a char code >= 256",function(){expect(isByteString(String.fromCharCode(256))).toBe(false)})});describe("bytes form directive",function(){var $compile;var $rootScope;beforeEach(module("/static/angular-components/forms/bytes-form.html"));beforeEach(module(formsModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=
$injector.get("$compile");$rootScope=$injector.get("$rootScope")}));var renderTestTemplate=function(value){$rootScope.value=value;var template='<grr-form-bytes value="value" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("shows nothing if value is null",function(){var element=renderTestTemplate({type:"RDFBytes",value:null});expect(element.find("input").val()).toBe("")});it("shows base64-decoded value for plain latin characters",function(){var element=renderTestTemplate({type:"RDFBytes",
value:window.btoa("foo")});expect(element.find("input").val()).toBe("foo")});it("shows nothing for incorrectly base64-encoded value",function(){var element=renderTestTemplate({type:"RDFBytes",value:"--"});expect(element.find("input").val()).toBe("")});it("updates value to a base64 version on input",function(){var value={type:"RDFBytes",value:""};var element=renderTestTemplate(value);element.find("input").val("a");browserTriggerEvent(element.find("input"),"change");expect(value.value).toBe("YQ==")});
it("updates value coorectly on hex-encoded input",function(){var value={type:"RDFBytes",value:""};var element=renderTestTemplate(value);element.find("input").val("\\");browserTriggerEvent(element.find("input"),"change");expect(value.value).toBe("XA==");element.find("input").val("\\x");browserTriggerEvent(element.find("input"),"change");expect(value.value).toBe("XHg=");element.find("input").val("\\x0");browserTriggerEvent(element.find("input"),"change");expect(value.value).toBe("XHgw");element.find("input").val("\\x0d");
browserTriggerEvent(element.find("input"),"change");expect(value.value).toBe("DQ==")});it("shows a validation message on unicode input",function(){var value={type:"RDFBytes",value:""};var element=renderTestTemplate(value);element.find("input").val("\u6628");browserTriggerEvent(element.find("input"),"change");expect(element.text()).toContain("Unicode characters are not allowed in a byte string")});it("updates value.validationError on unicode input",function(){var value={type:"RDFBytes",value:""};var element=
renderTestTemplate(value);element.find("input").val("\u6628");browserTriggerEvent(element.find("input"),"change");expect(value.validationError).toContain("Unicode characters are not allowed in a byte string")})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.forms.clientLabelFormDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var124=goog.require("grrUi.tests");var browserTriggerEvent=$jscomp$destructuring$var124.browserTriggerEvent;var testsModule=$jscomp$destructuring$var124.testsModule;var $jscomp$destructuring$var125=goog.require("grrUi.forms.forms");var formsModule=$jscomp$destructuring$var125.formsModule;describe("client label form directive",function(){var $compile;var $q;
var $rootScope;var grrApiService;var defaultOption="-- All clients --";beforeEach(module("/static/angular-components/forms/client-label-form.html"));beforeEach(module(formsModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");$q=$injector.get("$q");grrApiService=$injector.get("grrApiService");spyOn(grrApiService,"get").and.callFake(function(url){var deferred=$q.defer();if(url==="/clients/labels")deferred.resolve({data:{items:[{type:"AFF4ObjectLabel",
value:{name:{type:"unicode",value:"ClientLabelFoo"}}},{type:"AFF4ObjectLabel",value:{name:{type:"unicode",value:"ClientLabelBar"}}}]}});else throw new Error("Unexpected url: "+url);return deferred.promise})}));var renderTestTemplate=function(clientLabel,formLabel,hideEmptyOption,emptyOptionLabel){$rootScope.clientLabel=clientLabel;$rootScope.formLabel=formLabel;$rootScope.hideEmptyOption=hideEmptyOption;$rootScope.emptyOptionLabel=emptyOptionLabel;var template="<grr-form-client-label "+'client-label="clientLabel" '+
'form-label="formLabel" '+'hide-empty-option="hideEmptyOption" '+'empty-option-label="emptyOptionLabel" '+"></grr-form-client-label>";var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("shows the list of available client labels",function(){var element=renderTestTemplate("");var select=element.find("select");var children=select.children();var options=children.map(function(index){return children[index].innerText});expect(options).toContain(defaultOption);expect(options).toContain("ClientLabelFoo");
expect(options).toContain("ClientLabelBar")});it("selects the label given through scope params initially",function(){var initialSelection="ClientLabelFoo";var element=renderTestTemplate(initialSelection);var select=element.find("select");var children=select.children();var found=false;for(var i=0;i<children.length;++i){expect(children[i].selected).toBe(children[i].innerText===initialSelection);if(children[i].selected)found=true}expect(found).toBe(true)});it("shows default <label> text by default",
function(){var element=renderTestTemplate("");var labelTag=element.find("label");expect(labelTag.text()).toBe("Client label")});it("shows custom <label> text if given",function(){var element=renderTestTemplate("","Custom label text");var labelTag=element.find("label");expect(labelTag.text()).toBe("Custom label text")});it("forwards value changes to parent scope",function(){var element=renderTestTemplate("");var select=element.find("select");var newSelection="ClientLabelBar";select.val("string:"+newSelection);
browserTriggerEvent(select,"change");$rootScope.$apply();expect(element.scope().$eval(element.attr("client-label"))).toEqual(newSelection)});it("hides the empty option if requested",function(){var element=renderTestTemplate("",undefined,true);var select=element.find("select");var children=select.children();var options=children.map(function(index){return children[index].innerText});expect(options).not.toContain(defaultOption)});it("displays a given string describing the empty option if requested",
function(){var customDefaultOption="Custom empty option description";var element=renderTestTemplate("",undefined,undefined,customDefaultOption);var select=element.find("select");var children=select.children();var options=children.map(function(index){return children[index].innerText});expect(options).not.toContain(defaultOption);expect(options).toContain(customDefaultOption)})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.forms.datetimeFormDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var126=goog.require("grrUi.tests");var browserTriggerEvent=$jscomp$destructuring$var126.browserTriggerEvent;var testsModule=$jscomp$destructuring$var126.testsModule;var $jscomp$destructuring$var127=goog.require("grrUi.forms.forms");var formsModule=$jscomp$destructuring$var127.formsModule;describe("datetime form directive",function(){var $compile;var $rootScope;
beforeEach(module("/static/angular-components/forms/datetime-form.html"));beforeEach(module(formsModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope")}));var renderTestTemplate=function(value){$rootScope.value=value;var template='<grr-form-datetime value="value" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("shows nothing if time value is null",function(){var element=
renderTestTemplate({type:"RDFDatetime",value:null});expect(element.find("input").val()).toBe("")});it("shows correct date if time value is 0",function(){var element=renderTestTemplate({type:"RDFDatetime",value:0});expect(element.find("input").val()).toBe("1970-01-01 00:00")});it("shows nothing if time value is too big",function(){var element=renderTestTemplate({type:"RDFDatetime",value:0x7fffffffffffffff});expect(element.find("input").val()).toBe("")});it("sets value to null on incorrect input",function(){var value=
{type:"RDFDatetime",value:0};var element=renderTestTemplate(value);element.find("input").val("a");browserTriggerEvent(element.find("input"),"change");expect(value.value).toBe(null)});it("shows warning on incorrect input",function(){var value={type:"RDFDatetime",value:0};var element=renderTestTemplate(value);element.find("input").val("a");browserTriggerEvent(element.find("input"),"change");expect(element.text()).toContain("Expected format is")});it("correctly updates the value on correct input",function(){var value=
{type:"RDFDatetime",value:0};var element=renderTestTemplate(value);element.find("input").val("1989-04-20 13:42");browserTriggerEvent(element.find("input"),"change");expect(value.value).toBe(60908292E7)});it('sets current date when "today" button is pressed',function(){var value={type:"RDFDatetime",value:0};var baseTime=new Date(Date.UTC(1989,4,20));jasmine.clock().mockDate(baseTime);var element=renderTestTemplate(value);browserTriggerEvent(element.find("button[name=Today]"),"click");expect(value.value).toBe(6116256E8)})});
exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.forms.dictFormDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var128=goog.require("grrUi.tests");var browserTriggerEvent=$jscomp$destructuring$var128.browserTriggerEvent;var stubDirective=$jscomp$destructuring$var128.stubDirective;var testsModule=$jscomp$destructuring$var128.testsModule;var $jscomp$destructuring$var129=goog.require("grrUi.forms.forms");var formsModule=$jscomp$destructuring$var129.formsModule;describe("dict form directive",
function(){var $compile;var $q;var $rootScope;var grrReflectionService;beforeEach(module("/static/angular-components/forms/dict-form.html"));beforeEach(module(formsModule.name));beforeEach(module(testsModule.name));stubDirective("grrFormValue");beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");$q=$injector.get("$q");grrReflectionService=$injector.get("grrReflectionService");grrReflectionService.getRDFValueDescriptor=function(valueType){if(valueType!=
"RDFString")throw new Error("This stub accepts only RDFString value type.");var deferred=$q.defer();deferred.resolve({name:"RDFString",default:{type:"RDFString",value:""}});return deferred.promise}}));var renderTestTemplate=function(value){$rootScope.value=value;var template='<grr-form-dict value="value" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};var setFormValue=function(element,value){var valueElement=element.find("grr-form-value");valueElement.scope().$eval(valueElement.attr("value")+
'.value = "'+value+'"');$rootScope.$apply()};it('add empty key and value when "+" button is clicked',function(){var model={type:"Dict",value:{}};var element=renderTestTemplate(model);browserTriggerEvent(element.find("button[name=Add]"),"click");expect(model).toEqual({type:"Dict",value:{"":{type:"RDFString",value:""}}})});it("updates the model when key is changed",function(){var model={type:"Dict",value:{}};var element=renderTestTemplate(model);browserTriggerEvent(element.find("button[name=Add]"),
"click");element.find("input.key").val("foo");browserTriggerEvent(element.find("input.key"),"change");expect(model).toEqual({type:"Dict",value:{"foo":{type:"RDFString",value:""}}})});it("updates the model when value is changed",function(){var model={type:"Dict",value:{}};var element=renderTestTemplate(model);browserTriggerEvent(element.find("button[name=Add]"),"click");setFormValue(element,"foo");expect(model).toEqual({type:"Dict",value:{"":{type:"RDFString",value:"foo"}}})});it("prefills the UI with values from model",
function(){var model={type:"Dict",value:{"foo":{type:"RDFString",value:"bar"}}};var element=renderTestTemplate(model);expect(element.find("input.key").val()).toBe("foo");var valueElement=element.find("grr-form-value");expect(valueElement.scope().$eval(valueElement.attr("value"))).toEqual({type:"RDFString",value:"bar"})});it("treats digits-only string as integers",function(){var model={type:"Dict",value:{}};var element=renderTestTemplate(model);browserTriggerEvent(element.find("button[name=Add]"),
"click");setFormValue(element,"42");expect(model).toEqual({type:"Dict",value:{"":{type:"RDFInteger",value:42}}})});it("dynamically changes value type from str to int and back",function(){var model={type:"Dict",value:{}};var element=renderTestTemplate(model);browserTriggerEvent(element.find("button[name=Add]"),"click");expect(model).toEqual({type:"Dict",value:{"":{type:"RDFString",value:""}}});setFormValue(element,"1");expect(model).toEqual({type:"Dict",value:{"":{type:"RDFInteger",value:1}}});setFormValue(element,
"1a");expect(model).toEqual({type:"Dict",value:{"":{type:"RDFString",value:"1a"}}})});it("treats 0x.* strings as hex integers",function(){var model={type:"Dict",value:{}};var element=renderTestTemplate(model);browserTriggerEvent(element.find("button[name=Add]"),"click");setFormValue(element,"0x2f");expect(model).toEqual({type:"Dict",value:{"":{type:"RDFInteger",value:47}}})});it("dynamically changes value type from hex int to str and back",function(){var model={type:"Dict",value:{}};var element=renderTestTemplate(model);
browserTriggerEvent(element.find("button[name=Add]"),"click");expect(model).toEqual({type:"Dict",value:{"":{type:"RDFString",value:""}}});setFormValue(element,"0x");expect(model).toEqual({type:"Dict",value:{"":{type:"RDFString",value:"0x"}}});setFormValue(element,"0x2f");expect(model).toEqual({type:"Dict",value:{"":{type:"RDFInteger",value:47}}});setFormValue(element,"0x2fz");expect(model).toEqual({type:"Dict",value:{"":{type:"RDFString",value:"0x2fz"}}})});it('treats "true" string as a boolean',
function(){var model={type:"Dict",value:{}};var element=renderTestTemplate(model);browserTriggerEvent(element.find("button[name=Add]"),"click");setFormValue(element,"true");expect(model).toEqual({type:"Dict",value:{"":{type:"RDFBool",value:true}}})});it('treats "false" string as a boolean',function(){var model={type:"Dict",value:{}};var element=renderTestTemplate(model);browserTriggerEvent(element.find("button[name=Add]"),"click");setFormValue(element,"false");expect(model).toEqual({type:"Dict",value:{"":{type:"RDFBool",
value:false}}})});it("dynamically changes valye type from text to bool and back",function(){var model={type:"Dict",value:{}};var element=renderTestTemplate(model);browserTriggerEvent(element.find("button[name=Add]"),"click");expect(model).toEqual({type:"Dict",value:{"":{type:"RDFString",value:""}}});setFormValue(element,"true");expect(model).toEqual({type:"Dict",value:{"":{type:"RDFBool",value:true}}});setFormValue(element,"truea");expect(model).toEqual({type:"Dict",value:{"":{type:"RDFString",value:"truea"}}})})});
exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.forms.durationFormDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var130=goog.require("grrUi.tests");var browserTriggerEvent=$jscomp$destructuring$var130.browserTriggerEvent;var testsModule=$jscomp$destructuring$var130.testsModule;var $jscomp$destructuring$var131=goog.require("grrUi.forms.forms");var formsModule=$jscomp$destructuring$var131.formsModule;describe("duration form directive",function(){var $compile;var $rootScope;
beforeEach(module("/static/angular-components/forms/duration-form.html"));beforeEach(module(formsModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope")}));var renderTestTemplate=function(value){$rootScope.value=value;var template='<grr-form-duration value="value" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("shows nothing if duration value is null",function(){var element=
renderTestTemplate({type:"Duration",value:null});expect(element.find("input").val()).toBe("")});it("shows 0 if duration value is 0",function(){var element=renderTestTemplate({type:"Duration",value:0});expect(element.find("input").val()).toBe("0")});it("shows correct duration for large numbers",function(){var element=renderTestTemplate({type:"Duration",value:1040688E6});expect(element.find("input").val()).toBe("12045000d")});it("shows duration in seconds if it's not divisible by 60",function(){var element=
renderTestTemplate({type:"Duration",value:122});expect(element.find("input").val()).toBe("122s")});it("shows duration in minutes if possible",function(){var element=renderTestTemplate({type:"Duration",value:120});expect(element.find("input").val()).toBe("2m")});it("shows duration in hours if possible",function(){var element=renderTestTemplate({type:"Duration",value:7200});expect(element.find("input").val()).toBe("2h")});it("shows duration in days if possible",function(){var element=renderTestTemplate({type:"Duration",
value:172800});expect(element.find("input").val()).toBe("2d")});it("shows duration in weeks if possible",function(){var element=renderTestTemplate({type:"Duration",value:1209600});expect(element.find("input").val()).toBe("2w")});it("sets value to null on incorrect input",function(){var value={type:"Duration",value:0};var element=renderTestTemplate(value);element.find("input").val("a");browserTriggerEvent(element.find("input"),"change");expect(value.value).toBe(null)});it("shows warning on incorrect input",
function(){var value={type:"Duration",value:0};var element=renderTestTemplate(value);element.find("input").val("a");browserTriggerEvent(element.find("input"),"change");expect(element.text()).toContain("Expected format is")});it("correctly updates the value when input is in weeks",function(){var value={type:"Duration",value:0};var element=renderTestTemplate(value);element.find("input").val("2w");browserTriggerEvent(element.find("input"),"change");expect(value.value).toBe(1209600)});it("correctly updates the value when input is in days",
function(){var value={type:"Duration",value:0};var element=renderTestTemplate(value);element.find("input").val("2d");browserTriggerEvent(element.find("input"),"change");expect(value.value).toBe(172800)});it("correctly updates the value when input is in hours",function(){var value={type:"Duration",value:0};var element=renderTestTemplate(value);element.find("input").val("2h");browserTriggerEvent(element.find("input"),"change");expect(value.value).toBe(7200)});it("correctly updates the value when input is in minutes",
function(){var value={type:"Duration",value:0};var element=renderTestTemplate(value);element.find("input").val("2m");browserTriggerEvent(element.find("input"),"change");expect(value.value).toBe(120)});it("correctly updates the value when input is in seconds",function(){var value={type:"Duration",value:0};var element=renderTestTemplate(value);element.find("input").val("2s");browserTriggerEvent(element.find("input"),"change");expect(value.value).toBe(2)});it("treats values without unit as seconds",
function(){var value={type:"Duration",value:0};var element=renderTestTemplate(value);element.find("input").val("2");browserTriggerEvent(element.find("input"),"change");expect(value.value).toBe(2)})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.forms.extFlagsLinuxPickerLongDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var132=goog.require("grrUi.forms.extFlagsLinuxPickerLongDirective");var ExtFlagsLinuxPickerLongDirective=$jscomp$destructuring$var132.ExtFlagsLinuxPickerLongDirective;var $jscomp$destructuring$var133=goog.require("grrUi.client.extFlags");var LINUX_FLAGS=$jscomp$destructuring$var133.LINUX_FLAGS;var getLinuxFlagMaskByNames=$jscomp$destructuring$var133.getLinuxFlagMaskByNames;
var $jscomp$destructuring$var134=goog.require("grrUi.forms.forms");var formsModule=$jscomp$destructuring$var134.formsModule;var $jscomp$destructuring$var135=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var135.testsModule;describe("Extended flags picker for Linux (long)",function(){var $compile;var $rootScope;beforeEach(module(ExtFlagsLinuxPickerLongDirective().templateUrl));beforeEach(module(formsModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=
$injector.get("$compile");$rootScope=$injector.get("$rootScope")}));var render=function(bits){$rootScope.bitsSet=bits.set;$rootScope.bitsUnset=bits.unset;var template='<grr-ext-flags-linux-picker-long\n      bits-set="bitsSet"\n      bits-unset="bitsUnset" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};var parse=function(element){var result={};for(var $jscomp$iter$0=$jscomp.makeIterator(LINUX_FLAGS),$jscomp$key$flag=$jscomp$iter$0.next();!$jscomp$key$flag.done;$jscomp$key$flag=
$jscomp$iter$0.next()){var flag=$jscomp$key$flag.value;{var option=$(element.find("#"+flag.name)).find("option[selected]");result[flag.name]=option.text()}}return result};it("correctly renders a table if set and unset bits are empty",function(){var table=parse(render({set:{value:0},unset:{value:0}}));for(var $jscomp$iter$1=$jscomp.makeIterator(LINUX_FLAGS),$jscomp$key$flag=$jscomp$iter$1.next();!$jscomp$key$flag.done;$jscomp$key$flag=$jscomp$iter$1.next()){var flag=$jscomp$key$flag.value;{expect(table[flag.name]).toBe("ignored")}}});
it("correctly renders a table if some bits are set",function(){var table=parse(render({set:{value:getLinuxFlagMaskByNames(["FS_SYNC_FL","FS_UNRM_FL"])},unset:{value:0}}));expect(table["FS_SYNC_FL"]).toBe("required set");expect(table["FS_UNRM_FL"]).toBe("required set");expect(table["FS_IMMUTABLE_FL"]).toBe("ignored")});it("correctly renders a table if some bits are unset",function(){var table=parse(render({set:{value:0},unset:{value:getLinuxFlagMaskByNames(["FS_IMMUTABLE_FL","FS_COMPR_FL"])}}));expect(table["FS_IMMUTABLE_FL"]).toBe("required unset");
expect(table["FS_COMPR_FL"]).toBe("required unset");expect(table["FS_SYNC_FL"]).toBe("ignored")});it("correctly renders a table if there are bits set and bits unset",function(){var table=parse(render({set:{value:getLinuxFlagMaskByNames(["FS_NOATIME_FL"])},unset:{value:getLinuxFlagMaskByNames(["FS_DIRTY_FL","FS_INDEX_FL"])}}));expect(table["FS_NOATIME_FL"]).toBe("required set");expect(table["FS_DIRTY_FL"]).toBe("required unset");expect(table["FS_INDEX_FL"]).toBe("required unset");expect(table["FS_TOPDIR_FL"]).toBe("ignored")})});
return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.forms.extFlagsLinuxPickerShortDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var136=goog.require("grrUi.forms.extFlagsLinuxPickerShortDirective");var ExtFlagsLinuxPickerShortDirective=$jscomp$destructuring$var136.ExtFlagsLinuxPickerShortDirective;var $jscomp$destructuring$var137=goog.require("grrUi.client.extFlags");var LINUX_FLAGS=$jscomp$destructuring$var137.LINUX_FLAGS;var getLinuxFlagMaskByNames=$jscomp$destructuring$var137.getLinuxFlagMaskByNames;
var $jscomp$destructuring$var138=goog.require("grrUi.core.troggleDirective");var TroggleDirective=$jscomp$destructuring$var138.TroggleDirective;var $jscomp$destructuring$var139=goog.require("grrUi.core.core");var coreModule=$jscomp$destructuring$var139.coreModule;var $jscomp$destructuring$var140=goog.require("grrUi.forms.forms");var formsModule=$jscomp$destructuring$var140.formsModule;var $jscomp$destructuring$var141=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var141.testsModule;
describe("Extended flags picker for Linux (short)",function(){var $compile;var $rootScope;beforeEach(module(TroggleDirective().templateUrl));beforeEach(module(ExtFlagsLinuxPickerShortDirective().templateUrl));beforeEach(module(coreModule.name));beforeEach(module(formsModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope")}));var render=function(bits){$rootScope.bitsSet=bits.set;$rootScope.bitsUnset=
bits.unset;var template='<grr-ext-flags-linux-picker-short\n      bits-set="bitsSet"\n      bits-unset="bitsUnset" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};var parse=function(element){var ths=element.find("th");var tds=element.find("td");expect(ths.length).toBe(tds.length);var result={};for(var i=0;i<ths.length;i++)result[$(ths[i]).text().trim()]=$(tds[i]).text().trim();return result};it("correctly renders a table if set and unset bits are empty",function(){var table=
parse(render({set:{value:0},unset:{value:0}}));for(var $jscomp$iter$2=$jscomp.makeIterator(LINUX_FLAGS),$jscomp$key$flag=$jscomp$iter$2.next();!$jscomp$key$flag.done;$jscomp$key$flag=$jscomp$iter$2.next()){var flag=$jscomp$key$flag.value;{expect(table[flag.identifier]).toBe("_")}}});it("correctly renders a table if some bits are set",function(){var table=parse(render({set:{value:getLinuxFlagMaskByNames(["FS_IMMUTABLE_FL","FS_APPEND_FL"])},unset:{value:0}}));expect(table["a"]).toBe("\u2713");expect(table["i"]).toBe("\u2713");
expect(table["c"]).toBe("_");expect(table["s"]).toBe("_")});it("correctly renders a table if some bits are unset",function(){var table=parse(render({set:{value:0},unset:{value:getLinuxFlagMaskByNames(["FS_NOCOMP_FL","FS_NODUMP_FL"])}}));expect(table["X"]).toBe("\u2715");expect(table["d"]).toBe("\u2715");expect(table["a"]).toBe("_");expect(table["B"]).toBe("_")});it("correctly renders a table if there are bits set and bits unset",function(){var table=parse(render({set:{value:getLinuxFlagMaskByNames(["FS_EXTENT_FL"])},
unset:{value:getLinuxFlagMaskByNames(["FS_TOPDIR_FL","FS_NOCOW_FL"])}}));expect(table["e"]).toBe("\u2713");expect(table["T"]).toBe("\u2715");expect(table["C"]).toBe("\u2715");expect(table["a"]).toBe("_")})});return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.forms.extFlagsOsxPickerDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var142=goog.require("grrUi.forms.extFlagsOsxPickerDirective");var ExtFlagsOsxPickerDirective=$jscomp$destructuring$var142.ExtFlagsOsxPickerDirective;var $jscomp$destructuring$var143=goog.require("grrUi.client.extFlags");var OSX_FLAGS=$jscomp$destructuring$var143.OSX_FLAGS;var getOsxFlagMaskByNames=$jscomp$destructuring$var143.getOsxFlagMaskByNames;var $jscomp$destructuring$var144=
goog.require("grrUi.core.troggleDirective");var TroggleDirective=$jscomp$destructuring$var144.TroggleDirective;var $jscomp$destructuring$var145=goog.require("grrUi.core.core");var coreModule=$jscomp$destructuring$var145.coreModule;var $jscomp$destructuring$var146=goog.require("grrUi.forms.forms");var formsModule=$jscomp$destructuring$var146.formsModule;var $jscomp$destructuring$var147=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var147.testsModule;describe("Extended flags picker for macOS",
function(){var $compile;var $rootScope;beforeEach(module(TroggleDirective().templateUrl));beforeEach(module(ExtFlagsOsxPickerDirective().templateUrl));beforeEach(module(coreModule.name));beforeEach(module(formsModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope")}));var render=function(bits){$rootScope.bitsSet=bits.set;$rootScope.bitsUnset=bits.unset;var template='<grr-ext-flags-osx-picker\n      bits-set="bitsSet"\n      bits-unset="bitsUnset" />';
var element=$compile(template)($rootScope);$rootScope.$apply();return element};var parse=function(element){var ths=element.find("th");var tds=element.find("td");expect(ths.length).toBe(tds.length);var result={};for(var i=0;i<ths.length;i++)result[$(ths[i]).text().trim()]=$(tds[i]).text().trim();return result};it("correctly renders a table if set and unset bits are empty",function(){var table=parse(render({set:{value:0},unset:{value:0}}));for(var $jscomp$iter$3=$jscomp.makeIterator(OSX_FLAGS),$jscomp$key$flag=
$jscomp$iter$3.next();!$jscomp$key$flag.done;$jscomp$key$flag=$jscomp$iter$3.next()){var flag=$jscomp$key$flag.value;{expect(table[flag.identifier]).toBe("_")}}});it("correctly renders a table if some bits are set",function(){var table=parse(render({set:{value:getOsxFlagMaskByNames(["UF_NODUMP","UF_IMMUTABLE"])},unset:{value:0}}));expect(table["nodump"]).toBe("\u2713");expect(table["uimmutable"]).toBe("\u2713");expect(table["archived"]).toBe("_")});it("correctly renders a table if some bits are unset",
function(){var table=parse(render({set:{value:0},unset:{value:getOsxFlagMaskByNames(["SF_APPEND","SF_NOUNLINK"])}}));expect(table["sappend"]).toBe("\u2715");expect(table["sunlnk"]).toBe("\u2715");expect(table["opaque"]).toBe("_")});it("correctly renders a table if there are bits set and bits unset",function(){var table=parse(render({set:{value:getOsxFlagMaskByNames(["UF_APPEND"])},unset:{value:getOsxFlagMaskByNames(["SF_APPEND"])}}));expect(table["uappend"]).toBe("\u2713");expect(table["sappend"]).toBe("\u2715");
expect(table["uimmutable"]).toBe("_");expect(table["simmutable"]).toBe("_")})});return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.forms.extFlagsTrogglingTest");goog.module.declareLegacyNamespace();goog.setTestOnly();var $jscomp$destructuring$var148=goog.require("grrUi.forms.extFlagsTroggling");var TroggableFlags=$jscomp$destructuring$var148.TroggableFlags;var $jscomp$destructuring$var149=goog.require("grrUi.core.troggleDirective");var TroggleState=$jscomp$destructuring$var149.TroggleState;describe("TroggableFlags",function(){var flags;beforeEach(function(){flags=
new TroggableFlags([{name:"FOO",identifier:"foo",mask:1,description:"foo"},{name:"BAR",identifier:"bar",mask:2,description:"bar"},{name:"BAZ",identifier:"baz",mask:4,description:"baz"}])});it("should update itself if children state changes",function(){flags.children[1].state=TroggleState.SET;expect(flags.bitsSet).toBe(2);flags.children[0].state=TroggleState.SET;expect(flags.bitsSet).toBe(3);flags.children[2].state=TroggleState.UNSET;expect(flags.bitsUnset).toBe(4)});it("should update children on bits change",
function(){flags.bitsSet=0;flags.bitsUnset=0;for(var $jscomp$iter$4=$jscomp.makeIterator(flags.children),$jscomp$key$flag=$jscomp$iter$4.next();!$jscomp$key$flag.done;$jscomp$key$flag=$jscomp$iter$4.next()){var flag=$jscomp$key$flag.value;{expect(flag.state).toBe(TroggleState.VOID)}}flags.bitsSet=4;expect(flags.children[2].state).toBe(TroggleState.SET);expect(flags.children[0].state).toBe(TroggleState.VOID);flags.bitsSet=5;expect(flags.children[2].state).toBe(TroggleState.SET);expect(flags.children[2].state).toBe(TroggleState.SET);
flags.bitsUnset=2;expect(flags.children[1].state).toBe(TroggleState.UNSET)});it("should throw if conflicting masks are set",function(){flags.bitsSet=6;flags.bitsUnset=2;expect(function(){return flags.children[1].state}).toThrow()})});return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.forms.outputPluginDescriptorFormDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var150=goog.require("grrUi.tests");var browserTriggerEvent=$jscomp$destructuring$var150.browserTriggerEvent;var stubDirective=$jscomp$destructuring$var150.stubDirective;var testsModule=$jscomp$destructuring$var150.testsModule;var $jscomp$destructuring$var151=goog.require("grrUi.forms.forms");var formsModule=$jscomp$destructuring$var151.formsModule;
describe("grr-output-plugin-descriptor-form directive",function(){var $compile;var $q;var $rootScope;var grrApiService;var grrReflectionService;beforeEach(module("/static/angular-components/forms/"+"output-plugin-descriptor-form.html"));beforeEach(module(formsModule.name));beforeEach(module(testsModule.name));stubDirective("grrFormValue");beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");$q=$injector.get("$q");grrApiService=$injector.get("grrApiService");
grrReflectionService=$injector.get("grrReflectionService");var apiServiceResponse=$q.defer();apiServiceResponse.resolve({data:{items:[{args_type:"FooOutputPluginArgs",name:"FooOutputPlugin",plugin_type:"LEGACY"},{args_type:"BarOutputPluginArgs",name:"BarOutputPlugin",plugin_type:"LEGACY"},{name:"foo-bar",friendly_name:"FooBar plugin",plugin_type:"INSTANT"}]}});spyOn(grrApiService,"get").and.returnValue(apiServiceResponse.promise);spyOn(grrReflectionService,"getRDFValueDescriptor").and.callFake(function(name){var deferred=
$q.defer();if(name=="FooOutputPluginArgs")deferred.resolve({default:{type:"FooOutputPluginArgs",value:"FooValue"}});else if(name=="BarOutputPluginArgs")deferred.resolve({default:{type:"BarOutputPluginArgs",value:"BarValue"}});else throw new Error("Unexpected name: "+name);return deferred.promise})}));var renderTestTemplate=function(value){$rootScope.value=angular.isDefined(value)?value:{type:"OutputPluginDescriptor",value:{}};var template='<grr-output-plugin-descriptor-form value="value" />';var element=
$compile(template)($rootScope);$rootScope.$apply();return element};it("selects alphabetically first plugin if none is specified",function(){var element=renderTestTemplate();expect($rootScope.value.value.plugin_name.value).toBe("BarOutputPlugin");expect(element.find("select").val()).toBe("string:BarOutputPlugin")});it("keeps current output plugin type if one is specified",function(){var element=renderTestTemplate({type:"OutputPluginDescriptor",value:{plugin_name:{type:"RDFString",value:"FooOutputPlugin"}}});
expect($rootScope.value.value.plugin_name.value).toBe("FooOutputPlugin");expect(element.find("select").val()).toBe("string:FooOutputPlugin")});it("sets plugin args to default when plugin type is changed",function(){var element=renderTestTemplate();expect($rootScope.value.value.plugin_args.type).toBe("BarOutputPluginArgs");element.find("select").val(element.find('select option[label="FooOutputPlugin"]').val());browserTriggerEvent(element.find("select"),"change");expect($rootScope.value.value.plugin_args.type).toBe("FooOutputPluginArgs")});
it("delegates current plugin args rendering to grr-form-value",function(){var element=renderTestTemplate();var argsValue=$rootScope.$eval(element.find("grr-form-value").attr("value"));expect(argsValue.type).toBe("BarOutputPluginArgs");element.find("select").val(element.find('select option[label="FooOutputPlugin"]').val());browserTriggerEvent(element.find("select"),"change");argsValue=$rootScope.$eval(element.find("grr-form-value").attr("value"));expect(argsValue.type).toBe("FooOutputPluginArgs")})});
exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.forms.semanticEnumFormDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var152=goog.require("grrUi.tests");var browserTriggerEvent=$jscomp$destructuring$var152.browserTriggerEvent;var testsModule=$jscomp$destructuring$var152.testsModule;var $jscomp$destructuring$var153=goog.require("grrUi.forms.forms");var formsModule=$jscomp$destructuring$var153.formsModule;describe("semantic enum form directive",function(){var $compile;
var $rootScope;var value;beforeEach(module("/static/angular-components/forms/semantic-enum-form.html"));beforeEach(module(formsModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");value={age:0,type:"EnumNamedValue",value:"NONE",mro:["EnumNamedValue","RDFInteger","RDFString","RDFBytes","RDFValue","object"]}}));var renderTestTemplate=function(metadata){$rootScope.value=value;$rootScope.metadata=
metadata;var template='<grr-form-enum metadata="metadata" value="value" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("shows list of options from the metadata",function(){var element=renderTestTemplate({allowed_values:[{name:"NONE",value:0},{name:"CHOICE 1",value:1},{name:"CHOICE 2",value:2}]});expect(element.find("option").length).toBe(3);expect(element.find("option:nth(0)").attr("label")).toBe("NONE");expect(element.find("option:nth(1)").attr("label")).toBe("CHOICE 1");
expect(element.find("option:nth(2)").attr("label")).toBe("CHOICE 2")});it('marks the default value with "(default)"',function(){var element=renderTestTemplate({allowed_values:[{name:"NONE",value:0},{name:"CHOICE 1",value:1},{name:"CHOICE 2",value:2}],default:{"age":0,"type":"EnumNamedValue","value":"CHOICE 1","mro":["EnumNamedValue","RDFInteger","RDFString","RDFBytes","RDFValue","object"]}});expect(element.find("option").length).toBe(3);expect(element.find("option:nth(0)").attr("label")).toBe("NONE");
expect(element.find("option:nth(1)").attr("label")).toBe("CHOICE 1 (default)");expect(element.find("option:nth(2)").attr("label")).toBe("CHOICE 2")});it("updates the value when user selects an option",function(){var element=renderTestTemplate({allowed_values:[{name:"NONE",value:0},{name:"CHOICE 1",value:1},{name:"CHOICE 2",value:2}]});expect(value.value).toBe("NONE");element.find("select").val(element.find('select option[label="CHOICE 2"]').val());browserTriggerEvent(element.find("select"),"change");
$rootScope.$apply();expect(value.value).toBe("CHOICE 2")})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.forms.semanticPrimitiveFormDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var154=goog.require("grrUi.tests");var browserTriggerEvent=$jscomp$destructuring$var154.browserTriggerEvent;var testsModule=$jscomp$destructuring$var154.testsModule;var $jscomp$destructuring$var155=goog.require("grrUi.forms.forms");var formsModule=$jscomp$destructuring$var155.formsModule;describe("semantic primitive form directive",function(){var $compile;
var $q;var $rootScope;var grrReflectionService;var boolValue;var intValue;var stringValue;beforeEach(module("/static/angular-components/forms/semantic-primitive-form.html"));beforeEach(module(formsModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");$q=$injector.get("$q");grrReflectionService=$injector.get("grrReflectionService");grrReflectionService.getRDFValueDescriptor=function(valueType){var deferred=
$q.defer();deferred.resolve({name:valueType,mro:[valueType]});return deferred.promise};stringValue={type:"RDFString",value:"foo"};intValue={type:"RDFInteger",value:42};boolValue={type:"RDFBool",value:true}}));var renderTestTemplate=function(value){$rootScope.value=value;var template='<grr-form-primitive value="value" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("prefills RDFString value from a model",function(){var element=renderTestTemplate(stringValue);expect(element.find("input").val()).toBe("foo")});
it("updates RDFString value when model is updated",function(){var element=renderTestTemplate(stringValue);expect(element.find("input").val()).toBe("foo");stringValue.value="bar";$rootScope.$apply();expect(element.find("input").val()).toBe("bar")});it("updates RDFString model when user changes the input",function(){var element=renderTestTemplate(stringValue);element.find("input").val("bar");browserTriggerEvent(element.find("input"),"change");$rootScope.$apply();expect(stringValue.value).toBe("bar")});
it("prefills RDFInteger value from a model",function(){var element=renderTestTemplate(intValue);expect(element.find("input").val()).toBe("42")});it("updates RDFInteger value when model is updated",function(){var element=renderTestTemplate(intValue);expect(element.find("input").val()).toBe("42");intValue.value=84;$rootScope.$apply();expect(element.find("input").val()).toBe("84")});it("updates RDFInteger model when user changes the input",function(){var element=renderTestTemplate(intValue);element.find("input").val("84");
browserTriggerEvent(element.find("input"),"change");$rootScope.$apply();expect(intValue.value).toBe(84)});it("prefills RDFBool value from a model",function(){var element=renderTestTemplate(boolValue);expect(element.find("input").prop("checked")).toBe(true)});it("updates RDFBool value when model is updated",function(){var element=renderTestTemplate(boolValue);expect(element.find("input").prop("checked")).toBe(true);boolValue.value=false;$rootScope.$apply();expect(element.find("input").prop("checked")).toBe(false)});
it("updates RDFBool model when user changes the input",function(){var element=renderTestTemplate(boolValue);browserTriggerEvent(element.find("input").prop("checked",false),"change");$rootScope.$apply();expect(boolValue.value).toBe(false)})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.forms.semanticProtoFormDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var156=goog.require("grrUi.tests");var browserTriggerEvent=$jscomp$destructuring$var156.browserTriggerEvent;var stubDirective=$jscomp$destructuring$var156.stubDirective;var testsModule=$jscomp$destructuring$var156.testsModule;var $jscomp$destructuring$var157=goog.require("grrUi.forms.semanticValueFormDirective");var clearCaches=$jscomp$destructuring$var157.clearCaches;
var $jscomp$destructuring$var158=goog.require("grrUi.forms.forms");var formsModule=$jscomp$destructuring$var158.formsModule;describe("semantic proto form directive",function(){var $compile;var $q;var $rootScope;var grrReflectionServiceMock;beforeEach(module("/static/angular-components/forms/semantic-proto-form.html"));beforeEach(module(formsModule.name));beforeEach(module(testsModule.name));angular.forEach(["grrFormProtoSingleField","grrFormProtoRepeatedField","grrFormProtoUnion"],function(directiveName){stubDirective(directiveName)});
beforeEach(module(function($provide){grrReflectionServiceMock={getRDFValueDescriptor:function(){}};$provide.factory("grrReflectionService",function(){return grrReflectionServiceMock})}));beforeEach(inject(function($injector){clearCaches();$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");$q=$injector.get("$q")}));var renderTestTemplate=function(value,metadata,hiddenFields){$rootScope.value=value;$rootScope.metadata=metadata;$rootScope.hiddenFields=hiddenFields;var template=
'<grr-form-proto value="value" metadata="metadata" '+'hidden-fields="hiddenFields" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};describe("form for structure with 3 primitive fields",function(){var defaultFooStructValue={type:"Foo",mro:["Foo","RDFProtoStruct"],value:{}};beforeEach(function(){var data={"Foo":{"default":{"type":"Foo","value":{}},"doc":"This is a structure Foo.","fields":[{"doc":"Field 1 description.","dynamic":false,"friendly_name":"Field 1","index":1,
"name":"field_1","repeated":false,"type":"PrimitiveType"},{"default":{"type":"PrimitiveType","value":"a foo bar"},"doc":"Field 2 description.","dynamic":false,"friendly_name":"Field 2","index":1,"name":"field_2","repeated":false,"type":"PrimitiveType"},{"default":{"type":"PrimitiveType","value":""},"doc":"Field 3 description.","dynamic":false,"friendly_name":"Field 3","index":1,"name":"field_3","repeated":false,"type":"PrimitiveType"}],"kind":"struct","name":"Foo","mro":["Foo","RDFProtoStruct"]},
"PrimitiveType":{"default":{"type":"PrimitiveType","value":""},"doc":"Test primitive type description.","kind":"primitive","name":"PrimitiveType","mro":["PrimitiveType"]}};var reflectionDeferred=$q.defer();reflectionDeferred.resolve(data);spyOn(grrReflectionServiceMock,"getRDFValueDescriptor").and.callFake(function(type,opt_withDeps){var reflectionDeferred=$q.defer();reflectionDeferred.resolve(opt_withDeps?data:data[type]);return reflectionDeferred.promise})});it("renders a form for structure with 3 primitive fields",
function(){var element=renderTestTemplate(defaultFooStructValue);expect(element.find("grr-form-proto-single-field").length).toBe(3)});it("does not overwrite field prefilled with non-default value",function(){var fooValue=defaultFooStructValue;fooValue.value={field_2:{type:"PrimitiveType",value:"42"}};renderTestTemplate(fooValue);expect(fooValue.value).toEqual({field_2:{type:"PrimitiveType",value:"42"}})});it("does not erase the field with default value prefilled with default "+"field value not equal to the default type value",
function(){var fooValue=defaultFooStructValue;fooValue.value={field_2:{type:"PrimitiveType",value:"a foo bar"}};renderTestTemplate(fooValue);expect(fooValue.value).toEqual({field_2:{type:"PrimitiveType",value:"a foo bar"}})});it("erases the field with default value prefilled with default field "+"value equal to the default type value",function(){var fooValue=defaultFooStructValue;fooValue.value={field_3:{type:"PrimitiveType",value:""}};renderTestTemplate(fooValue);expect(fooValue.value).toEqual({})});
it("erases the field without default prefilled with default type "+"value",function(){var fooValue=defaultFooStructValue;fooValue.value={field_1:{type:"PrimitiveType",value:""}};renderTestTemplate(fooValue);expect(fooValue.value).toEqual({})});it("does not erase hidden fields",function(){var fooValue=defaultFooStructValue;fooValue.value={field_1:{type:"PrimitiveType",value:""}};renderTestTemplate(fooValue,undefined,["field_1"]);expect(fooValue.value).toEqual({field_1:{type:"PrimitiveType",value:""}})});
it("does not render fields listed in hidden-fields argument",function(){var element=renderTestTemplate(defaultFooStructValue,undefined,["field_1"]);expect(element.find("grr-form-proto-single-field").length).toBe(2);var field=element.find("grr-form-proto-single-field:nth(0)");expect(field.scope().$eval(field.attr("value"))).toEqual({type:"PrimitiveType",value:"a foo bar"});field=element.find("grr-form-proto-single-field:nth(1)");expect(field.scope().$eval(field.attr("value"))).toEqual({type:"PrimitiveType",
value:""})});it("does not prefill the model with defaults",function(){var fooValue=defaultFooStructValue;renderTestTemplate(fooValue);expect(fooValue.value).toEqual({})});it("prefills nested form elements with defaults",function(){var fooValue=defaultFooStructValue;var element=renderTestTemplate(fooValue);var field=element.find("grr-form-proto-single-field:nth(0)");expect(field.scope().$eval(field.attr("value"))).toEqual({type:"PrimitiveType",value:""});field=element.find("grr-form-proto-single-field:nth(1)");
expect(field.scope().$eval(field.attr("value"))).toEqual({type:"PrimitiveType",value:"a foo bar"});field=element.find("grr-form-proto-single-field:nth(2)");expect(field.scope().$eval(field.attr("value"))).toEqual({type:"PrimitiveType",value:""})});it("updates model when a field is changed",function(){var fooValue=defaultFooStructValue;var element=renderTestTemplate(fooValue);var field=element.find("grr-form-proto-single-field:nth(0)");var fieldValue=field.scope().$eval(field.attr("value"));fieldValue.value=
"42";$rootScope.$apply();expect(fooValue.value).toEqual({field_1:{type:"PrimitiveType",value:"42"}})});var icon=function(element,iconName){return element.find("i.glyphicon-"+iconName)};var expectIcon=function(element,iconName){expect(icon(element,iconName).length).toBe(1)};var expectNoIcon=function(element,iconName){expect(icon(element,iconName).length).toBe(0)};it("does not render collapse/expand icon if depth is not set",function(){var element=renderTestTemplate(defaultFooStructValue,{depth:undefined});
expectNoIcon(element,"plus")});it("does not render collapse/expand icon if depth is 0 or 1",function(){var element=renderTestTemplate(defaultFooStructValue,{depth:0});expectNoIcon(element,"plus");element=renderTestTemplate(defaultFooStructValue,{depth:1});expectNoIcon(element,"plus")});it("renders as collapsed if metadata.depth is 2",function(){var element=renderTestTemplate(defaultFooStructValue,{depth:2});expectIcon(element,"plus")});it("expands if collapsed plus icons is clicked",function(){var element=
renderTestTemplate(defaultFooStructValue,{depth:2});expect(element.find("grr-form-proto-single-field").length).toBe(0);browserTriggerEvent(icon(element,"plus"),"click");expect(element.find("grr-form-proto-single-field").length).toBe(3);expectNoIcon(element,"plus");expectIcon(element,"minus")});it("collapses if expanded and minus icon is clicked",function(){var element=renderTestTemplate(defaultFooStructValue,{depth:2});browserTriggerEvent(icon(element,"plus"),"click");browserTriggerEvent(icon(element,
"minus"),"click");expect(element.find("grr-form-proto-single-field").length).toBe(0);expectNoIcon(element,"minus");expectIcon(element,"plus")})});describe("form for structure with 1 repeated field",function(){beforeEach(function(){var data={"Foo":{"default":{"type":"Foo","value":{}},"doc":"This is a structure Foo.","fields":[{"default":{"mro":["PrimitiveType"],"type":"PrimitiveType","value":""},"doc":"Field 1 description.","dynamic":false,"friendly_name":"Field 1","index":1,"name":"field_1","repeated":true,
"type":"PrimitiveType"}],"kind":"struct","mro":["Foo","RDFProtoStruct"]},"PrimitiveType":{"default":{"type":"PrimitiveType","value":""},"doc":"Test primitive type description.","kind":"primitive","mro":["PrimitiveType"],"name":"PrimitiveType"}};spyOn(grrReflectionServiceMock,"getRDFValueDescriptor").and.callFake(function(type,opt_withDeps){var reflectionDeferred=$q.defer();reflectionDeferred.resolve(opt_withDeps?data:data[type]);return reflectionDeferred.promise})});it("does not prefill the model",
function(){var fooValue={type:"Foo",value:{}};renderTestTemplate(fooValue);expect(fooValue.value).toEqual({})});it("does not overwrite prefilled data",function(){var fooValue={type:"Foo",value:{field_1:[{type:"PrimitiveType",value:"42"}]}};renderTestTemplate(fooValue);expect(fooValue.value.field_1.length).toBe(1);expect(fooValue.value.field_1[0]).toEqual({type:"PrimitiveType",value:"42"})});it("updates the model when repeated field is changed",function(){var fooValue={type:"Foo",value:{}};var element=
renderTestTemplate(fooValue);var field=element.find("grr-form-proto-repeated-field:nth(0)");var fieldValue=field.scope().$eval(field.attr("value"));fieldValue.push({"type":"PrimitiveType",value:"42"});$rootScope.$apply();expect(fooValue.value).toEqual({field_1:[{type:"PrimitiveType",value:"42"}]})});it("renders the repeated field with corresponding directive",function(){var fooValue={type:"Foo",value:{}};var element=renderTestTemplate(fooValue);expect(element.find("grr-form-proto-repeated-field").length).toBe(1)});
it("does not render repeated field from the hidden-fields",function(){var fooValue={type:"Foo",value:{}};var element=renderTestTemplate(fooValue,undefined,["field_1"]);expect(element.find("grr-form-proto-repeated-field").length).toBe(0)})});describe("form for union-type structure",function(){beforeEach(function(){var data={"Foo":{"default":{"type":"Foo","value":{}},"doc":"This is a structure Foo.","union_field":"type","fields":[{"default":{"mro":["PrimitiveType"],"type":"PrimitiveType","value":""},
"doc":"Field 1 description.","dynamic":false,"friendly_name":"Union Type","index":1,"name":"type","repeated":true,"type":"PrimitiveType"}],"kind":"struct","mro":["Foo","RDFProtoStruct"]},"PrimitiveType":{"default":{"type":"PrimitiveType","value":""},"doc":"Test primitive type description.","kind":"primitive","mro":["PrimitiveType"],"name":"PrimitiveType"}};var reflectionDeferred=$q.defer();reflectionDeferred.resolve(data);spyOn(grrReflectionServiceMock,"getRDFValueDescriptor").and.callFake(function(type,
opt_withDeps){var reflectionDeferred=$q.defer();reflectionDeferred.resolve(opt_withDeps?data:data[type]);return reflectionDeferred.promise})});it("delegates union-type structure rendering",function(){var fooValue={type:"Foo",value:{}};var element=renderTestTemplate(fooValue);expect(element.find("grr-form-proto-union").length).toBe(1)})})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.forms.semanticProtoRepeatedFieldFormDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var159=goog.require("grrUi.tests");var browserTriggerEvent=$jscomp$destructuring$var159.browserTriggerEvent;var stubDirective=$jscomp$destructuring$var159.stubDirective;var testsModule=$jscomp$destructuring$var159.testsModule;var $jscomp$destructuring$var160=goog.require("grrUi.forms.forms");var formsModule=$jscomp$destructuring$var160.formsModule;
describe("semantic proto repeated field form directive",function(){var $compile;var $q;var $rootScope;beforeEach(module("/static/angular-components/forms/semantic-proto-repeated-field-form.html"));beforeEach(module(formsModule.name));beforeEach(module(testsModule.name));stubDirective("grrFormValue");beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");$q=$injector.get("$q")}));var renderTestTemplate=function(value,descriptor,field,noCustomTemplate){$rootScope.value=
value;$rootScope.descriptor=descriptor;$rootScope.field=field;$rootScope.noCustomTemplate=noCustomTemplate;var template='<grr-form-proto-repeated-field value="value" '+'descriptor="descriptor" field="field" '+'no-custom-template="noCustomTemplate" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};var typedPrimitiveValue={type:"PrimitiveType",value:42};var primitiveValueDescriptor={type:"PrimitiveType",mro:["PrimitiveType"],kind:"primitive",default:angular.copy(typedPrimitiveValue)};
describe("without custom directives",function(){beforeEach(inject(function($injector){var grrSemanticRepeatedFormDirectivesRegistryService=$injector.get("grrSemanticRepeatedFormDirectivesRegistryService");spyOn(grrSemanticRepeatedFormDirectivesRegistryService,"findDirectiveForType").and.callFake(function(type){var q=$q.defer();q.reject();return q.promise})}));it("renders doc and friendly name",function(){var element=renderTestTemplate([],primitiveValueDescriptor,{doc:"Field documentation",friendly_name:"Field friendly name"});
expect(element.find('label[title="Field documentation"]').length).not.toBe(0);expect(element.text()).toContain("Field friendly name")});it("delegates items rendering to grr-form-value",function(){var element=renderTestTemplate([{type:"PrimitiveType",value:42},{type:"PrimitiveType",value:43}],primitiveValueDescriptor,{});expect(element.find("grr-form-value").length).toBe(2)});it('adds new item when "Add" is clicked',function(){var value=[];var element=renderTestTemplate(value,primitiveValueDescriptor,
{});expect(element.find("grr-form-value").length).toBe(0);browserTriggerEvent($("button[name=Add]",element),"click");expect(element.find("grr-form-value").length).toBe(1);expect(angular.equals(value,[typedPrimitiveValue])).toBe(true);browserTriggerEvent($("button[name=Add]",element),"click");expect(element.find("grr-form-value").length).toBe(2);expect(angular.equals(value,[typedPrimitiveValue,typedPrimitiveValue])).toBe(true)});it('removes an item when "Remove" is clicked',function(){var value=[angular.copy(typedPrimitiveValue),
angular.copy(typedPrimitiveValue)];var element=renderTestTemplate(value,primitiveValueDescriptor,{});expect(element.find("grr-form-value").length).toBe(2);browserTriggerEvent($("button[name=Remove]:nth(0)",element),"click");expect(element.find("grr-form-value").length).toBe(1);expect(angular.equals(value,[typedPrimitiveValue])).toBe(true);browserTriggerEvent($("button[name=Remove]:nth(0)",element),"click");expect(element.find("grr-form-value").length).toBe(0);expect(value).toEqual([])})});describe("with custom directive",
function(){beforeEach(inject(function($injector){var grrSemanticRepeatedFormDirectivesRegistryService=$injector.get("grrSemanticRepeatedFormDirectivesRegistryService");spyOn(grrSemanticRepeatedFormDirectivesRegistryService,"findDirectiveForType").and.callFake(function(type){var q=$q.defer();q.resolve({directive_name:"fooBar"});return q.promise})}));it("renders doc and friendly name",function(){var element=renderTestTemplate([],primitiveValueDescriptor,{doc:"Field documentation",friendly_name:"Field friendly name"});
expect(element.find('label[title="Field documentation"]').length).not.toBe(0);expect(element.text()).toContain("Field friendly name")});it("delegates items rendering to grr-form-value",function(){var element=renderTestTemplate([],primitiveValueDescriptor,{});expect(element.find("foo-bar").length).toBe(1)});it("ignores custom directive if no-custom-template binding is true",function(){var element=renderTestTemplate([{type:"PrimitiveType",value:42},{type:"PrimitiveType",value:43}],primitiveValueDescriptor,
{},true);expect(element.find("foo-bar").length).toBe(0);expect(element.find("grr-form-value").length).toBe(2)})});describe('with custom directive with "hideCustomTemplateLabel" set',function(){beforeEach(inject(function($injector){var grrSemanticRepeatedFormDirectivesRegistryService=$injector.get("grrSemanticRepeatedFormDirectivesRegistryService");spyOn(grrSemanticRepeatedFormDirectivesRegistryService,"findDirectiveForType").and.callFake(function(type){var q=$q.defer();q.resolve({directive_name:"fooBar",
hideCustomTemplateLabel:true});return q.promise})}));it("does not render custom field's label",function(){var element=renderTestTemplate([],primitiveValueDescriptor,{});expect(element.find('label[title="Field documentation"]').length).toBe(0);expect(element.text()).not.toContain("Field friendly name");expect(element.find("foo-bar").length).toBe(1)})})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.forms.semanticProtoSingleFieldFormDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var161=goog.require("grrUi.forms.forms");var formsModule=$jscomp$destructuring$var161.formsModule;var $jscomp$destructuring$var162=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var162.testsModule;describe("semantic proto single field form directive",function(){var $compile;var $rootScope;beforeEach(module("/static/angular-components/forms/semantic-proto-form.html"));
beforeEach(module("/static/angular-components/forms/semantic-proto-union-form.html"));beforeEach(module("/static/angular-components/forms/semantic-proto-single-field-form.html"));beforeEach(module("/static/angular-components/forms/semantic-proto-repeated-field-form.html"));beforeEach(module(formsModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope")}));var renderTestTemplate=function(value,
field){$rootScope.value=value;$rootScope.field=field;var template='<grr-form-proto-single-field value="value" '+'field="field" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("renders doc and friendly name",function(){var element=renderTestTemplate({},{doc:"Field documentation",friendly_name:"Field friendly name"});expect(element.find('label[title="Field documentation"]').length).toBe(1);expect(element.text()).toContain("Field friendly name")});it("delegates rendering to grr-form-value",
function(){var element=renderTestTemplate({},{});expect(element.find("grr-form-value").length).toBe(1)})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.forms.semanticProtoUnionFormDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var163=goog.require("grrUi.forms.forms");var formsModule=$jscomp$destructuring$var163.formsModule;var $jscomp$destructuring$var164=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var164.testsModule;describe("semantic proto union form directive",function(){var $compile;var $q;var $rootScope;var descriptor;var grrReflectionService;
beforeEach(module("/static/angular-components/forms/semantic-proto-form.html"));beforeEach(module("/static/angular-components/forms/semantic-proto-union-form.html"));beforeEach(module("/static/angular-components/forms/semantic-proto-single-field-form.html"));beforeEach(module("/static/angular-components/forms/semantic-proto-repeated-field-form.html"));beforeEach(module(formsModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=$injector.get("$compile");
$rootScope=$injector.get("$rootScope");$q=$injector.get("$q");grrReflectionService=$injector.get("grrReflectionService");grrReflectionService.getRDFValueDescriptor=function(valueType){var deferred=$q.defer();deferred.resolve({name:valueType,mro:[valueType]});return deferred.promise};descriptor={"default":{"mro":["Foo","RDFProtoStruct"],"type":"Foo","value":{}},"doc":"This is a structure Foo.","union_field":"type","fields":[{"default":{"mro":["PrimitiveType"],"type":"PrimitiveType","value":""},"index":1,
"name":"type","repeated":false,"type":"PrimitiveType"},{"default":{"mro":["PrimitiveTypeFoo"],"type":"PrimitiveTypeFoo","value":"foo"},"index":2,"name":"foo","repeated":false,"type":"PrimitiveTypeFoo"},{"default":{"mro":["PrimitiveTypeBar"],"type":"PrimitiveTypeBar","value":"bar"},"index":3,"name":"bar","repeated":false,"type":"PrimitiveTypeBar"}]}}));var renderTestTemplate=function(value){$rootScope.value=value;$rootScope.descriptor=descriptor;var template='<grr-form-proto-union value="value" '+
'descriptor="descriptor" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("displays field based on union field value",function(){var value={type:"Foo",mro:["Foo"],value:{type:{type:"PrimitiveType",mro:["PrimitiveType"],value:"foo"},foo:{type:"PrimitiveTypeFoo",mro:["PrimitiveTypeFoo"],value:42},bar:{type:"PrimitiveTypeBar",mro:["PrimitiveTypeBar"],value:43}}};var element=renderTestTemplate(value);expect(element.text()).toContain("No directive for type: PrimitiveTypeFoo");
expect(element.text()).not.toContain("No directive for type: PrimitiveTypeBar");value.value.type.value="bar";$rootScope.$apply();expect(element.text()).toContain("No directive for type: PrimitiveTypeBar");expect(element.text()).not.toContain("No directive for type: PrimitiveTypeFoo")});it("resets entered data when union type is changed",function(){var value={type:"Foo",mro:["Foo"],value:{type:{type:"PrimitiveType",mro:["PrimitiveType"],value:"foo"},foo:{type:"PrimitiveTypeFoo",mro:["PrimitiveTypeFoo"]},
bar:{type:"PrimitiveTypeBar",mro:["PrimitiveTypeBar"]}}};renderTestTemplate(value);$rootScope.$apply();value.value.foo.value=42;$rootScope.$apply();expect(value.value.foo.value).toBe(42);value.value.type.value="bar";$rootScope.$apply();expect(value.value.foo.value).toEqual({})})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.forms.semanticValueFormDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var165=goog.require("grrUi.forms.semanticValueFormDirective");var clearCaches=$jscomp$destructuring$var165.clearCaches;var $jscomp$destructuring$var166=goog.require("grrUi.forms.forms");var formsModule=$jscomp$destructuring$var166.formsModule;var $jscomp$destructuring$var167=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var167.testsModule;
describe("semantic value form directive",function(){var $compile;var $q;var $rootScope;var grrSemanticFormDirectivesRegistryService;var grrReflectionService;beforeEach(module(formsModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){clearCaches();$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");$q=$injector.get("$q");grrSemanticFormDirectivesRegistryService=$injector.get("grrSemanticFormDirectivesRegistryService");grrReflectionService=$injector.get("grrReflectionService");
grrReflectionService.getRDFValueDescriptor=function(valueType){var deferred=$q.defer();deferred.resolve({name:valueType,mro:[valueType]});return deferred.promise}}));var renderTestTemplate=function(value,metadata){$rootScope.value=value;$rootScope.metadata=metadata;var template='<grr-form-value value="value" metadata="metadata" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("shows error message if no corresponding directive found",function(){var fooValue={type:"Foo",
mro:["Foo"],value:"foo"};var element=renderTestTemplate(fooValue);expect(element.text()).toContain("No directive for type: Foo")});it("renders registered type with a corresponding directive",function(){var directiveMock={directive_name:"theTestDirective"};grrSemanticFormDirectivesRegistryService.registerDirective("Foo",directiveMock);var fooValue={type:"Foo",mro:["Foo"],value:"foo"};var element=renderTestTemplate(fooValue);expect($("the-test-directive",element).length).toBe(1);expect($("the-test-directive[value]",
element).length).toBe(1);expect($("the-test-directive[metadata]",element).length).toBe(1)});it("destroys nested directive's scope if value type is changed",function(){var directiveFooMock={directive_name:"theFooTestDirective"};var directiveBarMock={directive_name:"theBarTestDirective"};grrSemanticFormDirectivesRegistryService.registerDirective("Foo",directiveFooMock);grrSemanticFormDirectivesRegistryService.registerDirective("Bar",directiveBarMock);var fooValue={type:"Foo",mro:["Foo"],value:"foo"};
var barValue={type:"Bar",mro:["Bar"],value:"bar"};var element=renderTestTemplate(fooValue);expect($("the-foo-test-directive",element).length).toBe(1);var fooScope=$("the-foo-test-directive",element).scope();fooScope.foo=42;var firesCount=0;fooScope.$watch("foo",function(){firesCount+=1});$rootScope.$apply();expect(firesCount).toBe(1);fooScope.foo=43;$rootScope.$apply();expect(firesCount).toBe(2);angular.extend(fooValue,barValue);$rootScope.$apply();expect($("the-bar-test-directive",element).length).toBe(1);
fooScope.foo=44;$rootScope.$apply();expect(firesCount).toBe(2)})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.forms.timerangeFormDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var168=goog.require("grrUi.forms.forms");var formsModule=$jscomp$destructuring$var168.formsModule;var $jscomp$destructuring$var169=goog.require("grrUi.tests");var stubDirective=$jscomp$destructuring$var169.stubDirective;var testsModule=$jscomp$destructuring$var169.testsModule;describe("timerange form directive",function(){var $compile;var $q;var $rootScope;
var grrReflectionService;beforeEach(module("/static/angular-components/forms/timerange-form.html"));beforeEach(module(formsModule.name));beforeEach(module(testsModule.name));stubDirective("grrFormValue");beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");$q=$injector.get("$q");grrReflectionService=$injector.get("grrReflectionService");spyOn(grrReflectionService,"getRDFValueDescriptor").and.callFake(function(valueType){var deferred=$q.defer();
if(valueType==="RDFDatetime")deferred.resolve({default:{type:"RDFDatetime",value:0}});else if(valueType==="Duration")deferred.resolve({default:{type:"Duration",value:0}});return deferred.promise})}));var renderTestTemplate=function(startTimeSecs,durationSecs,startTimeLabel,durationLabel){$rootScope.startTimeSecs=startTimeSecs;$rootScope.durationSecs=durationSecs;if(angular.isDefined(startTimeLabel))$rootScope.startTimeLabel=startTimeLabel;if(angular.isDefined(durationLabel))$rootScope.durationLabel=
durationLabel;var template="<grr-form-timerange "+'start-time-secs="startTimeSecs" '+'duration-secs="durationSecs" '+(angular.isDefined(startTimeLabel)?'start-time-label="startTimeLabel" ':"")+(angular.isDefined(durationLabel)?'duration-label="durationLabel" ':"")+"></grr-form-timerange>";var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("shows the given scope params initially",function(){var element=renderTestTemplate(123,456);var directive=element.find("grr-form-value:nth(0)");
expect(directive.scope().$eval(directive.attr("value"))).toEqual({type:"RDFDatetime",value:123E6});directive=element.find("grr-form-value:nth(1)");expect(directive.scope().$eval(directive.attr("value"))).toEqual({type:"Duration",value:456})});it("shows default labels by default",function(){var element=renderTestTemplate(123,456);expect(element.find("label:nth(0)").text()).toBe("Time range start time");expect(element.find("label:nth(1)").text()).toBe("Time range duration")});it("shows custom labels if given",
function(){var element=renderTestTemplate(123,456,"Custom start time label","Custom duration label");expect(element.find("label:nth(0)").text()).toBe("Custom start time label");expect(element.find("label:nth(1)").text()).toBe("Custom duration label")});it("forwards changed values to parent scope",function(){var element=renderTestTemplate(123,456);var directive=element.find("grr-form-value:nth(0)");directive.scope().$eval(directive.attr("value")+".value = 321000000");directive=element.find("grr-form-value:nth(1)");
directive.scope().$eval(directive.attr("value")+".value = 654");$rootScope.$apply();expect(element.scope().$eval(element.attr("start-time-secs"))).toEqual(321);expect(element.scope().$eval(element.attr("duration-secs"))).toEqual(654)})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.forms.utilsTest");goog.setTestOnly();var $jscomp$destructuring$var170=goog.require("grrUi.forms.utils");var valueHasErrors=$jscomp$destructuring$var170.valueHasErrors;describe("forms utils",function(){describe("valueHasErrors",function(){it("returns false for a primitive value without errors",function(){expect(valueHasErrors({type:"RDFString",value:"blah"})).toBe(false)});it("returns true for a primitive value with an error",function(){expect(valueHasErrors({type:"RDFString",
value:"blah",validationError:"Oh no!"})).toBe(true)});it("returns false for a value with a struct field without errors",function(){expect(valueHasErrors({type:"RDFString",value:{foo:{type:"RDFInteger",value:42}}})).toBe(false)});it("returns true for a value with a struct field with an error",function(){expect(valueHasErrors({type:"RDFString",value:{foo:{type:"RDFInteger",value:42,validationError:"Oh no!"}}})).toBe(true)});it("returns false for a value with an array field without errors",function(){expect(valueHasErrors({type:"RDFString",
value:{foo:[{type:"RDFInteger",value:42}]}})).toBe(false)});it("returns true for a value with an array field with an error",function(){expect(valueHasErrors({type:"RDFString",value:{foo:[{type:"RDFInteger",value:42,validationError:"Oh no!"}]}})).toBe(true)})})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.hunt.huntStatsDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var171=goog.require("grrUi.hunt.hunt");var huntModule=$jscomp$destructuring$var171.huntModule;var $jscomp$destructuring$var172=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var172.testsModule;describe("hunt stats directive",function(){var $compile;var $q;var $rootScope;var grrApiService;beforeEach(module("/static/angular-components/hunt/hunt-stats.html"));
beforeEach(module(huntModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");$q=$injector.get("$q");grrApiService=$injector.get("grrApiService")}));var render=function(huntId){$rootScope.huntId=huntId;var template='<grr-hunt-stats hunt-id="huntId" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("shows user cpu usage histogram",function(){var statsResponse=
{stats:{type:"ClientResourcesStats",value:{user_cpu_stats:{type:"RunningStats",value:{histogram:{type:"StatsHistogram",value:{bins:[{type:"StatsHistogramBin",value:{num:{type:"long",value:10.55},range_max_value:{type:"float",value:16.55}}},{type:"StatsHistogramBin",value:{num:{type:"long",value:5.55},range_max_value:{type:"float",value:32768.55}}}]}}}}}}};$.plot=jasmine.createSpy("$.plot spy").and.callFake(function(element,series,options){expect(element.hasClass("user-cpu-histogram")).toBeTruthy();
expect(series[0].data.length).toEqual(2);expect(series[0].data[0]).toEqual([0,10.55]);expect(series[0].data[1]).toEqual([1,5.55]);expect(options.xaxis.ticks).toEqual([[.5,"16.6"],[1.5,"32768.6"]])});var deferred=$q.defer();deferred.resolve({data:statsResponse});spyOn(grrApiService,"get").and.returnValue(deferred.promise);render("H:12345678");expect(grrApiService.get).toHaveBeenCalledWith("/hunts/H:12345678/stats");expect($.plot).toHaveBeenCalled()});it("shows system cpu usage histogram",function(){var statsResponse=
{stats:{type:"ClientResourcesStats",value:{system_cpu_stats:{type:"RunningStats",value:{histogram:{type:"StatsHistogram",value:{bins:[{type:"StatsHistogramBin",value:{num:{type:"long",value:10.55},range_max_value:{type:"float",value:16.55}}},{type:"StatsHistogramBin",value:{num:{type:"long",value:5.55},range_max_value:{type:"float",value:32768.55}}}]}}}}}}};$.plot=jasmine.createSpy("$.plot spy").and.callFake(function(element,series,options){expect(element.hasClass("system-cpu-histogram")).toBeTruthy();
expect(series[0].data.length).toEqual(2);expect(series[0].data[0]).toEqual([0,10.55]);expect(series[0].data[1]).toEqual([1,5.55]);expect(options.xaxis.ticks).toEqual([[.5,"16.6"],[1.5,"32768.6"]])});var deferred=$q.defer();deferred.resolve({data:statsResponse});spyOn(grrApiService,"get").and.returnValue(deferred.promise);render("H:12345678");expect(grrApiService.get).toHaveBeenCalledWith("/hunts/H:12345678/stats");expect($.plot).toHaveBeenCalled()});it("shows network bytes histogram with correct values and xaxis labels",
function(){var statsResponse={stats:{type:"ClientResourcesStats",value:{network_bytes_sent_stats:{type:"RunningStats",value:{histogram:{type:"StatsHistogram",value:{bins:[{type:"StatsHistogramBin",value:{num:{type:"long",value:10},range_max_value:{type:"float",value:16}}},{type:"StatsHistogramBin",value:{num:{type:"long",value:5},range_max_value:{type:"float",value:32768}}}]}}}}}}};$.plot=jasmine.createSpy("$.plot spy").and.callFake(function(element,series,options){expect(element.hasClass("network-bytes-histogram")).toBeTruthy();
expect(series[0].data.length).toEqual(2);expect(series[0].data[0]).toEqual([0,10]);expect(series[0].data[1]).toEqual([1,5]);expect(options.xaxis.ticks).toEqual([[.5,"16B"],[1.5,"32K"]])});var deferred=$q.defer();deferred.resolve({data:statsResponse});spyOn(grrApiService,"get").and.returnValue(deferred.promise);render("H:12345678");expect(grrApiService.get).toHaveBeenCalledWith("/hunts/H:12345678/stats");expect($.plot).toHaveBeenCalled()})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.outputPlugins.outputPluginLogsDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var173=goog.require("grrUi.tests");var browserTriggerEvent=$jscomp$destructuring$var173.browserTriggerEvent;var stubDirective=$jscomp$destructuring$var173.stubDirective;var testsModule=$jscomp$destructuring$var173.testsModule;var $jscomp$destructuring$var174=goog.require("grrUi.outputPlugins.outputPlugins");var outputPluginsModule=$jscomp$destructuring$var174.outputPluginsModule;
describe("output plugin logs directive",function(){var $compile;var $q;var $rootScope;var $timeout;var grrApiService;beforeEach(module("/static/angular-components/output-plugins/output-plugin-logs.html"));beforeEach(module("/static/angular-components/output-plugins/output-plugin-logs-modal.html"));beforeEach(module(outputPluginsModule.name));beforeEach(module(testsModule.name));stubDirective("grrPagedFilteredTable");beforeEach(inject(function($injector){$q=$injector.get("$q");$compile=$injector.get("$compile");
$timeout=$injector.get("$timeout");$rootScope=$injector.get("$rootScope");grrApiService=$injector.get("grrApiService")}));var renderTestTemplate=function(){$rootScope.url="foo/bar";var template='<grr-output-plugin-logs url="url" label="a foo"'+'css-class="label-danger" icon="foo-icon" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("fetches and show items count",function(){var deferred=$q.defer();deferred.resolve({data:{total_count:42}});spyOn(grrApiService,"get").and.returnValue(deferred.promise);
var element=renderTestTemplate();expect(element.text()).toContain("42")});it("shows nothing if total_count is 0",function(){var deferred=$q.defer();deferred.resolve({data:{total_count:0}});spyOn(grrApiService,"get").and.returnValue(deferred.promise);var element=renderTestTemplate();expect(element.text().trim()).toBe("")});describe("inspect dialog",function(){beforeEach(function(){var deferred=$q.defer();deferred.resolve({data:{total_count:42}});spyOn(grrApiService,"get").and.returnValue(deferred.promise)});
afterEach(function(){$(document.body).html("")});it("is shown when label is clicked",function(){var element=renderTestTemplate();browserTriggerEvent(element.find(".label"),"click");expect($(document.body).text()).toContain("Inspect a foo")});it("closes when close button is clicked",function(){var element=renderTestTemplate();browserTriggerEvent(element.find(".label"),"click");browserTriggerEvent($("button.close"),"click");$timeout.flush();expect($(document.body).text()).not.toContain("Inspect a foo")})})});
exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.outputPlugins.outputPluginNoteBodyDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var175=goog.require("grrUi.outputPlugins.outputPlugins");var outputPluginsModule=$jscomp$destructuring$var175.outputPluginsModule;var $jscomp$destructuring$var176=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var176.testsModule;describe("output plugin note directive",function(){var $compile;var $rootScope;var grrOutputPluginsDirectivesRegistryService;
beforeEach(module(outputPluginsModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");grrOutputPluginsDirectivesRegistryService=$injector.get("grrOutputPluginsDirectivesRegistryService")}));var defaultOutputPlugin={value:{plugin_descriptor:{value:{plugin_name:{value:"Foo"}}}}};var renderTestTemplate=function(outputPlugin){$rootScope.outputPlugin=outputPlugin||angular.copy(defaultOutputPlugin);
var template="<grr-output-plugin-note-body "+'output-plugin="outputPlugin" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("shows nothing if no corresponding directive found",function(){var element=renderTestTemplate();expect(element.text().trim()).toBe("")});it("renders registered type with a corresponding directive",function(){var directiveMock={directive_name:"theTestDirective"};grrOutputPluginsDirectivesRegistryService.registerDirective("Foo",directiveMock);
var element=renderTestTemplate();expect($("the-test-directive",element).length).toBe(1)});it("passes outputPlugin to the corresponding directive",function(){var directiveMock={directive_name:"theTestDirective"};grrOutputPluginsDirectivesRegistryService.registerDirective("Foo",directiveMock);var element=renderTestTemplate();var directive=element.find("the-test-directive");expect(directive.scope().$eval(directive.attr("output-plugin"))).toEqual(defaultOutputPlugin)})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.outputPlugins.outputPluginNoteDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var177=goog.require("grrUi.outputPlugins.outputPlugins");var outputPluginsModule=$jscomp$destructuring$var177.outputPluginsModule;var $jscomp$destructuring$var178=goog.require("grrUi.tests");var stubDirective=$jscomp$destructuring$var178.stubDirective;var testsModule=$jscomp$destructuring$var178.testsModule;describe("output plugin note directive",
function(){var $compile;var $rootScope;var grrOutputPluginsDirectivesRegistryService;beforeEach(module("/static/angular-components/output-plugins/output-plugin-note.html"));beforeEach(module(outputPluginsModule.name));beforeEach(module(testsModule.name));stubDirective("grrOutputPluginNoteBody");stubDirective("grrOutputPluginLogs");beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");grrOutputPluginsDirectivesRegistryService=$injector.get("grrOutputPluginsDirectivesRegistryService")}));
var defaultOutputPlugin={value:{plugin_descriptor:{value:{plugin_name:{value:"Foo"}}},id:{value:"42"}}};var renderTestTemplate=function(outputPlugin){$rootScope.outputPlugin=outputPlugin||angular.copy(defaultOutputPlugin);$rootScope.outputPluginsUrl="/foo/bar";var template='<grr-output-plugin-note output-plugin="outputPlugin" '+'output-plugins-url="outputPluginsUrl" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("shows registered plugin title if registered",
function(){var element=renderTestTemplate();expect(element.text()).toContain("");var directiveMock={directive_name:"theTestDirective",output_plugin_title:"a bar plugin"};grrOutputPluginsDirectivesRegistryService.registerDirective("Foo",directiveMock);element=renderTestTemplate();expect(element.text()).toContain("a bar plugin")});it("shows plugin descriptor name if not registered",function(){var element=renderTestTemplate();expect(element.text()).toContain("Foo")});it("delegates rendering to grr-output-plugin-note-body",
function(){var element=renderTestTemplate();var body=element.find("grr-output-plugin-note-body");expect(body.scope().$eval(body.attr("output-plugin"))).toEqual(defaultOutputPlugin)});it("delegates logs info rendering to grr-output-plugin-logs",function(){var element=renderTestTemplate();var logs=element.find("grr-output-plugin-logs:nth(0)");expect(logs.scope().$eval(logs.attr("url"))).toEqual("/foo/bar/42/logs")});it("delegates errors info rendering to grr-output-plugin-logs",function(){var element=
renderTestTemplate();var errors=element.find("grr-output-plugin-logs:nth(1)");expect(errors.scope().$eval(errors.attr("url"))).toEqual("/foo/bar/42/errors")})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.outputPlugins.outputPluginsNotesDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var179=goog.require("grrUi.outputPlugins.outputPlugins");var outputPluginsModule=$jscomp$destructuring$var179.outputPluginsModule;var $jscomp$destructuring$var180=goog.require("grrUi.tests");var stubDirective=$jscomp$destructuring$var180.stubDirective;var testsModule=$jscomp$destructuring$var180.testsModule;describe("output plugins notes list directive",
function(){var $compile;var $q;var $rootScope;var grrApiService;beforeEach(module("/static/angular-components/output-plugins/"+"output-plugins-notes.html"));beforeEach(module(outputPluginsModule.name));beforeEach(module(testsModule.name));stubDirective("grrOutputPluginNote");beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");$q=$injector.get("$q");grrApiService=$injector.get("grrApiService")}));var renderTestTemplate=function(){$rootScope.outputPluginsUrl=
"/foo/bar/plugins";var template="<grr-output-plugins-notes "+'output-plugins-url="outputPluginsUrl" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("requests output plugins metadata via API service",function(){var deferred=$q.defer();spyOn(grrApiService,"get").and.returnValue(deferred.promise);renderTestTemplate();expect(grrApiService.get).toHaveBeenCalledWith("/foo/bar/plugins")});it("shows an error when API request fails",function(){var deferred=$q.defer();
spyOn(grrApiService,"get").and.returnValue(deferred.promise);deferred.reject({data:{message:"FAIL"}});var element=renderTestTemplate();expect(element.text()).toContain("Can't fetch output plugins list: "+"FAIL")});it("delegates every plugin display to grr-output-plugin-note",function(){var deferred=$q.defer();spyOn(grrApiService,"get").and.returnValue(deferred.promise);var plugin1={value:"foo"};var plugin2={value:"bar"};deferred.resolve({data:{items:[plugin1,plugin2]}});var element=renderTestTemplate();
expect(element.find("grr-output-plugin-note").length).toBe(2);var directive=element.find("grr-output-plugin-note:nth(0)");expect(directive.scope().$eval(directive.attr("output-plugin"))).toEqual(plugin1);directive=element.find("grr-output-plugin-note:nth(1)");expect(directive.scope().$eval(directive.attr("output-plugin"))).toEqual(plugin2)})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.routing.aff4UrnToUrlTest");goog.setTestOnly();var $jscomp$destructuring$var181=goog.require("grrUi.routing.aff4UrnToUrl");var aff4UrnToUrl=$jscomp$destructuring$var181.aff4UrnToUrl;describe("aff4UrnToUrl()",function(){it("doesn't convert random string",function(){expect(aff4UrnToUrl("aff4:/foo/bar")).toBe(null)});it("converts non-flow and non-vfs URN in client scope to the client link",function(){expect(aff4UrnToUrl("aff4:/C.0001000200030004/foo/bar")).toEqual({state:"client",
params:{clientId:"C.0001000200030004"}})});it("converts client-scoped fs/os-prefixed URN to VFS link",function(){expect(aff4UrnToUrl("aff4:/C.0001000200030004/fs/os/foo/bar")).toEqual({state:"client.vfs",params:{clientId:"C.0001000200030004",path:"fs/os/foo/bar"}})});it("converts client-scoped flow URN to a flow link",function(){expect(aff4UrnToUrl("aff4:/C.0001000200030004/flows/F:123456")).toEqual({state:"client.flows",params:{clientId:"C.0001000200030004",flowId:"F:123456"}})});it("converts hunt URN to a hunt link",
function(){expect(aff4UrnToUrl("aff4:/hunts/H:123456")).toEqual({state:"hunts",params:{huntId:"H:123456"}})});it("converts cron job URN to a cron job link",function(){expect(aff4UrnToUrl("aff4:/cron/SomeCronJob")).toEqual({state:"crons",params:{cronJobId:"SomeCronJob"}})});it("converts client approval URN to a client approval link",function(){expect(aff4UrnToUrl("aff4:/ACL/C.0001000200030004/test/approval_id")).toEqual({state:"clientApproval",params:{clientId:"C.0001000200030004",username:"test",
approvalId:"approval_id"}})});it("converts hunt approval URN to a hunt approval link",function(){expect(aff4UrnToUrl("aff4:/ACL/hunts/H:123456/test/approval_id")).toEqual({state:"huntApproval",params:{huntId:"H:123456",username:"test",approvalId:"approval_id"}})});it("converts cron job approval URN to a cron job approval link",function(){expect(aff4UrnToUrl("aff4:/ACL/cron/SomeCronJob/test/approval_id")).toEqual({state:"cronJobApproval",params:{cronJobId:"SomeCronJob",username:"test",approvalId:"approval_id"}})});
it("handles non-URL-friendly characters correctly",function(){expect(aff4UrnToUrl("aff4:/C.0001000200030004/fs/os/_f$o/bA%")).toEqual({state:"client.vfs",params:{clientId:"C.0001000200030004",path:"fs/os/_f$o/bA%"}})})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.routing.rewriteUrlTest");goog.setTestOnly();var $jscomp$destructuring$var182=goog.require("grrUi.routing.rewriteUrl");var rewriteUrl=$jscomp$destructuring$var182.rewriteUrl;describe("rewriteUrl()",function(){var mapping={};mapping["main=ManageCron"]="/crons/";mapping["main=ManageCron&cron_job_urn=aff4:/cron/CleanTemp"]="/crons/CleanTemp";mapping["main=ManageHunts"]="/hunts/";mapping["main=ManageHunts&hunt_id=aff4:/hunts/H:123456"]=
"/hunts/H:123456";mapping["main=VirtualFileSystemView&c=C.dc1a70ddaaba407a&tag=AFF4Stats"+"&t=_fs-tsk-_5C_5C_3F_5CVolume_7B649ac6fa_2D9ab4_"+"2D11e5_2Db332_2D806e6f6e6963_7D"]="/clients/C.dc1a70ddaaba407a/vfs/fs/tsk/"+"%5C%5C%3F%5CVolume%7B649ac6fa-9ab4-11e5-b332-806e6f6e6963%7D/";mapping["main=GlobalLaunchFlows"]="/global-flows";mapping["main=ServerLoadView"]="/server-load";mapping["main=BinaryConfigurationView"]="/manage-binaries";mapping["main=ConfigManager"]="/config";mapping["main=ArtifactManagerView"]=
"/artifacts";mapping["main=ApiDocumentation"]="/api-docs";mapping["main=GrantAccess&acl="+"aff4%3A%2FACL%2Fhunts%2FH%3A55AAAA70%2Ftest%2Fapproval%3A6AFF3CC9"]="/users/test/approvals/hunt/H:55AAAA70/approval:6AFF3CC9";mapping["main=GrantAccess&acl="+"aff4%3A%2FACL%2FC.833c593a0fe6aca0%2Ftest%2Fapproval%3A8935BE23"]="/users/test/approvals/client/C.833c593a0fe6aca0/approval:8935BE23";mapping["main=CanaryTestRenderer"]="/canary-test";mapping["main=HostTable"]="/search?q=";mapping["main=HostTable&q=test"]=
"/search?q=test";it("should map legacy URLs to correct sane URLs",function(){angular.forEach(mapping,function(targetUrl,legacyUrl){expect(rewriteUrl(legacyUrl)).toEqual(targetUrl)})})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.semantic.byteSizeDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var183=goog.require("grrUi.semantic.semantic");var semanticModule=$jscomp$destructuring$var183.semanticModule;var $jscomp$destructuring$var184=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var184.testsModule;describe("grrByteSize directive",function(){var $compile;var $rootScope;beforeEach(module("/static/angular-components/semantic/byte-size.html"));
beforeEach(module(semanticModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope")}));var renderTestTemplate=function(value){$rootScope.value=value;var template='<grr-byte-size value="value" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it('shows "-" when value is empty',function(){var value={type:"ByteSize",value:null};var element=renderTestTemplate(value);
expect(element.text().trim()).toBe("-")});it("shows 0 if value is 0",function(){var value={type:"ByteSize",value:0};var element=renderTestTemplate(value);expect(element.text().trim()).toBe("0")});it("shows value in bytes if it is less than 1024",function(){var value={type:"ByteSize",value:42};var element=renderTestTemplate(value);expect(element.text().trim()).toBe("42B")});it("shows value in kibibytes if it is less than 1024**2",function(){var value={type:"ByteSize",value:1124};var element=renderTestTemplate(value);
expect(element.text().trim()).toBe("1.1KiB")});it("shows value in mebibytes if it is less than 1024**3",function(){var value={type:"ByteSize",value:44040192};var element=renderTestTemplate(value);expect(element.text().trim()).toBe("42MiB")});it("shows value in gibibytes if it is more than 1024**3",function(){var value={type:"ByteSize",value:1610612736};var element=renderTestTemplate(value);expect(element.text().trim()).toBe("1.5GiB")});it("shows value in bytes in the tooltip",function(){var value=
{type:"ByteSize",value:1610612736};var element=renderTestTemplate(value);expect(element.find("span").attr("title")).toBe("1610612736 bytes")})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.semantic.bytesDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var185=goog.require("grrUi.tests");var browserTriggerEvent=$jscomp$destructuring$var185.browserTriggerEvent;var testsModule=$jscomp$destructuring$var185.testsModule;var $jscomp$destructuring$var186=goog.require("grrUi.semantic.semantic");var semanticModule=$jscomp$destructuring$var186.semanticModule;describe("bytes directive",function(){var $compile;var $rootScope;
beforeEach(module("/static/angular-components/semantic/bytes.html"));beforeEach(module(semanticModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope")}));var renderTestTemplate=function(value){$rootScope.value=value;var template='<grr-bytes value="value" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("shows nothing when value is empty",function(){var value=
{type:"RDFBytes",value:null};var element=renderTestTemplate(value);expect(element.text().trim()).toBe("")});it("shows error message if value is incorrectly base64-encoded",function(){var value={type:"RDFBytes",value:"--"};var element=renderTestTemplate(value);expect(element.text().trim()).toMatch(/base64decodeerror.*:--/)});it("converts base64-encoded value into a hex-encoded string",function(){var macAddress={type:"MacAddress",value:"Zm9vDcg="};var element=renderTestTemplate(macAddress);expect(element.text()).toContain("foo\\x0d\\xc8")});
it("hides content behind a link if its longer than 1024 bytes",function(){var value={type:"RDFBytes",value:Array(1025).join("-")};var element=renderTestTemplate(value);expect(element.text()).not.toMatch(/base64decodeerror.*:--/);expect(element.text()).toContain("Show bytes...");browserTriggerEvent($("a",element),"click");expect(element.text()).toMatch(/base64decodeerror.*:--/);expect(element.text()).not.toContain("Show bytes...")})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.semantic.clientUrnDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var187=goog.require("grrUi.tests");var browserTriggerEvent=$jscomp$destructuring$var187.browserTriggerEvent;var testsModule=$jscomp$destructuring$var187.testsModule;var $jscomp$destructuring$var188=goog.require("grrUi.semantic.semantic");var semanticModule=$jscomp$destructuring$var188.semanticModule;describe("client urn directive",function(){var $compile;
var $q;var $rootScope;var $timeout;var grrApiService;beforeEach(module("/static/angular-components/semantic/client-urn.html"));beforeEach(module("/static/angular-components/semantic/client-urn-modal.html"));beforeEach(module(semanticModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$q=$injector.get("$q");$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");$timeout=$injector.get("$timeout");grrApiService=$injector.get("grrApiService")}));
var renderTestTemplate=function(value){$rootScope.value=value;var template='<grr-client-urn value="value" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("does not show anything when value is empty",function(){var element=renderTestTemplate(null);expect(element.text().trim()).toBe("")});it("shows string value",function(){var element=renderTestTemplate("aff4:/C.0000000000000001");expect(element.text()).toContain("C.0000000000000001")});it("shows value with type information",
function(){var clientUrn={age:0,type:"ClientURN",value:"aff4:/C.0000000000000001"};var element=renderTestTemplate(clientUrn);expect(element.text()).toContain("C.0000000000000001")});it("has a proper href",function(){var clientUrn={age:0,type:"ClientURN",value:"aff4:/C.0000000000000001"};var element=renderTestTemplate(clientUrn);expect(element.find("a").attr("href")).toBe("#!/clients/C.0000000000000001/host-info")});describe("client urn summary modal dialog",function(){beforeEach(function(){grrApiService.get=
function(urn,params){expect(urn).toBe("clients/C.0000000000000001");return $q(function(resolve,reject){resolve({data:"This is a summary"})})}});afterEach(function(){$(document.body).html("")});it("is shown when info button is clicked",function(){var element=renderTestTemplate("aff4:/C.0000000000000001");browserTriggerEvent($("button",element),"click");expect($(document.body).text()).toContain("Client C.0000000000000001")});it('is shown when info button is clicked and value has no "aff4" prefix',function(){var element=
renderTestTemplate("C.0000000000000001");browserTriggerEvent($("button",element),"click");expect($(document.body).text()).toContain("Client C.0000000000000001")});it("closed when close button is clicked",function(){var element=renderTestTemplate("aff4:/C.0000000000000001");browserTriggerEvent($("button",element),"click");expect($(document.body).text()).toContain("Client C.0000000000000001");browserTriggerEvent($("button.close"),"click");$timeout.flush();expect($(document.body).text()).not.toContain("Client C.0000000000000001")})})});
exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.semantic.dataObjectDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var189=goog.require("grrUi.semantic.semantic");var semanticModule=$jscomp$destructuring$var189.semanticModule;var $jscomp$destructuring$var190=goog.require("grrUi.tests");var stubDirective=$jscomp$destructuring$var190.stubDirective;var testsModule=$jscomp$destructuring$var190.testsModule;describe("data object semantic directive",function(){var $compile;
var $rootScope;beforeEach(module("/static/angular-components/semantic/data-object.html"));beforeEach(module(semanticModule.name));beforeEach(module(testsModule.name));stubDirective("grrSemanticValue");beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope")}));var renderTestTemplate=function(value){$rootScope.value=value;var template='<grr-data-object value="value" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};
it("shows empty table when value is empty",function(){var element=renderTestTemplate({type:"ApiDataObject",value:{}});expect(element.find("table").length).toBe(1);expect(element.find("tr").length).toBe(0)});it("shows 2 rows for a data object with two key-value pairs",function(){var element=renderTestTemplate({type:"ApiDataObject",value:{items:[{type:"ApiDataObjectKeyValuePair",value:{key:{type:"unicode",value:"Test Integer Value"},value:{type:"RDFInteger",value:1E3}}},{type:"ApiDataObjectKeyValuePair",
value:{key:{type:"unicode",value:"Test String Value"},value:{type:"RDFString",value:"<some value>"}}}]}});expect(element.find("table").length).toBe(1);expect(element.find("tr").length).toBe(2);expect(element.text()).toContain("Test Integer Value");expect(element.text()).toContain("Test String Value");expect(element.find("grr-semantic-value").length).toBe(2)})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.semantic.dictDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var191=goog.require("grrUi.semantic.semantic");var semanticModule=$jscomp$destructuring$var191.semanticModule;var $jscomp$destructuring$var192=goog.require("grrUi.tests");var stubDirective=$jscomp$destructuring$var192.stubDirective;var testsModule=$jscomp$destructuring$var192.testsModule;describe("dict semantic directive",function(){var $compile;var $rootScope;
beforeEach(module("/static/angular-components/semantic/dict.html"));beforeEach(module(semanticModule.name));beforeEach(module(testsModule.name));stubDirective("grrSemanticValue");beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope")}));var renderTestTemplate=function(value){$rootScope.value=value;var template='<grr-dict value="value" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("shows empty table when value is empty",
function(){var element=renderTestTemplate({type:"dict",value:{}});expect(element.find("table").length).toBe(1);expect(element.find("tr").length).toBe(0)});it("shows 2 keys and corresponding values for value with 2 keys",function(){var element=renderTestTemplate({type:"dict",value:{fooKey:{type:"Foo"},barKey:{type:"Bar"}}});expect(element.find("table").length).toBe(1);expect(element.find("tr").length).toBe(2);expect(element.text()).toContain("fooKey");expect(element.text()).toContain("barKey");expect(element.find("grr-semantic-value").length).toBe(2)})});
exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.semantic.durationDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var193=goog.require("grrUi.semantic.semantic");var semanticModule=$jscomp$destructuring$var193.semanticModule;var $jscomp$destructuring$var194=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var194.testsModule;describe("duration directive",function(){var $compile;var $rootScope;beforeEach(module(semanticModule.name));beforeEach(module(testsModule.name));
beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope")}));var renderTestTemplate=function(value){$rootScope.value=value;var template='<grr-duration value="value" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it('shows "-" when value is empty',function(){var value={type:"Duration",value:null};var element=renderTestTemplate(value);expect(element.text().trim()).toBe("-")});it("shows 0 if duration value is 0",
function(){var value={type:"Duration",value:0};var element=renderTestTemplate(value);expect(element.text().trim()).toBe("0")});it("shows duration in seconds if it's not divisible by 60",function(){var value={type:"Duration",value:122};var element=renderTestTemplate(value);expect(element.text().trim()).toBe("122s")});it("shows duration in minutes if possible",function(){var value={type:"Duration",value:120};var element=renderTestTemplate(value);expect(element.text().trim()).toBe("2m")});it("shows duration in hours if possible",
function(){var value={type:"Duration",value:7200};var element=renderTestTemplate(value);expect(element.text().trim()).toBe("2h")});it("shows duration in days if possible",function(){var value={type:"Duration",value:172800};var element=renderTestTemplate(value);expect(element.text().trim()).toBe("2d")});it("shows duration in weeks if possible",function(){var value={type:"Duration",value:1209600};var element=renderTestTemplate(value);expect(element.text().trim()).toBe("2w")});it("shows duration in days if not divisible by 7",
function(){var value={type:"Duration",value:1036800};var element=renderTestTemplate(value);expect(element.text().trim()).toBe("12d")})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.semantic.encryptionKeyDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var195=goog.require("grrUi.semantic.semantic");var semanticModule=$jscomp$destructuring$var195.semanticModule;var $jscomp$destructuring$var196=goog.require("grrUi.semantic.encryptionKeyDirective");var stringifyEncryptionKey=$jscomp$destructuring$var196.stringifyEncryptionKey;var $jscomp$destructuring$var197=goog.require("grrUi.tests");var testsModule=
$jscomp$destructuring$var197.testsModule;describe("encryption key directive",function(){describe("stringifyEncryptionKey()",function(){it("converts base64 encoded string of zeroes to a hex-string",function(){expect(stringifyEncryptionKey("AAAAAA==")).toBe("00000000")});it("converts sample base64 encoded string to a hex-string",function(){expect(stringifyEncryptionKey("AAABAgMEBQYHCAkKCwwNDg8Q")).toBe("00000102030405060708090a0b0c0d0e0f10")})});var $compile;var $rootScope;beforeEach(module(semanticModule.name));
beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope")}));var renderTestTemplate=function(value){$rootScope.value=value;var template='<grr-encryption-key value="value" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("shows nothing when value is empty",function(){var element=renderTestTemplate(undefined);expect(element.text().trim()).toBe("")});it("shows hex-stringified bytes when value is not empty",
function(){var element=renderTestTemplate({type:"EncryptionKey",value:"AAABAgMEBQYHCAkKCwwNDg8Q"});expect(element.text().trim()).toBe("00000102030405060708090a0b0c0d0e0f10")})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.semantic.exactDurationDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var198=goog.require("grrUi.semantic.semantic");var semanticModule=$jscomp$destructuring$var198.semanticModule;var $jscomp$destructuring$var199=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var199.testsModule;describe("exact duration directive",function(){var $compile;var $rootScope;beforeEach(module(semanticModule.name));beforeEach(module(testsModule.name));
beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope")}));var renderExactDuration=function(value){$rootScope.value=value;var template='<grr-exact-duration value="value" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it('shows "-" when value is empty',function(){var value={type:"Duration",value:null};var element=renderExactDuration(value);expect(element.text().trim()).toBe("-")});it("handles zero-values correctly",
function(){var value={type:"Duration",value:0};var element=renderExactDuration(value);expect(element.text().trim()).toBe("0s")});it("correctly renders whole seconds",function(){var value={type:"Duration",value:42};var element=renderExactDuration(value);expect(element.text().trim()).toBe("42s")});it("correctly renders whole minutes",function(){var value={type:"Duration",value:120};var element=renderExactDuration(value);expect(element.text().trim()).toBe("2m")});it("correctly renders whole hours",function(){var value=
{type:"Duration",value:3600};var element=renderExactDuration(value);expect(element.text().trim()).toBe("1h")});it("correctly renders compound values",function(){var value={type:"Duration",value:131+(new Date("2000-01-20")-new Date("2000-01-01"))/1E3};var element=renderExactDuration(value);expect(element.text().trim()).toBe("2w 5d 2m 11s")});it("rounds to nearest seconds",function(){var value={type:"Duration",value:62.5};var element=renderExactDuration(value);expect(element.text().trim()).toBe("1m 3s")});
it("raises on negative duration values",function(){var value={type:"Duration",value:-11};expect(function(){return renderExactDuration(value)}).toThrow()})});return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.semantic.flowIdDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var200=goog.require("grrUi.client.client");var clientModule=$jscomp$destructuring$var200.clientModule;var $jscomp$destructuring$var201=goog.require("grrUi.semantic.semantic");var semanticModule=$jscomp$destructuring$var201.semanticModule;var $jscomp$destructuring$var202=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var202.testsModule;describe("grr-flow-id directive",
function(){var $compile;var $rootScope;beforeEach(module("/static/angular-components/semantic/flow-id.html"));beforeEach(module(clientModule.name));beforeEach(module(semanticModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope")}));var renderTestTemplate=function(value,clientId){$rootScope.value=value;var template='<grr-flow-id value="value"></grr-flow-id>';if(clientId){$rootScope.clientId=
clientId;template='<grr-client-context client-id="clientId">'+template+"</grr-client-context>"}var element=$compile(template)($rootScope);$rootScope.$apply();return element};var sampleValue={value:"F:112233",type:"ApiFlowId"};describe("without client context",function(){it("renders flow id as a string",function(){var element=renderTestTemplate(sampleValue);expect(element.find('span:contains("F:112233")').length).toBe(1);expect(element.find('a:contains("F:112233")').length).toBe(0)})});describe("with client context",
function(){it("renders flow id as a link",function(){var element=renderTestTemplate(sampleValue,"C.1111222233334444");expect(element.find('span:contains("F:112233")').length).toBe(0);var aRef=element.find('a:contains("F:112233")');expect(aRef.length).toBe(1);expect(aRef.attr("href")).toBe("#!/clients/C.1111222233334444/flows/F%3A112233")});it("renders a tooltip with a client id",function(){var element=renderTestTemplate(sampleValue,"C.1111222233334444");var aref=element.find('a:contains("F:112233")');
expect(aref.attr("title")).toBe("Flow F:112233 ran on client C.1111222233334444")})})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.semantic.hashDigestDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var203=goog.require("grrUi.semantic.semantic");var semanticModule=$jscomp$destructuring$var203.semanticModule;var $jscomp$destructuring$var204=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var204.testsModule;describe("hash digest directive",function(){var $compile;var $rootScope;beforeEach(module(semanticModule.name));beforeEach(module(testsModule.name));
beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope")}));var renderTestTemplate=function(value){$rootScope.value=value;var template='<grr-hash-digest value="value" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("shows nothing when value is empty",function(){var value={type:"HashDigest",value:null};var element=renderTestTemplate(value);expect(element.text().trim()).toBe("")});it("shows error message if value is incorrectly base64-encoded",
function(){var value={type:"HashDigest",value:"--"};var element=renderTestTemplate(value);expect(element.text().trim()).toMatch(/base64decodeerror.*:--/)});it("converts base64-encoded value into a hex-encoded string",function(){var base64EncodedHash={type:"HashDigest",value:"dGVzdA=="};var element=renderTestTemplate(base64EncodedHash);expect(element.text()).toContain("74657374")})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.semantic.hashListDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var205=goog.require("grrUi.semantic.semantic");var semanticModule=$jscomp$destructuring$var205.semanticModule;var $jscomp$destructuring$var206=goog.require("grrUi.tests");var stubDirective=$jscomp$destructuring$var206.stubDirective;var testsModule=$jscomp$destructuring$var206.testsModule;describe("hash list directive",function(){var $compile;var $rootScope;
beforeEach(module(semanticModule.name));beforeEach(module(testsModule.name));stubDirective("grrSemanticValue");beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope")}));var renderTestTemplate=function(value){$rootScope.value=value;var template='<grr-hash-list value="value" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("shows nothing when value is empty",function(){var value={type:"HashList",value:null};
var element=renderTestTemplate(value);expect(element.find("grr-hash-digest").length).toBe(0)});it("delegates single item to grr-semantic-value",function(){var base64EncodedHashList={type:"HashList",value:"MTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTE="};var element=renderTestTemplate(base64EncodedHashList);var directive=element.find("grr-semantic-value");expect(angular.equals(directive.scope().$eval(directive.attr("value"))),[{type:"HashDigest",value:"MTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTE="}])});
it("delegates two items to grr-hash-digest",function(){var base64EncodedHashList={type:"HashList",value:"MTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTE"+"yMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMg=="};var element=renderTestTemplate(base64EncodedHashList);var directive=element.find("grr-semantic-value");expect(angular.equals(directive.scope().$eval(directive.attr("value"))),[{type:"HashDigest",value:"MTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTE="},{type:"HashDigest",value:"MjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjI="}])})});
exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.semantic.jsonDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var207=goog.require("grrUi.tests");var browserTriggerEvent=$jscomp$destructuring$var207.browserTriggerEvent;var testsModule=$jscomp$destructuring$var207.testsModule;var $jscomp$destructuring$var208=goog.require("grrUi.semantic.semantic");var semanticModule=$jscomp$destructuring$var208.semanticModule;describe("json directive",function(){var $compile;var $rootScope;
beforeEach(module("/static/angular-components/semantic/json.html"));beforeEach(module(semanticModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope")}));var renderTestTemplate=function(value){$rootScope.value=value;var template='<grr-json value="value" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("shows nothing when value is empty",function(){var value=
{type:"ZippedJSONBytes",value:null};var element=renderTestTemplate(value);expect(element.text().trim()).toBe("")});it("shows error message if value is not correct json",function(){var value={type:"ZippedJSONBytes",value:"--"};var element=renderTestTemplate(value);expect(element.text().trim()).toMatch(/jsonerror.*:--/)});it("shows json string when it's a correct json string",function(){var value={type:"ZippedJSONBytes",value:'[{"foo": 42}]'};var element=renderTestTemplate(value);expect(element.text()).toContain('"foo": 42')});
it("hides content behind a link if its longer than 1024 bytes",function(){var value={type:"ZippedJSONBytes",value:Array(1025).join("-")};var element=renderTestTemplate(value);expect(element.text()).not.toMatch(/base64decodeerror.*:--/);expect(element.text()).toContain("Show JSON...");browserTriggerEvent($("a",element),"click");expect(element.text()).toMatch(/jsonerror.*:--/);expect(element.text()).not.toContain("Show JSON...")})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.semantic.macAddressDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var209=goog.require("grrUi.semantic.semantic");var semanticModule=$jscomp$destructuring$var209.semanticModule;var $jscomp$destructuring$var210=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var210.testsModule;describe("mac address directive",function(){var $compile;var $rootScope;beforeEach(module(semanticModule.name));beforeEach(module(testsModule.name));
beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope")}));var renderTestTemplate=function(value){$rootScope.value=value;var template='<grr-mac-address value="value" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it('shows "-" when value is empty',function(){var macAddress={type:"MacAddress",value:null};var element=renderTestTemplate(macAddress);expect(element.text().trim()).toBe("-")});it("expands base64-encoded value into a human-readable string",
function(){var macAddress={type:"MacAddress",value:"+BZUBnli"};var element=renderTestTemplate(macAddress);expect(element.text()).toContain("f8:16:54:06:79:62")})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.semantic.networkAddressDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var211=goog.require("grrUi.semantic.semantic");var semanticModule=$jscomp$destructuring$var211.semanticModule;var $jscomp$destructuring$var212=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var212.testsModule;describe("mac address directive",function(){var $compile;var $rootScope;beforeEach(module(semanticModule.name));beforeEach(module(testsModule.name));
beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope")}));var renderTestTemplate=function(value){$rootScope.value=value;var template='<grr-network-address value="value" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it('shows "-" when value is null',function(){var element=renderTestTemplate(null);expect(element.text().trim()).toBe("-")});it("shows IPv4 value for IPv4 address without metadata",function(){var element=
renderTestTemplate({packed_bytes:"+BZUBn",address_type:"INET"});expect(element.text()).toContain("248.22.84.06")});it("shows IPv4 value for IPv4 address with metadata",function(){var element=renderTestTemplate({value:{packed_bytes:{value:"+BZUBn"},address_type:{value:"INET"}}});expect(element.text()).toContain("248.22.84.06")});it("shows IPv6 value for IPv6 address without metadata",function(){var element=renderTestTemplate({packed_bytes:"+BZUBnliBnl",address_type:"INET6"});expect(element.text()).toContain("f816:5406:7962:0679")});
it("shows IPv6 value for IPv6 address with metadata",function(){var element=renderTestTemplate({value:{packed_bytes:{value:"+BZUBnliBnl"},address_type:{value:"INET6"}}});expect(element.text()).toContain("f816:5406:7962:0679")})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.semantic.semanticDiffAnnotatedProtoDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var213=goog.require("grrUi.semantic.semantic");var semanticModule=$jscomp$destructuring$var213.semanticModule;var $jscomp$destructuring$var214=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var214.testsModule;describe("grr-semantic-diff-annotated-proto directive",function(){var $compile;var $q;var $rootScope;var grrReflectionService;
beforeEach(module("/static/angular-components/semantic/semantic-diff-annotated-proto.html"));beforeEach(module(semanticModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");$q=$injector.get("$q");grrReflectionService=$injector.get("grrReflectionService");spyOn(grrReflectionService,"getRDFValueDescriptor");var descriptors={"Bar":{},"Foo":{fields:[{name:"a"},{name:"foo"},{name:"bar"}]}};grrReflectionService.getRDFValueDescriptor.and.callFake(function(typeName){var deferred=
$q.defer();deferred.resolve(descriptors[typeName]);return deferred.promise})}));var renderTestTemplate=function(value){$rootScope.value=value;var template='<grr-semantic-diff-annotated-proto value="value" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it('renders only after the "value" binding is set',function(){var element=renderTestTemplate(undefined);expect(element.find('td:contains("foo")').length).toBe(0);$rootScope.value={type:"Foo",value:{foo:{type:"Bar",
value:42}}};$rootScope.$apply();expect(element.find('td:contains("foo")').length).toBe(1)});it('"value" binding is effectively a one-time binding',function(){var value={type:"Foo",value:{foo:{type:"Bar",value:42}}};var element=renderTestTemplate(value);expect(element.find('td:contains("bar")').length).toBe(0);var newValue=angular.copy(value);newValue["value"]["bar"]={type:"Bar",value:43};$rootScope.value=newValue;$rootScope.$apply();expect(element.find('td:contains("bar")').length).toBe(0)});angular.forEach(["added",
"changed","removed"],function(annotation){it('renders "'+annotation+'" annotation on the value itself correctly',function(){var value={type:"Foo",value:42,_diff:annotation};var element=renderTestTemplate(value);expect(element.find("table.diff-"+annotation).length).toBe(1)});it('renders "'+annotation+'"-annotated non-repeated field correctly',function(){var value={type:"Foo",value:{a:{type:"Bar",value:42,_diff:annotation}}};var element=renderTestTemplate(value);expect(element.find("tr.diff-"+annotation).length).toBe(1)});
it('renders "'+annotation+'"-annotated repeated field correctly',function(){var value={type:"Foo",value:{a:[{type:"Bar",value:42,_diff:annotation}]}};var element=renderTestTemplate(value);expect(element.find("div.repeated.diff-"+annotation).length).toBe(1)})})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.semantic.semanticProtoDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var215=goog.require("grrUi.semantic.semanticProtoDirective");var buildItems=$jscomp$destructuring$var215.buildItems;var buildNonUnionItems=$jscomp$destructuring$var215.buildNonUnionItems;var buildUnionItems=$jscomp$destructuring$var215.buildUnionItems;var getUnionFieldValue=$jscomp$destructuring$var215.getUnionFieldValue;var $jscomp$destructuring$var216=
goog.require("grrUi.semantic.semantic");var semanticModule=$jscomp$destructuring$var216.semanticModule;var $jscomp$destructuring$var217=goog.require("grrUi.tests");var stubDirective=$jscomp$destructuring$var217.stubDirective;var testsModule=$jscomp$destructuring$var217.testsModule;describe("semantic proto directive",function(){describe("getUnionFieldValue()",function(){it("throws if descriptor doesn't have union_field",function(){expect(function(){getUnionFieldValue({},{})}).toThrow()});it("returns union field value when it's set",
function(){var value={type:"FooType",value:{action_type:{type:"unicode",value:"DOWNLOAD"}}};var descriptor={union_field:"action_type"};expect(getUnionFieldValue(value,descriptor)).toBe("download")});it("returns union field value default if it's not set",function(){var value={type:"FooType",value:{}};var descriptor={union_field:"action_type",fields:[{name:"action_type",default:{type:"unicode",value:"DOWNLOAD"}}]};expect(getUnionFieldValue(value,descriptor)).toBe("download")})});describe("buildUnionItems()",
function(){var descriptor={union_field:"action_type",fields:[{name:"action_type",default:{type:"unicode",value:"SEND_TO_SOCKET"}},{name:"download",default:{type:"unicode",value:"defaultFoo"}},{name:"send_to_socket",default:{type:"unicode",value:"defaultBar"}}]};var valueWithSetFields={type:"FooType",value:{action_type:{type:"unicode",value:"DOWNLOAD"},download:{type:"unicode",value:"foo"},send_to_socket:{type:"unicode",value:"bar"}}};var valueWithUnsetFields={type:"FooType",value:{}};it("excludes fields not pointed by set union field value",
function(){var items=buildUnionItems(valueWithSetFields,descriptor);for(var i=0;i<items.length;++i)expect(items[i].key).not.toBe("send_to_socket")});it("excludes fields not pointed by default union field value",function(){var items=buildUnionItems(valueWithUnsetFields,descriptor);for(var i=0;i<items.length;++i)expect(items[i].key).not.toBe("download")});it("includes union field when it's set",function(){var items=buildUnionItems(valueWithSetFields,descriptor);expect(items[0]["key"]).toBe("action_type");
expect(items[0]["value"]["value"]).toBe("DOWNLOAD")});it("includes union field value when it's set",function(){var items=buildUnionItems(valueWithSetFields,descriptor);expect(items[1]["key"]).toBe("download");expect(items[1]["value"]["value"]).toBe("foo")});it("includes union field default when it's not set",function(){var items=buildUnionItems(valueWithUnsetFields,descriptor);expect(items[0]["key"]).toBe("action_type");expect(items[0]["value"]["value"]).toBe("SEND_TO_SOCKET")});it("includes union field value default when it's not set",
function(){var items=buildUnionItems(valueWithUnsetFields,descriptor);expect(items[1]["key"]).toBe("send_to_socket");expect(items[1]["value"]["value"]).toBe("defaultBar")})});describe("buildNonUnionItems()",function(){var descriptor={fields:[{name:"foo",default:{type:"unicode",value:"defaultFoo"}},{name:"bar",default:{type:"unicode",value:"defaultBar"}}]};var value={type:"Struct",value:{foo:{type:"unicode",value:"theFoo"}}};it("includes set fields only",function(){var items=buildNonUnionItems(value,
descriptor);expect(items.length).toBe(1);expect(items[0]["key"]).toBe("foo");expect(items[0]["value"]["value"]).toBe("theFoo")})});describe("buildItems()",function(){it("builds items for a non-union-type value",function(){var descriptor={fields:[{name:"foo"}]};var value={type:"Struct",value:{foo:{type:"unicode",value:"theFoo"}}};var items=buildItems(value,descriptor);expect(items.length).toBe(1);expect(items[0]["key"]).toBe("foo");expect(items[0]["value"]["value"]).toBe("theFoo")});it("builds items for a union-type value",
function(){var descriptor={union_field:"action_type",fields:[{name:"action_type"},{name:"send_to_socket"}]};var valueWithSetFields={type:"FooType",value:{action_type:{type:"unicode",value:"SEND_TO_SOCKET"},send_to_socket:{type:"unicode",value:"bar"}}};var items=buildItems(valueWithSetFields,descriptor);expect(items[0]["key"]).toBe("action_type");expect(items[0]["value"]["value"]).toBe("SEND_TO_SOCKET");expect(items[1]["key"]).toBe("send_to_socket");expect(items[1]["value"]["value"]).toBe("bar")})});
var $compile;var $q;var $rootScope;var grrReflectionService;beforeEach(module("/static/angular-components/semantic/semantic-proto.html"));beforeEach(module(semanticModule.name));beforeEach(module(testsModule.name));stubDirective("grrSemanticValue");beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");$q=$injector.get("$q");grrReflectionService=$injector.get("grrReflectionService");spyOn(grrReflectionService,"getRDFValueDescriptor")}));var renderTestTemplate=
function(value,descriptors){$rootScope.value=value;if(descriptors)grrReflectionService.getRDFValueDescriptor.and.callFake(function(typeName){var deferred=$q.defer();deferred.resolve(descriptors[typeName]);return deferred.promise});var template='<grr-semantic-proto value="value" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it('renders only after the "value" binding is set',function(){var element=renderTestTemplate(undefined,{"Struct":{fields:[{name:"foo"}]}});
expect(element.find('td:contains("foo")').length).toBe(0);$rootScope.value={type:"Struct",value:{foo:{type:"unicode",value:"theFoo"}}};$rootScope.$apply();expect(element.find('td:contains("foo")').length).toBe(1)});it('"value" binding is effectively a one-time binding',function(){var value={type:"Struct",value:{foo:{type:"unicode",value:"theFoo"}}};var element=renderTestTemplate(value,{"Struct":{fields:[{name:"foo",name:"bar"}]}});expect(element.find('td:contains("bar")').length).toBe(0);var newValue=
angular.copy(value);newValue["value"]["bar"]={type:"unicode",value:"theBar"};$rootScope.value=newValue;$rootScope.$apply();expect(element.find('td:contains("bar")').length).toBe(0)});describe("with non-union-type value",function(){it("does not show anything when value is empty",function(){var element=renderTestTemplate(null);expect(element.text().trim()).toBe("")});it("respects fields order",function(){var element=renderTestTemplate({type:"RDFProtoStruct",value:{client_id:{type:"unicode",value:"client_id"},
system_info:{type:"unicode",value:"system_info"},client_info:{type:"unicode",value:"client_info"}}},{"unicode":{},"RDFProtoStruct":{fields:[{name:"client_id"},{name:"system_info"},{name:"client_info"}]}});expect($("tr:nth(0)",element).text()).toContain("client_id");expect($("tr:nth(1)",element).text()).toContain("system_info");expect($("tr:nth(2)",element).text()).toContain("client_info");element=renderTestTemplate({type:"RDFProtoStruct",value:{client_id:{type:"unicode",value:"client_id"},system_info:{type:"unicode",
value:"system_info"},client_info:{type:"unicode",value:"client_info"}}},{"RDFProtoStruct":{fields:[{name:"client_info"},{name:"system_info"},{name:"client_id"}]}});expect($("tr:nth(0)",element).text()).toContain("client_info");expect($("tr:nth(1)",element).text()).toContain("system_info");expect($("tr:nth(2)",element).text()).toContain("client_id")})});describe("with union-type values",function(){var valueWithSetValues={type:"RDFProtoStruct",value:{action_type:{type:"unicode",value:"SEND_TO_SOCKET"},
download:{type:"unicode",value:"foo"},send_to_socket:{type:"unicode",value:"bar"}}};var valueWithUnsetValues={type:"RDFProtoStruct",value:{}};var descriptors={"unicode":{},"RDFProtoStruct":{union_field:"action_type",fields:[{name:"action_type",default:{type:"unicode",value:"DOWNLOAD"}},{name:"download",default:{type:"unicode",value:"foo"}},{name:"send_to_socket",default:{type:"unicode",value:"bar"}}]}};it("doesn't show inactive union fields",function(){var element=renderTestTemplate(valueWithSetValues,
descriptors);expect($("tr",element).length).toBe(2);expect($("tr:nth(0)",element).text()).not.toContain("download");expect($("tr:nth(1)",element).text()).not.toContain("download")});it("shows action type when explicitly set",function(){var element=renderTestTemplate(valueWithSetValues,descriptors);expect($("tr:nth(0)",element).text()).toContain("action_type")});it("shows active union field when explicitly set",function(){var element=renderTestTemplate(valueWithSetValues,descriptors);expect($("tr:nth(1)",
element).text()).toContain("send_to_socket")});it("shows action type when not explicitly set",function(){var element=renderTestTemplate(valueWithUnsetValues,descriptors);expect($("tr:nth(0)",element).text()).toContain("action_type")});it("shows active union field when not explicitly set",function(){var element=renderTestTemplate(valueWithUnsetValues,descriptors);expect($("tr:nth(1)",element).text()).toContain("download")})})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.semantic.semanticProtosDiffDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var218=goog.require("grrUi.semantic.semanticProtosDiffDirective");var diffAnnotate=$jscomp$destructuring$var218.diffAnnotate;describe("grrSemanticProtosDiff directive",function(){describe("diffAnnotate()",function(){it("does nothing for 2 plain equal data structures",function(){var value={type:"Foo",value:{a:{type:"RDFString",value:"foo"},b:{type:"RDFInteger",
value:42}}};var originalValue=angular.copy(value);var newValue=angular.copy(value);diffAnnotate(originalValue,newValue);expect(originalValue).toEqual(value);expect(newValue).toEqual(value)});it("marks changed primitive attribute as changed",function(){var originalValue={type:"Foo",value:{a:{type:"RDFString",value:"foo"}}};var newValue={type:"Foo",value:{a:{type:"RDFString",value:"bar"}}};diffAnnotate(originalValue,newValue);expect(originalValue).toEqual({type:"Foo",value:{a:{type:"RDFString",value:"foo",
_diff:"changed"}}});expect(newValue).toEqual({type:"Foo",value:{a:{type:"RDFString",value:"bar",_diff:"changed"}}})});it("marks primitive attribute as changed on type change",function(){var originalValue={type:"Foo",value:{a:{type:"RDFString",value:"foo"}}};var newValue={type:"Foo",value:{a:{type:"ClientURN",value:"foo"}}};diffAnnotate(originalValue,newValue);expect(originalValue).toEqual({type:"Foo",value:{a:{type:"RDFString",value:"foo",_diff:"changed"}}});expect(newValue).toEqual({type:"Foo",value:{a:{type:"ClientURN",
value:"foo",_diff:"changed"}}})});it("marks added primitive attribute as added",function(){var originalValue={type:"Foo",value:{a:{type:"RDFString",value:"foo"}}};var newValue={type:"Foo",value:{a:{type:"RDFString",value:"foo"},b:{type:"RDFString",value:"bar"}}};diffAnnotate(originalValue,newValue);expect(originalValue).toEqual({type:"Foo",value:{a:{type:"RDFString",value:"foo"}}});expect(newValue).toEqual({type:"Foo",value:{a:{type:"RDFString",value:"foo"},b:{type:"RDFString",value:"bar",_diff:"added"}}})});
it("marks removed primitive attribute as removed",function(){var originalValue={type:"Foo",value:{a:{type:"RDFString",value:"foo"},b:{type:"RDFString",value:"bar"}}};var newValue={type:"Foo",value:{a:{type:"RDFString",value:"foo"}}};diffAnnotate(originalValue,newValue);expect(originalValue).toEqual({type:"Foo",value:{a:{type:"RDFString",value:"foo"},b:{type:"RDFString",value:"bar",_diff:"removed"}}});expect(newValue).toEqual({type:"Foo",value:{a:{type:"RDFString",value:"foo"}}})});it("marks added and removed primitive attributes in the same value",
function(){var originalValue={type:"Foo",value:{a:{type:"RDFString",value:"foo"},b:{type:"RDFString",value:"bar"}}};var newValue={type:"Foo",value:{a:{type:"RDFString",value:"foo"},c:{type:"RDFString",value:"aha"}}};diffAnnotate(originalValue,newValue);expect(originalValue).toEqual({type:"Foo",value:{a:{type:"RDFString",value:"foo"},b:{type:"RDFString",value:"bar",_diff:"removed"}}});expect(newValue).toEqual({type:"Foo",value:{a:{type:"RDFString",value:"foo"},c:{type:"RDFString",value:"aha",_diff:"added"}}})});
it("marks primitive item added to a list as added",function(){var originalValue=[{type:"RDFString",value:"foo"}];var newValue=[{type:"RDFString",value:"foo"},{type:"RDFString",value:"bar"}];diffAnnotate(originalValue,newValue);expect(originalValue).toEqual([{type:"RDFString",value:"foo"}]);expect(newValue).toEqual([{type:"RDFString",value:"foo"},{type:"RDFString",value:"bar",_diff:"added"}])});it("marks primitive item removed from a list as removed",function(){var originalValue=[{type:"RDFString",
value:"foo"},{type:"RDFString",value:"bar"}];var newValue=[{type:"RDFString",value:"foo"}];diffAnnotate(originalValue,newValue);expect(originalValue).toEqual([{type:"RDFString",value:"foo"},{type:"RDFString",value:"bar",_diff:"removed"}]);expect(newValue).toEqual([{type:"RDFString",value:"foo"}])});it("marks changed list item as added and removed",function(){var originalValue=[{type:"RDFString",value:"foo"}];var newValue=[{type:"RDFString",value:"bar"}];diffAnnotate(originalValue,newValue);expect(originalValue).toEqual([{type:"RDFString",
value:"foo",_diff:"removed"}]);expect(newValue).toEqual([{type:"RDFString",value:"bar",_diff:"added"}])});it("treats lists as unchanged if the order of items changed",function(){var originalValue=[{type:"RDFString",value:"foo"},{type:"RDFString",value:"bar"}];var savedOriginalValue=angular.copy(originalValue);var newValue=[{type:"RDFString",value:"bar"},{type:"RDFString",value:"foo"}];var savedNewValue=angular.copy(newValue);diffAnnotate(originalValue,newValue);expect(originalValue).toEqual(savedOriginalValue);
expect(newValue).toEqual(savedNewValue)});it("treats lists as unchanged if duplicate items were added",function(){var originalValue=[{type:"RDFString",value:"foo"}];var savedOriginalValue=angular.copy(originalValue);var newValue=[{type:"RDFString",value:"foo"},{type:"RDFString",value:"foo"}];var savedNewValue=angular.copy(newValue);diffAnnotate(originalValue,newValue);expect(originalValue).toEqual(savedOriginalValue);expect(newValue).toEqual(savedNewValue)})})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.semantic.semanticValueDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var219=goog.require("grrUi.semantic.semanticValueDirective");var clearCaches=$jscomp$destructuring$var219.clearCaches;var getCachedSingleValueTemplate=$jscomp$destructuring$var219.getCachedSingleValueTemplate;var $jscomp$destructuring$var220=goog.require("grrUi.semantic.semantic");var semanticModule=$jscomp$destructuring$var220.semanticModule;var $jscomp$destructuring$var221=
goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var221.testsModule;describe("semantic value directive",function(){var $compile;var $q;var $rootScope;var grrSemanticValueDirectivesRegistryService;var grrReflectionService;beforeEach(module(semanticModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){clearCaches();$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");$q=$injector.get("$q");grrSemanticValueDirectivesRegistryService=
$injector.get("grrSemanticValueDirectivesRegistryService");grrReflectionService=$injector.get("grrReflectionService");grrReflectionService.getRDFValueDescriptor=function(valueType){var deferred=$q.defer();deferred.resolve({name:valueType,mro:[valueType]});return deferred.promise}}));var renderTestTemplate=function(value){$rootScope.value=value;var template='<grr-semantic-value value="value" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("does not show anything when value is null",
function(){var element=renderTestTemplate(null);expect(element.text().trim()).toBe("")});it("does not show anything when value is undefined",function(){var element=renderTestTemplate(undefined);expect(element.text().trim()).toBe("")});it("renders plain string values",function(){var element=renderTestTemplate("foobar");expect(element.text().trim()).toBe("foobar")});it("renders plain integer values",function(){var element=renderTestTemplate(42);expect(element.text().trim()).toBe("42")});it("renders list of plain string values",
function(){var element=renderTestTemplate(["elem1","elem2","elem3"]);expect(element.text().trim()).toBe("elem1 elem2 elem3")});it("renders list of plain integer values",function(){var element=renderTestTemplate([41,42,43]);expect(element.text().trim()).toBe("41 42 43")});it("renders richly typed value with a registered directive",function(){var directiveMock={directive_name:"theTestDirective"};grrSemanticValueDirectivesRegistryService.registerDirective("NonExistentType",directiveMock);var element=
renderTestTemplate({type:"NonExistentType",value:42});expect($("the-test-directive",element).length).toBe(1);expect($('the-test-directive[value="::value"]',element).length).toBe(1)});it("renders list of typed values with registered directives",function(){var directiveMock1={directive_name:"theTestDirective1"};grrSemanticValueDirectivesRegistryService.registerDirective("NonExistentType1",directiveMock1);var directiveMock2={directive_name:"theTestDirective2"};grrSemanticValueDirectivesRegistryService.registerDirective("NonExistentType2",
directiveMock2);var directiveMock3={directive_name:"theTestDirective3"};grrSemanticValueDirectivesRegistryService.registerDirective("NonExistentType3",directiveMock3);var element=renderTestTemplate([{type:"NonExistentType1",value:41},{type:"NonExistentType2",value:42},{type:"NonExistentType3",value:43}]);expect($("the-test-directive1",element).length).toBe(1);expect($("the-test-directive2",element).length).toBe(1);expect($("the-test-directive3",element).length).toBe(1)});it("renders typed values as strings when there's no handler",
function(){var element=renderTestTemplate({type:"NonExistentType",value:42});expect(element.text().trim()).toBe("42")});it("respects type override done with grr-semantic-value-registry-override",function(){var directiveMock={directive_name:"theTestDirective"};grrSemanticValueDirectivesRegistryService.registerDirective("SomeType",directiveMock);var overrideDirectiveMock={directive_name:"theTestDirectiveOverride"};$rootScope.override=overrideDirectiveMock;$rootScope.value={type:"SomeType",value:42};
var template="<grr-semantic-value-registry-override "+"map=\"{'SomeType': override}\">"+'<grr-semantic-value value="value"></grr-semantic-value>'+"</grr-semantic-value-registry-override>";var element=$compile(template)($rootScope);$rootScope.$apply();expect($("the-test-directive-override",element).length).toBe(1)});it("respects the override even if an RDF type was rendered once before",function(){var directiveMock={directive_name:"theTestDirective"};grrSemanticValueDirectivesRegistryService.registerDirective("SomeType",
directiveMock);var element=renderTestTemplate({type:"SomeType",value:42});expect($("the-test-directive",element).length).toBe(1);var overrideDirectiveMock={directive_name:"theTestDirectiveOverride"};$rootScope.override=overrideDirectiveMock;var template="<grr-semantic-value-registry-override "+"map=\"{'SomeType': override}\">"+'<grr-semantic-value value="value"></grr-semantic-value>'+"</grr-semantic-value-registry-override>";element=$compile(template)($rootScope);$rootScope.$apply();expect($("the-test-directive-override",
element).length).toBe(1)});it("caches templates for overrides using unique keys",function(){var directiveMock={directive_name:"theTestDirective"};grrSemanticValueDirectivesRegistryService.registerDirective("SomeType",directiveMock);var element=renderTestTemplate({type:"SomeType",value:42});expect($("the-test-directive",element).length).toBe(1);var overrideDirectiveMock={directive_name:"theTestDirectiveOverride"};$rootScope.override=overrideDirectiveMock;var template="<grr-semantic-value-registry-override "+
"map=\"{'SomeType': override, 'AnotherType': override}\">"+'<grr-semantic-value value="value"></grr-semantic-value>'+"</grr-semantic-value-registry-override>";element=$compile(template)($rootScope);$rootScope.$apply();expect(getCachedSingleValueTemplate("SomeType")).toBeDefined();expect(getCachedSingleValueTemplate("SomeType:AnotherType_theTestDirectiveOverride:"+"SomeType_theTestDirectiveOverride")).toBeDefined()})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.semantic.semanticVersionedProtoDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var222=goog.require("grrUi.tests");var browserTriggerEvent=$jscomp$destructuring$var222.browserTriggerEvent;var stubDirective=$jscomp$destructuring$var222.stubDirective;var testsModule=$jscomp$destructuring$var222.testsModule;var $jscomp$destructuring$var223=goog.require("grrUi.semantic.semantic");var semanticModule=$jscomp$destructuring$var223.semanticModule;
describe("semantic versioned proto directive",function(){var $compile;var $q;var $rootScope;var grrReflectionService;beforeEach(module("/static/angular-components/semantic/"+"semantic-versioned-proto.html"));beforeEach(module(semanticModule.name));beforeEach(module(testsModule.name));stubDirective("grrSemanticValue");beforeEach(inject(function($injector){$q=$injector.get("$q");$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");grrReflectionService=$injector.get("grrReflectionService");
var deferred=$q.defer();deferred.resolve({"TheType":{kind:"struct",fields:[{name:"field",type:"TheType"},{name:"foo",type:"RDFString"}],default:{}},"RDFString":{kind:"primitive",default:""}});grrReflectionService.getRDFValueDescriptor=jasmine.createSpy("getRDFValueDescriptor").and.returnValue(deferred.promise)}));var renderTestTemplate=function(value,callback,depth){$rootScope.value=value;$rootScope.callback=callback;$rootScope.depth=depth;var template="<grr-semantic-versioned-proto "+'value="value" history-depth="depth" '+
'on-field-click="callback(fieldPath)" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};var oneLevelValue={type:"TheType",value:{foo:{type:"RDFString",value:"blah"}}};var twoLevelValue={type:"TheType",value:{field:{type:"TheType",value:{foo:{type:"RDFString",value:"bar"}}},foo:{type:"RDFString",value:"blah"}}};it('renders only after the "value" binding is set',function(){var element=renderTestTemplate(undefined,function(){},1);expect(element.find(".proto_history button").length).toBe(0);
$rootScope.value=oneLevelValue;$rootScope.$apply();expect(element.find(".proto_history button").length).toBe(1)});it('"value" binding is effectively a one-time binding',function(){var element=renderTestTemplate(oneLevelValue,function(){},1);expect(element.find(".proto_history button").length).toBe(1);var newValue=angular.copy(oneLevelValue);newValue["value"]={};$rootScope.value=newValue;$rootScope.$apply();expect(element.find(".proto_history button").length).toBe(1)});it("adds history button to 1st-level field",
function(){var element=renderTestTemplate(oneLevelValue,function(){},1);expect(element.find(".proto_history button").length).toBe(1)});it("passes a correct field path for a 1st-level field",function(){var callback=jasmine.createSpy();var element=renderTestTemplate(oneLevelValue,callback,1);browserTriggerEvent(element.find(".proto_history button"),"click");expect(callback.calls.count()).toBe(1);expect(callback.calls.first().args).toEqual(["foo"])});it("adds history button to 2nd-level field",function(){var element=
renderTestTemplate(twoLevelValue,function(){},2);expect(element.find("td.proto_value .proto_history button").length).toBe(1)});it("passes a correct field path for a 2nd-level field",function(){var callback=jasmine.createSpy();var element=renderTestTemplate(twoLevelValue,callback,2);browserTriggerEvent(element.find("td.proto_value .proto_history button"),"click");expect(callback.calls.count()).toBe(1);expect(callback.calls.first().args).toEqual(["field.foo"])});it("does not add history button outside history-depth",
function(){var element=renderTestTemplate(twoLevelValue,function(){},1);expect(element.find("td.proto_value .proto_history button").length).toBe(0)})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.semantic.statExtFlagsLinuxDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var224=goog.require("grrUi.semantic.semantic");var semanticModule=$jscomp$destructuring$var224.semanticModule;var $jscomp$destructuring$var225=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var225.testsModule;var HTML_TEMPLATE_PATH="/static/angular-components/semantic/stat-ext-flags-linux.html";describe("stat ext-flags for Linux directive",
function(){var $compile;var $rootScope;beforeEach(module(HTML_TEMPLATE_PATH));beforeEach(module(semanticModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope")}));var render=function(value){$rootScope.value=value;var template='<grr-stat-ext-flags-linux value="value" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("handles empty values",function(){var element=
render(undefined);expect(element.text().trim()).toBe("none")});it("handles incorrect input type",function(){var element=render({value:"foo"});expect(element.text().trim()).toBe("malformed")});it("handles negative values",function(){var element=render({value:-1});expect(element.text().trim()).toBe("malformed")});it("handles non-integer values",function(){var element=render({value:5.13});expect(element.text().trim()).toBe("malformed")});it("indicates files without special flags",function(){var element=
render({value:0});expect(element.text().replace(/\s/g,"")).toBe("--------------------")});it("indicates regular files",function(){var element=render({value:524288});expect(element.text().replace(/\s/g,"")).toBe("-----------------e--")});it("indicates immutable files",function(){var element=render({value:524304});expect(element.text().replace(/\s/g,"")).toBe("----i------------e--")});it("indicates files non-dumpable support",function(){var element=render({value:524352});expect(element.text().replace(/\s/g,
"")).toBe("------d----------e--")})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.semantic.statExtFlagsOsxDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var226=goog.require("grrUi.semantic.semantic");var semanticModule=$jscomp$destructuring$var226.semanticModule;var $jscomp$destructuring$var227=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var227.testsModule;var HTML_TEMPLATE_URL="/static/angular-components/semantic/stat-ext-flags-osx.html";describe("stat ext-flags for Mac directive",
function(){var $compile;var $rootScope;beforeEach(module(HTML_TEMPLATE_URL));beforeEach(module(semanticModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope")}));var render=function(value){$rootScope.value=value;var template='<grr-stat-ext-flags-osx value="value" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("handles empty values",function(){var element=
render(undefined);expect(element.text().trim()).toBe("none")});it("handles incorrect input type",function(){var element=render({value:"foo"});expect(element.text().trim()).toBe("malformed")});it("handles negative values",function(){var element=render({vaue:-42});expect(element.text().trim()).toBe("malformed")});it("handles non-integer values",function(){var element=render({value:3.14});expect(element.text().trim()).toBe("malformed")});it("indicates regular files",function(){var element=render({value:0});
expect(element.text().trim()).toBe("")});it("indicates immutable files",function(){var element=render({value:2});expect(element.text().trim()).toBe("uimmutable")});it("indicates files with nodump flag",function(){var element=render({value:1});expect(element.text().trim()).toBe("nodump")});it("indicates files with multiple flags",function(){var element=render({value:196616});var text=element.text().trim();expect(text).toContain("opaque");expect(text).toContain("archived");expect(text).toContain("simmutable")});
it("ignores flags with unknown keywords",function(){var element=render({value:32});expect(element.text().trim()).toBe("")})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.semantic.statModeDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var228=goog.require("grrUi.semantic.semantic");var semanticModule=$jscomp$destructuring$var228.semanticModule;var $jscomp$destructuring$var229=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var229.testsModule;describe("stat mode directive",function(){var $compile;var $rootScope;beforeEach(module(semanticModule.name));beforeEach(module(testsModule.name));
beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope")}));var render=function(value){$rootScope.value=value;var template='<grr-stat-mode value="value" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("does not show anything when value is null",function(){var element=render(null);expect(element.text().trim()).toBe("-")});it("does not show anything when value is empty",function(){var element=render({});expect(element.text().trim()).toBe("-")});
it("indicates regular files",function(){var element=render({value:33188});expect(element.text().trim()).toBe("-rw-r--r--")});it("indicates directories",function(){var element=render({value:16832});expect(element.text().trim()).toBe("drwx------")});it("indicates character devices",function(){var element=render({value:8592});expect(element.text().trim()).toBe("crw--w----")});it("indicates symbolic links",function(){var element=render({value:41325});expect(element.text().trim()).toBe("lr-xr-xr-x")});
it("indicates block devices",function(){var element=render({value:24960});expect(element.text().trim()).toBe("brw-------")});it("indicates FIFO pipes",function(){var element=render({value:4516});expect(element.text().trim()).toBe("prw-r--r--")});it("indicates sockets",function(){var element=render({value:50668});expect(element.text().trim()).toBe("srwxr-sr--")});it("considers the S_ISUID flag",function(){var element=render({value:35300});expect(element.text().trim()).toBe("-rwsr--r--");element=render({value:35236});
expect(element.text().trim()).toBe("-rwSr--r--")});it("considers the S_ISGID flag",function(){var element=render({value:36332});expect(element.text().trim()).toBe("-rwsr-sr--");element=render({value:36324});expect(element.text().trim()).toBe("-rwsr-Sr--")});it("considers the S_ISVTX flag",function(){var element=render({value:35812});expect(element.text().trim()).toBe("-rwsr--r-T");element=render({value:35813});expect(element.text().trim()).toBe("-rwsr--r-t")})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.semantic.timestampDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var230=goog.require("grrUi.tests");var browserTriggerEvent=$jscomp$destructuring$var230.browserTriggerEvent;var testsModule=$jscomp$destructuring$var230.testsModule;var $jscomp$destructuring$var231=goog.require("grrUi.semantic.semantic");var semanticModule=$jscomp$destructuring$var231.semanticModule;describe("timestamp directive",function(){var MICRO_IN_MILLI=
1E3;var MILLI_IN_UNIT=1E3;var SECONDS=MICRO_IN_MILLI*MILLI_IN_UNIT;var MINUTES=60*SECONDS;var $compile;var $rootScope;beforeEach(module("/static/angular-components/semantic/timestamp.html"));beforeEach(module(semanticModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope")}));var renderTestTemplate=function(value){$rootScope.value=value;var template='<grr-timestamp value="value" />';var element=
$compile(template)($rootScope);$rootScope.$apply();return element};it("does not show anything when value is undefined",function(){var element=renderTestTemplate(undefined);expect(element.text().trim()).toBe("")});it("does not show anything when value is null",function(){var element=renderTestTemplate(null);expect(element.text().trim()).toBe("-")});it('shows "-" when value is 0',function(){var element=renderTestTemplate(0);expect(element.text().trim()).toBe("-")});it("shows integer value",function(){var element=
renderTestTemplate(42*SECONDS);expect(element.text()).toContain("1970-01-01 00:00:42")});it("shows value with type information",function(){var timestamp={"mro":["RDFDatetime","RDFInteger","RDFString","RDFBytes","RDFValue","object"],"value":42*SECONDS,"age":0,"type":"RDFDatetime"};var element=renderTestTemplate(timestamp);expect(element.text()).toContain("1970-01-01 00:00:42")});it("includes a human-readable diff when hovered",function(){function assertTimestampRendersDiff(timestamp,diff){var element=
renderTestTemplate(timestamp);var span=$(element).find("> span");browserTriggerEvent($(element).find("> span"),"mouseenter");expect(span.attr("title")).toContain(diff)}var now=(new Date-0)*MICRO_IN_MILLI;assertTimestampRendersDiff(now+5*SECONDS,"now");assertTimestampRendersDiff(now-5*SECONDS,"now");assertTimestampRendersDiff(now-2*MINUTES-2*SECONDS,"2 minutes ago")})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.semantic.timestampSecondsDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var232=goog.require("grrUi.tests");var browserTriggerEvent=$jscomp$destructuring$var232.browserTriggerEvent;var testsModule=$jscomp$destructuring$var232.testsModule;var $jscomp$destructuring$var233=goog.require("grrUi.semantic.semantic");var semanticModule=$jscomp$destructuring$var233.semanticModule;describe("timestamp seconds directive",function(){var MILLI_IN_UNIT=
1E3;var $compile;var $rootScope;beforeEach(module("/static/angular-components/semantic/timestamp.html"));beforeEach(module(semanticModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope")}));var renderTestTemplate=function(value){$rootScope.value=value;var template='<grr-timestamp-seconds value="value" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("does not show anything when value is undefined",
function(){var element=renderTestTemplate(undefined);expect(element.text().trim()).toBe("")});it("does not show anything when value is null",function(){var element=renderTestTemplate(null);expect(element.text().trim()).toBe("-")});it('shows "-" when value is 0',function(){var element=renderTestTemplate(0);expect(element.text().trim()).toBe("-")});it("shows integer value",function(){var element=renderTestTemplate(42);expect(element.text()).toContain("1970-01-01 00:00:42")});it("shows value with type information",
function(){var timestamp={"mro":["RDFDatetimeSeconds","RDFDatetime","RDFInteger","RDFString","RDFBytes","RDFValue","object"],"value":42,"age":0,"type":"RDFDatetimeSeconds"};var element=renderTestTemplate(timestamp);expect(element.text()).toContain("1970-01-01 00:00:42")});it("includes a human-readable diff when hovered",function(){function assertTimestampRendersDiff(timestamp,diff){var element=renderTestTemplate(timestamp);var span=$(element).find("span");browserTriggerEvent($(element).find("span"),
"mouseenter");expect(span.attr("title")).toContain(diff)}var now=(new Date-0)/MILLI_IN_UNIT;assertTimestampRendersDiff(now,"now")})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.semantic.urnDirectiveTest");goog.setTestOnly();var aff4UrnToUrl=goog.require("grrUi.routing.aff4UrnToUrl");var $jscomp$destructuring$var234=goog.require("grrUi.semantic.semantic");var semanticModule=$jscomp$destructuring$var234.semanticModule;var $jscomp$destructuring$var235=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var235.testsModule;describe("urn directive",function(){var $compile;var $rootScope;var grrRoutingService;
beforeEach(module("/static/angular-components/semantic/urn.html"));beforeEach(module(semanticModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");grrRoutingService=$injector.get("grrRoutingService")}));var renderTestTemplate=function(value){$rootScope.value=value;var template='<grr-urn value="value" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("does not show anything when value is empty",
function(){var element=renderTestTemplate(null);expect(element.text().trim()).toBe("")});it("shows plain string if grrRoutingService can't convert URN",function(){spyOn(aff4UrnToUrl,"aff4UrnToUrl").and.returnValue(undefined);var element=renderTestTemplate("aff4:/foo/bar");expect(element.text().trim()).toBe("aff4:/foo/bar");expect(element.find("a").length).toBe(0)});it("shows a link if grrRoutingService can convert URN",function(){spyOn(aff4UrnToUrl,"aff4UrnToUrl").and.returnValue({state:"someState",
params:{}});spyOn(grrRoutingService,"href").and.returnValue("/some/real/link");var element=renderTestTemplate("aff4:/C.0001000200030004/fs/os/foo/bar");expect(element.find("a").text().trim()).toBe("aff4:/C.0001000200030004/fs/os/foo/bar");expect(element.find("a").attr("href")).toBe("/some/real/link")})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.core.clientWarningsDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var236=goog.require("grrUi.sidebar.sidebar");var sidebarModule=$jscomp$destructuring$var236.sidebarModule;var $jscomp$destructuring$var237=goog.require("grrUi.tests");var stubDirective=$jscomp$destructuring$var237.stubDirective;var testsModule=$jscomp$destructuring$var237.testsModule;describe("grr-client-warnings directive",function(){var $q;var $compile;
var $rootScope;var grrApiService;beforeEach(module("/static/angular-components/sidebar/client-warnings.html"));beforeEach(module(sidebarModule.name));beforeEach(module(testsModule.name));stubDirective("grrMarkdown");beforeEach(inject(function($injector){$q=$injector.get("$q");$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");grrApiService=$injector.get("grrApiService")}));var renderTestTemplate=function(configOption,client){$rootScope.client=client||{type:"ApiClient",value:{labels:[{type:"ApiClientLabel",
value:{name:{type:"RDFString",value:"foo"}}},{type:"ApiClientLabel",value:{name:{type:"RDFString",value:"bar"}}}]}};spyOn(grrApiService,"getV2Cached").and.callFake(function(){var deferred=$q.defer();var promise=deferred.promise;deferred.resolve({data:configOption});return promise});var template='<grr-client-warnings client="client" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("does not render anything on empty config option",function(){var element=renderTestTemplate({});
expect(element.find("grr-markdown").length).toBe(0)});it("does not render anything on empty rules list",function(){var element=renderTestTemplate({value:{rules:[]}});expect(element.find("grr-markdown").length).toBe(0)});it("shows a single warning when one rule matches a single label",function(){var element=renderTestTemplate({value:{rules:[{withLabels:["foo"],message:"blah"}]}});expect(element.find("grr-markdown").length).toBe(1);var markdownElement=element.find("grr-markdown:nth(0)");var source=
markdownElement.scope().$eval(markdownElement.attr("source"));expect(source).toBe("blah")});it("matches labels in a case-insensitive way",function(){var element=renderTestTemplate({value:{rules:[{withLabels:["FOO"],message:"blah"}]}});expect(element.find("grr-markdown").length).toBe(1);var markdownElement=element.find("grr-markdown:nth(0)");var source=markdownElement.scope().$eval(markdownElement.attr("source"));expect(source).toBe("blah")});it("shows a single warning when one rule matches two labels",
function(){var element=renderTestTemplate({value:{rules:[{withLabels:["foo","bar"],message:"blah"}]}});expect(element.find("grr-markdown").length).toBe(1);var markdownElement=element.find("grr-markdown:nth(0)");var source=markdownElement.scope().$eval(markdownElement.attr("source"));expect(source).toBe("blah")});it("shows two warnings when two rules match",function(){var element=renderTestTemplate({value:{rules:[{withLabels:["foo"],message:"blah1"},{withLabels:["bar"],message:"blah2"}]}});expect(element.find("grr-markdown").length).toBe(2);
var markdownElement=element.find("grr-markdown:nth(0)");var source=markdownElement.scope().$eval(markdownElement.attr("source"));expect(source).toBe("blah1");markdownElement=element.find("grr-markdown:nth(1)");source=markdownElement.scope().$eval(markdownElement.attr("source"));expect(source).toBe("blah2")})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.stats.auditChartDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var238=goog.require("grrUi.stats.stats");var statsModule=$jscomp$destructuring$var238.statsModule;var $jscomp$destructuring$var239=goog.require("grrUi.tests");var stubDirective=$jscomp$destructuring$var239.stubDirective;var testsModule=$jscomp$destructuring$var239.testsModule;describe("audit chart directive",function(){var $compile;var $rootScope;beforeEach(module("/static/angular-components/stats/audit-chart.html"));
beforeEach(module(statsModule.name));beforeEach(module(testsModule.name));stubDirective("grrSemanticValue");beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope")}));var renderTestTemplate=function(typedData){$rootScope.typedData=typedData;var template='<grr-audit-chart typed-data="typedData">'+"</grr-audit-chart>";var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("shows nothing if the given data is undefined",
function(){var element=renderTestTemplate(undefined);expect(element.find("th").length).toBe(0);expect(element.find("td").length).toBe(0)});it("shows the given data",function(){var element=renderTestTemplate({"value":{"audit_chart":{"value":{"rows":[{"value":{"action":{"value":"HUNT_CREATED","type":"EnumNamedValue"},"user":{"value":"GRRWorker","type":"unicode"},"id":{"value":123,"type":"long"},"timestamp":{"value":1485174411E6,"type":"RDFDatetime"},"description":{"value":"Description of the hunt.",
"type":"unicode"},"flow_name":{"value":"Flow Foo.","type":"unicode"},"urn":{"value":"aff4:/hunts/H:12345678","type":"RDFURN"}},"type":"AuditEvent"},{"value":{"action":{"value":"HUNT_STARTED","type":"EnumNamedValue"},"user":{"value":"GRRWorker","type":"unicode"},"id":{"value":456,"type":"long"},"timestamp":{"value":1485174502E6,"type":"RDFDatetime"},"description":{"value":"Description of another hunt.","type":"unicode"},"urn":{"value":"aff4:/hunts/H:87654321","type":"RDFURN"}},"type":"AuditEvent"}],
"used_fields":[{"value":"action","type":"unicode"},{"value":"description","type":"unicode"},{"value":"flow_name","type":"unicode"},{"value":"timestamp","type":"unicode"},{"value":"urn","type":"unicode"},{"value":"user","type":"unicode"}]},"type":"ApiAuditChartReportData"},"representation_type":{"value":"AUDIT_CHART","type":"EnumNamedValue"}},"type":"ApiReportData"});var ths=element.find("th");expect(ths.length).toBe(6);expect(ths[0].innerText).toContain("Action");expect(ths[1].innerText).toContain("Description");
expect(ths[2].innerText).toContain("Flow name");expect(ths[3].innerText).toContain("Timestamp");expect(ths[4].innerText).toContain("Urn");expect(ths[5].innerText).toContain("User");var tbodyTrs=element.find("tbody tr");expect(tbodyTrs.length).toBe(2);var getCellValue=function(td){var semVal=$(td).find("grr-semantic-value");return semVal.scope().$eval(semVal.attr("value"))};var row0Tds=$(tbodyTrs[0]).find("td");expect(row0Tds.length).toBe(6);expect(getCellValue(row0Tds[0])).toEqual({"value":"HUNT_CREATED",
"type":"EnumNamedValue"});expect(getCellValue(row0Tds[1])).toEqual({"value":"Description of the hunt.","type":"unicode"});expect(getCellValue(row0Tds[2])).toEqual({"value":"Flow Foo.","type":"unicode"});expect(getCellValue(row0Tds[3])).toEqual({"value":1485174411E6,"type":"RDFDatetime"});expect(getCellValue(row0Tds[4])).toEqual({"value":"aff4:/hunts/H:12345678","type":"RDFURN"});expect(getCellValue(row0Tds[5])).toEqual({"value":"GRRWorker","type":"unicode"});var row1Tds=$(tbodyTrs[1]).find("td");
expect(row1Tds.length).toBe(6);expect(getCellValue(row1Tds[0])).toEqual({"value":"HUNT_STARTED","type":"EnumNamedValue"});expect(getCellValue(row1Tds[1])).toEqual({"value":"Description of another hunt.","type":"unicode"});expect(getCellValue(row1Tds[2])).toBe(undefined);expect(getCellValue(row1Tds[3])).toEqual({"value":1485174502E6,"type":"RDFDatetime"});expect(getCellValue(row1Tds[4])).toEqual({"value":"aff4:/hunts/H:87654321","type":"RDFURN"});expect(getCellValue(row1Tds[5])).toEqual({"value":"GRRWorker",
"type":"unicode"})})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.stats.reportDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var240=goog.require("grrUi.stats.stats");var statsModule=$jscomp$destructuring$var240.statsModule;var $jscomp$destructuring$var241=goog.require("grrUi.core.apiService");var stripTypeInfo=$jscomp$destructuring$var241.stripTypeInfo;var $jscomp$destructuring$var242=goog.require("grrUi.tests");var stubDirective=$jscomp$destructuring$var242.stubDirective;var testsModule=
$jscomp$destructuring$var242.testsModule;describe("report directive",function(){var $compile;var $q;var $rootScope;var grrApiService;var grrTimeService;beforeEach(module("/static/angular-components/stats/report.html"));beforeEach(module(statsModule.name));beforeEach(module(testsModule.name));stubDirective("grrFormClientLabel");stubDirective("grrFormTimerange");stubDirective("grrChart");beforeEach(inject(function($injector){$q=$injector.get("$q");$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");
grrApiService=$injector.get("grrApiService");grrTimeService=$injector.get("grrTimeService");var clock=grrTimeService.getCurrentTimeMs();grrTimeService.getCurrentTimeMs=function(){clock+=42;return clock}}));var renderTestTemplate=function(name){$rootScope.name=name;var template='<grr-report name="name">'+"</grr-report>";var element=$compile(template)($rootScope);$rootScope.$apply();return element};var mockGrrApiService=function(){var deferredWork={};spyOn(grrApiService,"get").and.callFake(function(path){var deferred=
$q.defer();var promise=deferred.promise;if(path==="stats/reports"){var response={"reports":[{"type":"ApiReport","value":{"desc":{"type":"ApiReportDescriptor","value":{"name":{"type":"unicode","value":"FooReportPlugin"},"summary":{"type":"unicode","value":"Foo's summary."},"type":{"type":"EnumNamedValue","value":"FOO_TYPE"},"requires_time_range":{"type":"RDFBool","value":false},"title":{"type":"unicode","value":"Foo Report"}}}}},{"type":"ApiReport","value":{"desc":{"type":"ApiReportDescriptor","value":{"name":{"type":"unicode",
"value":"BarReportPlugin"},"summary":{"type":"unicode","value":"Bar's summary."},"type":{"type":"EnumNamedValue","value":"BAR_TYPE"},"requires_time_range":{"type":"RDFBool","value":false},"title":{"type":"unicode","value":"Bar Report"}}}}}]};deferred.resolve({data:response})}else{var response$7={data:{data:{value:{representation_type:{value:"STACK_CHART"},stack_chart:{value:{data:[{value:{label:path,points:[]}}]}}}}}};deferredWork[path].promise.then(function(){deferred.resolve({data:response$7})})}return promise});
return deferredWork};it("drops responses to old requests",function(){var deferredWork=mockGrrApiService();deferredWork["stats/reports/FooReportPlugin"]=$q.defer();deferredWork["stats/reports/BarReportPlugin"]=$q.defer();var element=renderTestTemplate("FooReportPlugin");$rootScope.name="BarReportPlugin";$rootScope.$apply();expect(element.find("grr-chart").length).toBe(0);deferredWork["stats/reports/FooReportPlugin"].resolve();$rootScope.$apply();expect(element.find("grr-chart").length).toBe(0);deferredWork["stats/reports/BarReportPlugin"].resolve();
$rootScope.$apply();var chart=element.find("grr-chart");expect(chart.length).toBe(1);var attribute=chart.attr("typed-data");var typedData=chart.scope().$eval(attribute);var data=stripTypeInfo(typedData["data"]);expect(data["stack_chart"]["data"][0]["label"]).toBe("stats/reports/BarReportPlugin");expect(JSON.stringify(typedData)).not.toContain("FooReportPlugin")})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.stats.reportListingDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var243=goog.require("grrUi.stats.reportListingDirective");var parseStatsReportsApiResponse=$jscomp$destructuring$var243.parseStatsReportsApiResponse;describe("stats.reportListingDirective.parseStatsReportsApiResponse",function(){it("Parses the response into a jsTree-compatible format.",function(){var reports=[{desc:{name:"FooReportPlugin",title:"Foos' Activity",
type:"SERVER"}},{desc:{name:"BarReportPlugin",title:"Bars Reported Over Time",type:"SERVER"}},{desc:{name:"BazReportPlugin",title:"Baz Statistics",type:"CLIENT"}}];var ret=parseStatsReportsApiResponse(reports);expect(ret).toEqual([{children:[{desc:{name:"FooReportPlugin",title:"Foos' Activity",type:"SERVER"},id:"FooReportPlugin",text:"Foos' Activity"},{desc:{name:"BarReportPlugin",title:"Bars Reported Over Time",type:"SERVER"},id:"BarReportPlugin",text:"Bars Reported Over Time"}],state:{disabled:true,
opened:true},text:"Server"},{children:[{desc:{name:"BazReportPlugin",title:"Baz Statistics",type:"CLIENT"},id:"BazReportPlugin",text:"Baz Statistics"}],state:{disabled:true,opened:true},text:"Client"}])})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.stats.serverLoadDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var244=goog.require("grrUi.stats.serverLoadDirective");var ServerLoadIndicatorService=$jscomp$destructuring$var244.ServerLoadIndicatorService;var $jscomp$destructuring$var245=goog.require("grrUi.stats.stats");var statsModule=$jscomp$destructuring$var245.statsModule;describe("server load indicator service",function(){var $compile;var $q;var $rootScope;var grrApiServiceMock;
beforeEach(module(statsModule.name));beforeEach(inject(function($injector){$q=$injector.get("$q");$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");grrApiServiceMock={get:function(){}}}));describe("ratio health indicators",function(){var getService=function(numeratorPath,numeratorResponse,denominatorPath,denominatorResponse){var service;inject(function($injector){service=$injector.instantiate(ServerLoadIndicatorService,{"$q":$q,"grrApiService":grrApiServiceMock})});var deferredNumerator=
$q.defer();deferredNumerator.resolve(numeratorResponse);var deferredDenominator=$q.defer();deferredDenominator.resolve(denominatorResponse);spyOn(grrApiServiceMock,"get").and.callFake(function(path){if(path==="stats/store/FRONTEND/metrics/metric1")return deferredNumerator.promise;else if(path==="stats/store/FRONTEND/metrics/metric2")return deferredDenominator.promise;else throw new Error("Unexpected path: "+path);});$rootScope.$apply();return service};it("sets unknown status when no data received",
function(){var service=getService("FRONTEND/metrics/metric1",{data:{metric_name:"metric1",data_points:[]}},"FRONTEND/metrics/metric2",{data:{metric_name:"metric2",data_points:[]}});var status=service.fetchRatioIndicator("FRONTEND","metric1","metric2",1.5,3);var resolvedStatus;status.then(function(value){resolvedStatus=value});$rootScope.$apply();expect(resolvedStatus).toBeDefined();expect(resolvedStatus).toEqual("unknown")});it("sets unknown when denominator is zero",function(){var service=getService("FRONTEND/metrics/metric1",
{data:{metric_name:"metric1",data_points:[[0,1]]}},"FRONTEND/metrics/metric2",{data:{metric_name:"metric2",data_points:[[0,0]]}});var status=service.fetchRatioIndicator("FRONTEND","metric1","metric2",1.5,3);var resolvedStatus;status.then(function(value){resolvedStatus=value});$rootScope.$apply();expect(resolvedStatus).toBeDefined();expect(resolvedStatus).toEqual("unknown")});it("sets warning status when ratio level is above threshold",function(){var service=getService("FRONTEND/metrics/metric1",{data:{metric_name:"metric1",
data_points:[[0,4]]}},"FRONTEND/metrics/metric2",{data:{metric_name:"metric2",data_points:[[0,2]]}});var status=service.fetchRatioIndicator("FRONTEND","metric1","metric2",1.5,3);var resolvedStatus;status.then(function(value){resolvedStatus=value});$rootScope.$apply();expect(resolvedStatus).toBeDefined();expect(resolvedStatus).toEqual("warning")});it("sets warning status when mean ratio is above threshold",function(){var service=getService("FRONTEND/metrics/metric1",{data:{metric_name:"metric1",data_points:[[0,
3],[10,5]]}},"FRONTEND/metrics/metric2",{data:{metric_name:"metric2",data_points:[[0,1],[10,3]]}});var status=service.fetchRatioIndicator("FRONTEND","metric1","metric2",1.5,3);var resolvedStatus;status.then(function(value){resolvedStatus=value});$rootScope.$apply();expect(resolvedStatus).toBeDefined();expect(resolvedStatus).toEqual("warning")});it("sets danger status when ratio level is above threshold",function(){var service=getService("FRONTEND/metrics/metric1",{data:{metric_name:"metric1",data_points:[[0,
7]]}},"FRONTEND/metrics/metric2",{data:{metric_name:"metric2",data_points:[[0,2]]}});var status=service.fetchRatioIndicator("FRONTEND","metric1","metric2",1.5,3);var resolvedStatus;status.then(function(value){resolvedStatus=value});$rootScope.$apply();expect(resolvedStatus).toBeDefined();expect(resolvedStatus).toEqual("danger")});it("sets normal status when ratio level is below threshold",function(){var service=getService("FRONTEND/metrics/metric1",{data:{metric_name:"metric1",data_points:[[0,2]]}},
"FRONTEND/metrics/metric2",{data:{metric_name:"metric2",data_points:[[0,2]]}});var status=service.fetchRatioIndicator("FRONTEND","metric1","metric2",1.5,3);var resolvedStatus;status.then(function(value){resolvedStatus=value});$rootScope.$apply();expect(resolvedStatus).toBeDefined();expect(resolvedStatus).toEqual("normal")})})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.user.userDesktopNotificationsDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var246=goog.require("grrUi.user.userNotificationButtonDirective");var UserNotificationButtonDirective=$jscomp$destructuring$var246.UserNotificationButtonDirective;var $jscomp$destructuring$var247=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var247.testsModule;var $jscomp$destructuring$var248=goog.require("grrUi.user.user");
var userModule=$jscomp$destructuring$var248.userModule;describe("User desktop notifications directive",function(){var $compile;var $interval;var $q;var $rootScope;var $location;var grrApiService;var FETCH_INTERVAL=UserNotificationButtonDirective.fetch_interval;beforeEach(module(userModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$q=$injector.get("$q");$location=$injector.get("$location");$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");
$interval=$injector.get("$interval");grrApiService=$injector.get("grrApiService");window.Notification=function(){this.close=function(){}};spyOn(window,"Notification").and.callThrough()}));var render=function(){var template="<grr-user-desktop-notifications />";var element=$compile(template)($rootScope);$rootScope.$apply();return element};var mockApiServiceResponse=function(value){spyOn(grrApiService,"get").and.callFake(function(){var deferred=$q.defer();deferred.resolve({data:{items:value}});return deferred.promise})};
it("fetches a single pending notification and displays it as a desktop "+"notification",function(){mockApiServiceResponse([{"type":"ApiNotification","value":{"is_pending":{"type":"RDFBool","value":true},"message":{"type":"unicode","value":"Host-0: <some message>"},"reference":{"type":"ApiNotificationReference","value":{"client":{"type":"ApiNotificationClientReference","value":{"client_id":{"type":"ClientURN","value":"aff4:/C.1000000000000000"}}},"type":{"type":"EnumNamedValue","value":"CLIENT"}}},
"timestamp":{"type":"RDFDatetime","value":42E6}}}]);render();$interval.flush(FETCH_INTERVAL);expect(grrApiService.get).toHaveBeenCalled();expect(Notification.calls.count()).toBe(1);expect(Notification).toHaveBeenCalledWith("GRR",{"body":"Host-0: <some message>","icon":"static/images/grr_logo_notification.png","tag":"GRR42000000"})});it("provides a relevant onclick callback for the desktop notification",function(){mockApiServiceResponse([{"type":"ApiNotification","value":{"is_pending":{"type":"RDFBool",
"value":true},"message":{"type":"unicode","value":"Host-0: <some message>"},"reference":{"type":"ApiNotificationReference","value":{"client":{"type":"ApiNotificationClientReference","value":{"client_id":{"type":"ClientURN","value":"aff4:/C.1000000000000000"}}},"type":{"type":"EnumNamedValue","value":"CLIENT"}}},"timestamp":{"type":"RDFDatetime","value":42E6}}}]);spyOn(grrApiService,"delete");spyOn($location,"path");render();$interval.flush(FETCH_INTERVAL);Notification.calls.mostRecent().object.onclick();
expect(grrApiService.delete).toHaveBeenCalledWith("users/me/notifications/pending/42000000");expect($location.path).toHaveBeenCalledWith("clients/C.1000000000000000")});it("fetches pending notifications and displays the last two of them as "+"desktop notifications",function(){mockApiServiceResponse([{"type":"ApiNotification","value":{"is_pending":{"type":"RDFBool","value":true},"message":{"type":"unicode","value":"Host-0: <another message>"},"reference":{"type":"ApiNotificationReference","value":{"type":{"type":"EnumNamedValue",
"value":"VFS"},"vfs":{"type":"ApiNotificationVfsReference","value":{"client_id":{"type":"ClientURN","value":"aff4:/C.1000000000000000"},"vfs_path":{"type":"RDFURN","value":"aff4:/C.1000000000000000"}}}}},"timestamp":{"type":"RDFDatetime","value":48E6}}},{"type":"ApiNotification","value":{"is_pending":{"type":"RDFBool","value":true},"message":{"type":"unicode","value":"Host-0: <some message>"},"reference":{"type":"ApiNotificationReference","value":{"client":{"type":"ApiNotificationClientReference",
"value":{"client_id":{"type":"ClientURN","value":"aff4:/C.1000000000000000"}}},"type":{"type":"EnumNamedValue","value":"CLIENT"}}},"timestamp":{"type":"RDFDatetime","value":42E6}}},{"type":"ApiNotification","value":{"is_pending":{"type":"RDFBool","value":true},"message":{"type":"unicode","value":"Host-0: <some other message>"},"reference":{"type":"ApiNotificationReference","value":{"type":{"type":"EnumNamedValue","value":"VFS"},"vfs":{"type":"ApiNotificationVfsReference","value":{"client_id":{"type":"ClientURN",
"value":"aff4:/C.1000000000000000"},"vfs_path":{"type":"RDFURN","value":"aff4:/C.1000000000000000"}}}}},"timestamp":{"type":"RDFDatetime","value":44E6}}}]);render();$interval.flush(FETCH_INTERVAL);expect(grrApiService.get).toHaveBeenCalled();expect(Notification.calls.count()).toBe(2);var firstCallArgs=Notification.calls.all()[0]["args"];var secondCallArgs=Notification.calls.all()[1]["args"];expect(firstCallArgs).toEqual(["GRR",{"body":"Host-0: <some other message>","icon":"static/images/grr_logo_notification.png",
"tag":"GRR44000000"}]);expect(secondCallArgs).toEqual(["GRR",{"body":"Host-0: <another message>","icon":"static/images/grr_logo_notification.png","tag":"GRR48000000"}])})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.user.userLabelDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var249=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var249.testsModule;var $jscomp$destructuring$var250=goog.require("grrUi.user.user");var userModule=$jscomp$destructuring$var250.userModule;describe("User label directive",function(){var $compile;var $q;var $rootScope;var grrApiService;beforeEach(module("/static/angular-components/user/user-label.html"));
beforeEach(module(userModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$q=$injector.get("$q");$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");grrApiService=$injector.get("grrApiService")}));var render=function(){var template="<grr-user-label />";var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("fetches username and shows it",function(){var mockUserName="Test Username";spyOn(grrApiService,"getCached").and.callFake(function(){var deferred=
$q.defer();deferred.resolve({data:{value:{username:{value:mockUserName}}}});return deferred.promise});var element=render(mockUserName);expect(element.text().trim()).toBe("User: "+mockUserName)});it("shows special message in case of 403 error",function(){spyOn(grrApiService,"getCached").and.callFake(function(){var deferred=$q.defer();deferred.reject({status:403,statusText:"Unauthorized"});return deferred.promise});var element=render();expect(element.text().trim()).toBe("User: Authentication Error")});
it("shows status text in case of a non-403 error",function(){spyOn(grrApiService,"getCached").and.callFake(function(){var deferred=$q.defer();deferred.reject({status:500,statusText:"Error"});return deferred.promise});var element=render();expect(element.text().trim()).toBe("User: Error")})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.user.userNotificationButtonDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var251=goog.require("grrUi.user.userNotificationButtonDirective");var UserNotificationButtonDirective=$jscomp$destructuring$var251.UserNotificationButtonDirective;var $jscomp$destructuring$var252=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var252.testsModule;var $jscomp$destructuring$var253=goog.require("grrUi.user.user");var userModule=
$jscomp$destructuring$var253.userModule;describe("User notification button directive",function(){var $compile;var $interval;var $q;var $rootScope;var grrApiService;var FETCH_INTERVAL=UserNotificationButtonDirective.fetch_interval;beforeEach(module("/static/angular-components/user/user-notification-button.html"));beforeEach(module(userModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$q=$injector.get("$q");$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");
$interval=$injector.get("$interval");grrApiService=$injector.get("grrApiService")}));var render=function(){var template="<grr-user-notification-button />";var element=$compile(template)($rootScope);$rootScope.$apply();return element};var mockApiServiceResponse=function(value){spyOn(grrApiService,"get").and.callFake(function(){var deferred=$q.defer();deferred.resolve({data:{count:value}});return deferred.promise})};it("fetches pending notifications count and displays an info-styled button on 0",function(){mockApiServiceResponse(0);
var element=render();$interval.flush(FETCH_INTERVAL);expect(grrApiService.get).toHaveBeenCalled();expect(element.text().trim()).toBe("0");expect(element.find("button").hasClass("btn-info")).toBe(true)});it("non-zero notifications count is shown as danger-styled button",function(){mockApiServiceResponse(5);var element=render();$interval.flush(FETCH_INTERVAL);expect(grrApiService.get).toHaveBeenCalled();expect(element.text().trim()).toBe("5");expect(element.find("button").hasClass("btn-danger")).toBe(true)})});
exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.user.userNotificationItemDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var254=goog.require("grrUi.user.userNotificationItemDirective");var annotateApiNotification=$jscomp$destructuring$var254.annotateApiNotification;describe("User notification item directive",function(){describe("annotateApiNotification()",function(){var buildNotification=function(reference){return{value:{is_pending:{value:true},message:{value:"Recursive Directory Listing complete 0 nodes, 0 dirs"},
reference:reference,timestamp:{value:0x530e9972fd28f}}}};it("annotates CLIENT notification correctly",function(){var notification=buildNotification({value:{type:{value:"CLIENT"},client:{value:{client_id:{value:"aff4:/C.0000000000000001"}}}}});annotateApiNotification(notification);expect(notification.link).toEqual("clients/C.0000000000000001");expect(notification.refType).toEqual("CLIENT")});it("annotates HUNT notification correctly",function(){var notification=buildNotification({value:{type:{value:"HUNT"},
hunt:{value:{hunt_id:{value:"H:123456"}}}}});annotateApiNotification(notification);expect(notification.link).toEqual("hunts/H:123456");expect(notification.refType).toEqual("HUNT")});it("annotates CRON notification correctly",function(){var notification=buildNotification({value:{type:{value:"CRON"},cron:{value:{cron_job_id:{value:"FooBar"}}}}});annotateApiNotification(notification);expect(notification.link).toEqual("crons/FooBar");expect(notification.refType).toEqual("CRON")});it("annotates FLOW notification correctly",
function(){var notification=buildNotification({value:{type:{value:"FLOW"},flow:{value:{client_id:{value:"aff4:/C.0001000200030004"},flow_id:{value:"F:123456"}}}}});annotateApiNotification(notification);expect(notification.link).toEqual("clients/C.0001000200030004/flows/F:123456");expect(notification.refType).toEqual("FLOW")});it("annotates CLIENT_APPROVAL notification correctly",function(){var notification=buildNotification({value:{type:{value:"CLIENT_APPROVAL"},client_approval:{value:{client_id:{value:"aff4:/C.0001000200030004"},
approval_id:{value:"foo-bar"},username:{value:"test"}}}}});annotateApiNotification(notification);expect(notification.link).toEqual("users/test/approvals/client/C.0001000200030004/foo-bar");expect(notification.refType).toEqual("CLIENT_APPROVAL")});it("annotates HUNT_APPROVAL notification correctly",function(){var notification=buildNotification({value:{type:{value:"HUNT_APPROVAL"},hunt_approval:{value:{hunt_id:{value:"H:123456"},approval_id:{value:"foo-bar"},username:{value:"test"}}}}});annotateApiNotification(notification);
expect(notification.link).toEqual("users/test/approvals/hunt/H:123456/foo-bar");expect(notification.refType).toEqual("HUNT_APPROVAL")});it("annotates CRON_JOB_APPROVAL notification correctly",function(){var notification=buildNotification({value:{type:{value:"CRON_JOB_APPROVAL"},cron_job_approval:{value:{cron_job_id:{value:"FooBar"},approval_id:{value:"foo-bar"},username:{value:"test"}}}}});annotateApiNotification(notification);expect(notification.link).toEqual("users/test/approvals/cron-job/FooBar/foo-bar");
expect(notification.refType).toEqual("CRON_JOB_APPROVAL")});it("annotates UNKNOWN notification correctly",function(){var notification=buildNotification({value:{type:{value:"UNKNOWN"},unknown:{value:{source_urn:{value:"aff4:/foo/bar"},subject_urn:{value:"aff4:/blah/blah"}}}}});annotateApiNotification(notification);expect(notification.link).toBe(null);expect(notification.refType).toEqual("UNKNOWN")});it("handles missing references correctly",function(){var notification={value:{is_pending:{value:false},
message:{value:"Recursive Directory Listing complete 0 nodes, 0 dirs"},timestamp:{value:0x530e9972fd28f}}};annotateApiNotification(notification);expect(notification.isPending).toBe(false);expect(notification.link).toBeUndefined();expect(notification.refType).toBeUndefined()})})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.client.virtualFileSystem.breadcrumbsDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var255=goog.require("grrUi.tests");var browserTriggerEvent=$jscomp$destructuring$var255.browserTriggerEvent;var testsModule=$jscomp$destructuring$var255.testsModule;var $jscomp$destructuring$var256=goog.require("grrUi.client.client");var clientModule=$jscomp$destructuring$var256.clientModule;describe("breadcrums directive",function(){var $compile;
var $rootScope;var $scope;beforeEach(module("/static/angular-components/client/virtual-file-system/breadcrumbs.html"));beforeEach(module(clientModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");$scope=$rootScope.$new()}));var render=function(path,stripEndingSlash){$scope.obj={path:path,stripEndingSlash:stripEndingSlash};var template='<grr-breadcrumbs strip-ending-slash="obj.stripEndingSlash" '+
'path="obj.path" />';var element=$compile(template)($scope);$scope.$apply();return element};it("should show the path components as links",function(){var element=render("path/to/some/resource");expect(element.find("a").length).toBe(2);expect(element.find("li.active").text().trim()).toBe("some")});it("strips ending slash if strip-ending-slash is true",function(){var element=render("path/to/some/resource/",true);expect(element.find("a").length).toBe(2);expect(element.find("li.active").text().trim()).toBe("some")});
it("should change the path when a link is clicked",function(){var element=render("path/to/some/resource");var links=element.find("a");expect(links.length).toBe(2);browserTriggerEvent(links[1],"click");$scope.$apply();expect(element.find("li.active").text().trim()).toBe("to");expect($scope.obj.path).toBe("path/to/")});it("should change the links when the scope changes",function(){var element=render("path/to/some/resource");expect(element.find("a").length).toBe(2);expect(element.find("li.active").text().trim()).toBe("some");
$scope.obj.path="a/path/to/another/file";$scope.$apply();expect(element.find("a").length).toBe(3);expect(element.find("li.active").text().trim()).toBe("another")})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.client.virtualFileSystem.encodingsDropdownDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var257=goog.require("grrUi.client.client");var clientModule=$jscomp$destructuring$var257.clientModule;var $jscomp$destructuring$var258=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var258.testsModule;describe("encodings dropdown directive",function(){var $compile;var $q;var $rootScope;var $scope;var grrApiService;
beforeEach(module("/static/angular-components/client/virtual-file-system/encodings-dropdown.html"));beforeEach(module(clientModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");$q=$injector.get("$q");grrApiService=$injector.get("grrApiService");$scope=$rootScope.$new()}));var mockApiService=function(responses){spyOn(grrApiService,"get").and.callFake(function(path){var response={encodings:responses[path]};
return $q.when({data:response})})};var render=function(encoding){$scope.obj={encoding:encoding};var template='<grr-encodings-dropdown encoding="obj.encoding" />';var element=$compile(template)($scope);$scope.$apply();return element};it("should select the scope value",function(){var encodings=[{value:"ENC1"},{value:"ENC2"},{value:"ENC99"},{value:"UTF_8"}];mockApiService({"reflection/file-encodings":encodings});var element=render("ENC1");expect(element.find("option").length).toBe(4);expect(element.find("option[selected]").text().trim()).toBe("ENC1");
expect(grrApiService.get).toHaveBeenCalled()});it("should change the selection when the scope changes",function(){var encodings=[{value:"ENC1"},{value:"ENC2"},{value:"ENC99"},{value:"UTF_8"}];mockApiService({"reflection/file-encodings":encodings});var element=render("ENC1");expect(element.find("option[selected]").text().trim()).toBe("ENC1");$scope.obj.encoding="UTF_8";$scope.$apply();expect(element.find("option[selected]").text().trim()).toBe("UTF_8")});it("should be disabled when no options are available",
function(){mockApiService({"some/url":[]});var element=render("UTF_8");expect(element.find("select[disabled]").length).toBe(1);expect(element.find("option").text().trim()).toBe("No encodings available.");expect($scope.obj.encoding).toBe("UTF_8")})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.client.virtualFileSystem.fileContextDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var259=goog.require("grrUi.client.virtualFileSystem.fileContextDirective");var FileContextController=$jscomp$destructuring$var259.FileContextController;describe("file context directive",function(){var $rootScope;beforeEach(inject(function($injector){$rootScope=$injector.get("$rootScope")}));var getController=function(){var controller;inject(function($injector){controller=
$injector.instantiate(FileContextController,{"$scope":$rootScope})});$rootScope.controller=controller;$rootScope.$apply();return controller};it("changes the controller values when the scope values change",function(){var controller=getController();expect(controller.clientId).toBeUndefined();expect(controller.selectedFilePath).toBeUndefined();expect(controller.selectedFileVersion).toBeUndefined();$rootScope.clientId=42;$rootScope.selectedFilePath="some/path/test.txt";$rootScope.selectedFileVersion=
1337;$rootScope.$apply();expect(controller.clientId).toEqual(42);expect(controller.selectedFilePath).toEqual("some/path/test.txt");expect(controller.selectedFileVersion).toEqual(1337)});it("changes the scope whenever the controller values change",function(){var controller=getController();controller.clientId=42;controller.selectedFilePath="some/path/test.txt";controller.selectedFileVersion=1337;$rootScope.$apply();expect($rootScope.clientId).toEqual(42);expect($rootScope.selectedFilePath).toEqual("some/path/test.txt");
expect($rootScope.selectedFileVersion).toEqual(1337)});it("allows settings the selected file via selectFile",function(){var controller=getController();controller.selectFile("some/path/test.txt");$rootScope.$apply();expect($rootScope.selectedFilePath).toEqual("some/path/test.txt");expect($rootScope.selectedFileVersion).toBeUndefined();controller.selectFile("some/other/path/test.txt",1337);$rootScope.$apply();expect($rootScope.selectedFilePath).toEqual("some/other/path/test.txt");expect($rootScope.selectedFileVersion).toEqual(1337)})});
exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.client.virtualFileSystem.fileHexViewDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var260=goog.require("grrUi.tests");var testsModule=$jscomp$destructuring$var260.testsModule;var $jscomp$destructuring$var261=goog.require("grrUi.client.virtualFileSystem.virtualFileSystem");var virtualFileSystemModule=$jscomp$destructuring$var261.virtualFileSystemModule;describe("file hex view directive",function(){var $compile;var $q;var $rootScope;
var grrApiService;beforeEach(module("/static/angular-components/client/virtual-file-system/file-hex-view.html"));beforeEach(module(virtualFileSystemModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$q=$injector.get("$q");$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");grrApiService=$injector.get("grrApiService")}));var render=function(clientId,filePath){$rootScope.clientId=clientId;$rootScope.selectedFilePath=filePath;var template="<grr-file-context"+
'    client-id="clientId"'+'    selected-file-path="selectedFilePath">'+"  <grr-file-hex-view />"+"</grr-file-context>";var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("shows proper hex values",function(){spyOn(grrApiService,"head").and.callFake(function(){return $q.when({headers:function(){return 100}})});spyOn(grrApiService,"get").and.callFake(function(){return $q.when({data:"some text"})});var element=render("C.0000111122223333","fs/os/c/test.txt");expect(grrApiService.get).toHaveBeenCalled();
expect(element.find("table.offset-area tr:first-child td").text().trim()).toEqual("0x00000000");expect(element.find("table.offset-area tr:last-child td").text().trim()).toEqual("0x00000300");expect(element.find("table.hex-area tr:first-child td").text().trim()).toEqual("736f6d652074657874");expect(element.find("table.content-area tr:first-child td").text().trim()).toEqual("some text")});it("shows a hint when the file is not available",function(){spyOn(grrApiService,"head").and.callFake(function(){return $q.reject("Some Error Message")});
var element=render("C.0000111122223333","fs/os/c/test.txt");expect(grrApiService.head).toHaveBeenCalled();expect(element.find(".no-content").length).toEqual(1)})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.client.virtualFileSystem.fileTreeDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var262=goog.require("grrUi.tests");var browserTriggerEvent=$jscomp$destructuring$var262.browserTriggerEvent;var testsModule=$jscomp$destructuring$var262.testsModule;var $jscomp$destructuring$var263=goog.require("grrUi.client.virtualFileSystem.virtualFileSystem");var virtualFileSystemModule=$jscomp$destructuring$var263.virtualFileSystemModule;
describe("file tree view directive",function(){var $compile;var $q;var $rootScope;var grrApiService;beforeEach(module("/static/angular-components/client/virtual-file-system/file-tree.html"));beforeEach(module(virtualFileSystemModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$q=$injector.get("$q");$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");grrApiService=$injector.get("grrApiService")}));var render=function(clientId,filePath){$rootScope.clientId=
clientId;$rootScope.selectedFolderPath=filePath;$rootScope.selectedFilePath=filePath;var template="<grr-file-context"+'    client-id="clientId"'+'    selected-folder-path="selectedFolderPath"'+'    selected-file-path="selectedFilePath"'+'    selected-file-version="selectedFileVersion">'+"  <grr-file-tree />"+"</grr-file-context>";var element=$compile(template)($rootScope);$rootScope.$apply();return element};var mockApiService=function(responses){spyOn(grrApiService,"get").and.callFake(function(path){var response=
{items:responses[path]};return $q.when({data:response})})};var getChildNodeTexts=function(jsTree,nodeId){var treeItems=jsTree.find(nodeId).find("[role=treeitem]");var texts=[];angular.forEach(treeItems,function(item){texts.push($(item).text())});return texts};it("shows correct nested folder structure",function(done){var responses={};responses["clients/C.0000111122223333/vfs-index/"]=[{value:{name:{value:"fs"},path:{value:"fs"}}}];responses["clients/C.0000111122223333/vfs-index/fs"]=[{value:{name:{value:"os"},
path:{value:"fs/os"}}},{value:{name:{value:"tsk"},path:{value:"fs/tsk"}}}];responses["clients/C.0000111122223333/vfs-index/fs/os"]=[{value:{name:{value:"dir1"},path:{value:"fs/os/dir1"}}},{value:{name:{value:"dir2"},path:{value:"fs/os/dir2"}}},{value:{name:{value:"dir3"},path:{value:"fs/os/dir3"}}}];mockApiService(responses);var element=render("C.0000111122223333","fs");var jsTree=element.find("#file-tree");jsTree.one("load_node.jstree",function(){expect(jsTree.find("[role=treeitem]").length).toBe(1);
expect(jsTree.find("[role=treeitem]").attr("id")).toBe("_fs");browserTriggerEvent(jsTree.find("#_fs a"),"click");jsTree.one("open_node.jstree",function(){expect(getChildNodeTexts(jsTree,"li#_fs")).toEqual(["os","tsk"]);browserTriggerEvent(jsTree.find("#_fs-os a"),"click");jsTree.one("open_node.jstree",function(){expect(getChildNodeTexts(jsTree,"li#_fs-os")).toEqual(["dir1","dir2","dir3"]);expect(jsTree.find("[role=treeitem]").length).toBe(6);done()});$rootScope.$apply()});$rootScope.$apply()})})});
exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.client.virtualFileSystem.fileViewDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var264=goog.require("grrUi.client.virtualFileSystem.fileViewDirective");var getFileId=$jscomp$destructuring$var264.getFileId;var getFilePathFromId=$jscomp$destructuring$var264.getFilePathFromId;describe("file view directive",function(){describe("getFileId()",function(){it("returns the file id for any given path",function(){expect(getFileId("some/regular/path")).toEqual("_some-regular-path");
expect(getFileId("some/$peci&l/path")).toEqual("_some-_24peci_26l-path");expect(getFileId("s0me/numb3r5/p4th")).toEqual("_s0me-numb3r5-p4th");expect(getFileId("a slightly/weird_/path")).toEqual("_a_20slightly-weird_5F-path");expect(getFileId("")).toEqual("_")});it("replaces characters with char code > 255 with more than a two-digit hex number",function(){expect(getFileId("some/sp\u20accial/path")).toEqual("_some-sp_20ACcial-path");expect(getFileId("fs/os/c/\u4e2d\u56fd\u65b0\u95fb\u7f51\u65b0\u95fb\u4e2d")).toEqual("_fs-os-c-_4E2D_56FD_65B0_95FB_7F51_65B0_95FB_4E2D")})});
describe("getFilePathFromId()",function(){it("returns the path for any given id",function(){expect(getFilePathFromId("_some-regular-path")).toEqual("some/regular/path");expect(getFilePathFromId("_some-_24peci_26l-path")).toEqual("some/$peci&l/path");expect(getFilePathFromId("_s0me-numb3r5-p4th")).toEqual("s0me/numb3r5/p4th");expect(getFilePathFromId("_a_20slightly-weird_5F-path")).toEqual("a slightly/weird_/path");expect(getFilePathFromId("_")).toEqual("")});it("does not decode chars encoded with more than two hex-digits",
function(){expect(getFilePathFromId("_some-sp_20ACcial-path")).not.toEqual("some/sp\u20accial/path");expect(getFilePathFromId("_fs-os-c-_4E2D_56FD_65B0_95FB_7F51_65B0_95FB_4E2D")).not.toEqual("fs/os/c/\u4e2d\u56fd\u65b0\u95fb\u7f51\u65b0\u95fb\u4e2d")})})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.client.virtualFileSystem.recursiveListButtonDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var265=goog.require("grrUi.tests");var browserTriggerEvent=$jscomp$destructuring$var265.browserTriggerEvent;var testsModule=$jscomp$destructuring$var265.testsModule;var $jscomp$destructuring$var266=goog.require("grrUi.client.virtualFileSystem.virtualFileSystem");var virtualFileSystemModule=$jscomp$destructuring$var266.virtualFileSystemModule;
describe('"recursive list directory" button',function(){var $compile;var $q;var $rootScope;var $timeout;var grrApiService;var grrReflectionService;beforeEach(module("/static/angular-components/client/virtual-file-system/recursive-list-button.html"));beforeEach(module("/static/angular-components/client/virtual-file-system/recursive-list-button-modal.html"));beforeEach(module(virtualFileSystemModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$q=$injector.get("$q");
$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");$timeout=$injector.get("$timeout");grrReflectionService=$injector.get("grrReflectionService");grrApiService=$injector.get("grrApiService")}));var renderTestTemplate=function(clientId,filePath){$rootScope.clientId=clientId||"C.0000111122223333";$rootScope.filePath=filePath||"fs/os/c/";var template="<grr-recursive-list-button "+'client-id="clientId" file-path="filePath" />';var element=$compile(template)($rootScope);$rootScope.$apply();
return element};it("fetches descriptors on click",function(){var deferred=$q.defer();spyOn(grrReflectionService,"getRDFValueDescriptor").and.returnValue(deferred.promise);var element=renderTestTemplate();browserTriggerEvent(element.find("button"),"click");expect(grrReflectionService.getRDFValueDescriptor).toHaveBeenCalledWith("ApiCreateVfsRefreshOperationArgs",true)});describe("modal dialog",function(){beforeEach(function(){var deferred=$q.defer();spyOn(grrReflectionService,"getRDFValueDescriptor").and.returnValue(deferred.promise);
deferred.resolve({"ApiCreateVfsRefreshOperationArgs":{default:{type:"ApiCreateVfsRefreshOperationArgs",value:{}}},"RDFInteger":{default:{type:"RDFInteger",value:0}},"RDFString":{default:{type:"RDFString",value:""}},"ClientURN":{default:{type:"ClientURN",value:""}}})});afterEach(function(){$(document.body).html("")});it("is shown when button clicked and descriptors fetched",function(){var element=renderTestTemplate();browserTriggerEvent(element.find("button"),"click");expect($(document.body).text()).toContain("Recursive Directory Refresh")});
it("is closed when close button is clicked",function(){var element=renderTestTemplate();browserTriggerEvent($("button",element),"click");browserTriggerEvent($("button.close"),"click");$timeout.flush();expect($(document.body).text()).not.toContain("Recursive Directory Refresh")});it("is closed when cancel button is clicked",function(){var element=renderTestTemplate();browserTriggerEvent($("button",element),"click");browserTriggerEvent($("button[name=Cancel]"),"click");$timeout.flush();expect($(document.body).text()).not.toContain("Recursive Directory Refresh")});
it('sends an API request when "refresh" is clicked',function(){var deferred=$q.defer();spyOn(grrApiService,"post").and.returnValue(deferred.promise);var element=renderTestTemplate();browserTriggerEvent(element.find("button"),"click");browserTriggerEvent($("button[name=Proceed]"),"click");expect(grrApiService.post).toHaveBeenCalledWith("clients/C.0000111122223333/vfs-refresh-operations",{type:"ApiCreateVfsRefreshOperationArgs",value:{file_path:{type:"RDFString",value:"fs/os/c"},max_depth:{type:"RDFInteger",
value:5},notify_user:true}},true)});it('strips "aff4:/" prefix from client id',function(){var deferred=$q.defer();spyOn(grrApiService,"post").and.returnValue(deferred.promise);var element=renderTestTemplate("aff4:/C.0000111122223333");browserTriggerEvent(element.find("button"),"click");browserTriggerEvent($("button[name=Proceed]"),"click");expect(grrApiService.post).toHaveBeenCalled();expect(grrApiService.post.calls.mostRecent().args[0]).toBe("clients/C.0000111122223333/vfs-refresh-operations")});
it("disables the button when API request is sent",function(){var deferred=$q.defer();spyOn(grrApiService,"post").and.returnValue(deferred.promise);var element=renderTestTemplate();browserTriggerEvent(element.find("button"),"click");expect(element.find("button[disabled]").length).toBe(0);browserTriggerEvent($("button[name=Proceed]"),"click");expect(element.find("button[disabled]").length).toBe(1)});it("shows success message when API request is successful",function(){var deferred=$q.defer();spyOn(grrApiService,
"post").and.returnValue(deferred.promise);deferred.resolve({data:{status:"OK"}});spyOn(grrApiService,"get").and.returnValue($q.defer().promise);var element=renderTestTemplate();browserTriggerEvent(element.find("button"),"click");browserTriggerEvent($("button[name=Proceed]"),"click");expect($(document.body).text()).toContain("Refresh started successfully!")});it("shows failure message when API request fails",function(){var deferred=$q.defer();spyOn(grrApiService,"post").and.returnValue(deferred.promise);
deferred.reject({data:{message:"Oh no!"}});var element=renderTestTemplate();browserTriggerEvent(element.find("button"),"click");browserTriggerEvent($("button[name=Proceed]"),"click");expect($(document.body).text()).toContain("Oh no!")})})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.client.virtualFileSystem.utilsTest");goog.setTestOnly();var $jscomp$destructuring$var267=goog.require("grrUi.client.virtualFileSystem.utils");var ensurePathIsFolder=$jscomp$destructuring$var267.ensurePathIsFolder;var getFolderFromPath=$jscomp$destructuring$var267.getFolderFromPath;describe("client virtual file system utils",function(){describe("ensurePathIsFolder()",function(){it('does nothing if path ends with "/"',function(){expect(ensurePathIsFolder("/")).toBe("/");
expect(ensurePathIsFolder("a/b/c/")).toBe("a/b/c/")});it('adds "/" if path does not end with it',function(){expect(ensurePathIsFolder("")).toBe("/");expect(ensurePathIsFolder("a/b/c")).toBe("a/b/c/")})});describe("getFolderFromPath()",function(){it("does nothing for falsey values",function(){expect(getFolderFromPath(null)).toBe("");expect(getFolderFromPath(undefined)).toBe("");expect(getFolderFromPath("")).toBe("")});it("strips last component from path with no trailing slash",function(){expect(getFolderFromPath("a/b/c")).toBe("a/b")});
it("strips trailing slash only, if there is one",function(){expect(getFolderFromPath("a/b/c/")).toBe("a/b/c")})})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.client.virtualFileSystem.vfsFilesArchiveButtonDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var268=goog.require("grrUi.client.virtualFileSystem.vfsFilesArchiveButtonDirective");var DOWNLOAD_EVERYTHING_REENABLE_DELAY=$jscomp$destructuring$var268.DOWNLOAD_EVERYTHING_REENABLE_DELAY;var $jscomp$destructuring$var269=goog.require("grrUi.core.serverErrorButtonDirective");var ServerErrorButtonDirective=$jscomp$destructuring$var269.ServerErrorButtonDirective;
var $jscomp$destructuring$var270=goog.require("grrUi.tests");var browserTriggerEvent=$jscomp$destructuring$var270.browserTriggerEvent;var testsModule=$jscomp$destructuring$var270.testsModule;var $jscomp$destructuring$var271=goog.require("grrUi.client.virtualFileSystem.virtualFileSystem");var virtualFileSystemModule=$jscomp$destructuring$var271.virtualFileSystemModule;describe('"download vfs archive" button',function(){var $compile;var $q;var $rootScope;var $timeout;var grrApiService;var ERROR_EVENT_NAME=
ServerErrorButtonDirective.error_event_name;beforeEach(module("/static/angular-components/client/virtual-file-system/vfs-files-archive-button.html"));beforeEach(module(virtualFileSystemModule.name));beforeEach(module(testsModule.name));beforeEach(inject(function($injector){$q=$injector.get("$q");$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope");$timeout=$injector.get("$timeout");grrApiService=$injector.get("grrApiService")}));var renderTestTemplate=function(clientId,filePath){$rootScope.clientId=
clientId||"C.0000111122223333";$rootScope.filePath=filePath||"fs/os/c/";var template="<grr-vfs-files-archive-button "+'client-id="clientId" file-path="filePath" />';var element=$compile(template)($rootScope);$rootScope.$apply();return element};it('sends correct request when "download everything" option is chosen',function(){var deferred=$q.defer();spyOn(grrApiService,"downloadFile").and.returnValue(deferred.promise);var element=renderTestTemplate();browserTriggerEvent(element.find("a[name=downloadEverything]"),
"click");expect(grrApiService.downloadFile).toHaveBeenCalledWith("clients/C.0000111122223333/vfs-files-archive/")});it('sends correct request when "download current folder" option is chosen',function(){var deferred=$q.defer();spyOn(grrApiService,"downloadFile").and.returnValue(deferred.promise);var element=renderTestTemplate();browserTriggerEvent(element.find("a[name=downloadCurrentFolder]"),"click");expect(grrApiService.downloadFile).toHaveBeenCalledWith("clients/C.0000111122223333/vfs-files-archive/fs/os/c")});
it('disables "download everything" option after the click for 30 seconds',function(){var deferred=$q.defer();spyOn(grrApiService,"downloadFile").and.returnValue(deferred.promise);var element=renderTestTemplate();browserTriggerEvent(element.find("a[name=downloadEverything]"),"click");$timeout.flush(DOWNLOAD_EVERYTHING_REENABLE_DELAY-1E3);var items=element.find("li:has(a[name=downloadEverything]).disabled");expect(items.length).toBe(1);$timeout.flush(1001);items=element.find("li:has(a[name=downloadEverything]):not(.disabled)");
expect(items.length).toBe(1)});it('disables "download current folder" option after the click until folder is changed',function(){var deferred=$q.defer();spyOn(grrApiService,"downloadFile").and.returnValue(deferred.promise);var element=renderTestTemplate();browserTriggerEvent(element.find("a[name=downloadCurrentFolder]"),"click");var items=element.find("li:has(a[name=downloadCurrentFolder]).disabled");expect(items.length).toBe(1);$rootScope.filePath="fs/os/c/d";$rootScope.$apply();items=element.find("li:has(a[name=downloadCurrentFolder]):not(.disabled)");
expect(items.length).toBe(1)});it("broadcasts error event on failure",function(done){var deferred=$q.defer();spyOn(grrApiService,"downloadFile").and.returnValue(deferred.promise);var element=renderTestTemplate();browserTriggerEvent(element.find("a[name=downloadCurrentFolder]"),"click");$rootScope.$on(ERROR_EVENT_NAME,done);deferred.reject({data:{message:"FAIL"}});$rootScope.$apply()})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.semantic.rekall.rekallJsonDirectiveTest");goog.setTestOnly();var $jscomp$destructuring$var272=goog.require("grrUi.semantic.rekall.rekall");var rekallModule=$jscomp$destructuring$var272.rekallModule;var $jscomp$destructuring$var273=goog.require("grrUi.tests");var stubDirective=$jscomp$destructuring$var273.stubDirective;var testsModule=$jscomp$destructuring$var273.testsModule;describe("Rekall JSON directive",function(){var $compile;var $rootScope;
beforeEach(module("/static/angular-components/semantic/rekall/rekall-json.html"));beforeEach(module(rekallModule.name));beforeEach(module(testsModule.name));stubDirective("grrRekallLog");stubDirective("grrRekallMetadata");stubDirective("grrRekallTable");beforeEach(inject(function($injector){$compile=$injector.get("$compile");$rootScope=$injector.get("$rootScope")}));var renderTestTemplate=function(jsonContextMessages,compressedJsonMessages){$rootScope.jsonContextMessages={"value":jsonContextMessages};
$rootScope.compressedJsonMessages={"value":compressedJsonMessages};var template="<grr-rekall-json "+'    json-context-messages="jsonContextMessages" '+'    compressed-json-messages="compressedJsonMessages">'+"</grr-rekall-json>";var element=$compile(template)($rootScope);$rootScope.$apply();return element};it("shows nothing when the input is empty",function(){var element=renderTestTemplate("[]","[]");expect(element.find("div").length).toBe(0)});it("shows messages of known types.",function(){var element=
renderTestTemplate('[["t", {}]]','[["L", {}], ["m", {}], ["r", {}]]');expect(element.find("div").length).toBe(3);expect(element.find("grr-rekall-log").length).toBe(1);expect(element.find("grr-rekall-metadata").length).toBe(1);expect(element.find("grr-rekall-table").length).toBe(1)});it('shows EOM for messages of type "x".',function(){var element=renderTestTemplate("[]",'[["x", {}]]');expect(element.find("div").length).toBe(1);expect(element.text()).toContain("EOM")});it("shows its input for messages of unknown type.",
function(){var element=renderTestTemplate("[]",'[["?", {}]]');expect(element.find("div").length).toBe(1);expect(element.text()).toContain('["?",{}]')})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.semantic.rekall.rekallRegistryServiceTest");goog.setTestOnly();var $jscomp$destructuring$var274=goog.require("grrUi.semantic.rekall.rekallRegistryService");var RekallRegistryService=$jscomp$destructuring$var274.RekallRegistryService;var $jscomp$destructuring$var275=goog.require("grrUi.semantic.rekall.rekall");var rekallModule=$jscomp$destructuring$var275.rekallModule;describe("Rekall registry",function(){var testRegistry;beforeEach(module(rekallModule.name));
beforeEach(inject(function($injector){testRegistry=$injector.instantiate(RekallRegistryService,{})}));it("finds previously registered directive",function(){testRegistry.registerDirective("SomeType",Object);var foundDirective=testRegistry.findDirectiveForMro("SomeType");expect(foundDirective).toBe(Object)});it("returns undefined when searching for not registered directive",function(){var foundDirective=testRegistry.findDirectiveForMro("SomeType");expect(foundDirective).toBeUndefined()});it("returns more specific directive when multiple directives match",
function(){var directive1=Object();var directive2=Object();testRegistry.registerDirective("SomeChildType",directive1);testRegistry.registerDirective("SomeParentType",directive2);var foundDirective=testRegistry.findDirectiveForMro("SomeChildType:SomeParentType");expect(foundDirective).toBe(directive1)})});exports={};return exports});goog.loadModule(function(exports){"use strict";goog.module("grrUi.semantic.rekall.utilsTest");goog.setTestOnly();var $jscomp$destructuring$var276=goog.require("grrUi.semantic.rekall.utils");var cropRekallJson=$jscomp$destructuring$var276.cropRekallJson;var stackRekallTables=$jscomp$destructuring$var276.stackRekallTables;describe("semantic.rekall.utils.cropRekallJson",function(){it("crops Rekall Json messages.",function(){var jsonStr='[["L",{"msg":"foo"}],["L",{"msg":"bar"}],["m",{"se'+'ssion":{}}]]';
var targetLen=50;var croppedJsonStr=cropRekallJson(jsonStr,targetLen);expect(croppedJsonStr).toBe('[["L",{"msg":"foo"}],["L",{"msg":"bar"}]]')});it("ignores brackets inside strings.",function(){var jsonStr='[["L",{"msg":"]]]]]]]]][[][][]["}],["L",{"msg":"ba'+'r"}],["m",{"session":{}}]]';var targetLen=50;var croppedJsonStr=cropRekallJson(jsonStr,targetLen);expect(croppedJsonStr).toBe('[["L",{"msg":"]]]]]]]]][[][][]["}]]')});it('ignores escaped "s and \\s inside strings.',function(){var jsonStr='[["L",{"msg":"]]\\"]\\"\\"\\"]]\\\\\\\\\\"]]]\\\\\\\\"}],["L",{'+
'"msg":"bar"}],["m",{"session":{}}]]';var targetLen=50;var croppedJsonStr=cropRekallJson(jsonStr,targetLen);expect(croppedJsonStr).toBe('[["L",{"msg":"]]\\"]\\"\\"\\"]]\\\\\\\\\\"]]]\\\\\\\\"}]]')})});describe("semantic.rekall.utils.stackRekallTables",function(){it("Stacks rekall tables correctly.",function(){var parsedMessages=[["r",{"ip":"::1"}],["t",[{"cname":"ip","name":"IP Address"}]],["r",{"ip":"::2"}],["r",{"ip":"::3"}],["r",{"ip":"::4"}]];var stackedMessages=stackRekallTables(parsedMessages);
expect(stackedMessages).toEqual([["t",{"header":undefined,"rows":[{"ip":"::1"}]}],["t",{"header":[{"cname":"ip","name":"IP Address"}],"rows":[{"ip":"::2"},{"ip":"::3"},{"ip":"::4"}]}]])})});exports={};return exports});
//# sourceMappingURL=grr-ui-test.bundle.js.map