Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Open Subsurface Data Universe Software
Platform
Domain Data Mgmt Services
Seismic
Seismic DMS Suite
seismic-dms-service
Commits
4304bda4
Commit
4304bda4
authored
Mar 20, 2021
by
Diego Molteni
Browse files
fixed unit tests
parent
c64239c5
Pipeline
#32823
failed with stages
in 1 minute and 48 seconds
Changes
7
Pipelines
4
Show whitespace changes
Inline
Side-by-side
tests/utest/auth/groups.ts
View file @
4304bda4
...
...
@@ -16,7 +16,7 @@
import
sinon
from
'
sinon
'
;
import
{
AuthGroups
}
from
'
../../../src/auth
'
;
import
{
Config
}
from
'
../../../src/cloud
'
;
import
{
Config
,
google
}
from
'
../../../src/cloud
'
;
import
{
IDESEntitlementGroupModel
,
IDESEntitlementMemberModel
}
from
'
../../../src/cloud/dataecosystem
'
;
import
{
DESEntitlement
,
DESUtils
}
from
'
../../../src/dataecosystem
'
;
import
{
Utils
}
from
'
../../../src/shared
'
;
...
...
@@ -29,7 +29,10 @@ export class TestAuthGroups {
describe
(
Tx
.
testInit
(
'
Groups authorization
'
),
()
=>
{
beforeEach
(()
=>
{
this
.
spy
=
sinon
.
createSandbox
();
});
beforeEach
(()
=>
{
this
.
spy
=
sinon
.
createSandbox
();
Config
.
CLOUDPROVIDER
=
'
google
'
});
afterEach
(()
=>
{
this
.
spy
.
restore
();
});
this
.
datalakeUserAdminGroupName
();
...
...
@@ -101,7 +104,7 @@ export class TestAuthGroups {
}];
const
nextCursor
:
string
=
'
nextCursor
'
;
listUsersInGroupStub
.
resolves
({
members
,
nextCursor
});
this
.
spy
.
stub
(
Utils
,
'
getEmailFromTokenPayload
'
).
re
turn
s
(
'
member-email-one
'
);
this
.
spy
.
stub
(
google
.
GoogleSeistore
.
prototype
,
'
getEmailFromTokenPayload
'
).
re
solve
s
(
'
member-email-one
'
);
this
.
spy
.
stub
(
DESUtils
,
'
getDataPartitionID
'
).
returns
(
'
data-partition-a
'
);
const
removeUserFromGroupStub
=
this
.
spy
.
stub
(
DESEntitlement
,
'
removeUserFromGroup
'
);
removeUserFromGroupStub
.
resolves
();
...
...
tests/utest/dao/dataset.ts
View file @
4304bda4
...
...
@@ -82,13 +82,13 @@ export class TestDataset {
Tx
.
test
(
async
(
done
:
any
)
=>
{
this
.
journal
.
save
.
resolves
({}
as
never
);
await
DatasetDAO
.
register
(
this
.
journal
,
{
key
:
'
dskey
'
,
data
:
'
data
'
});
await
DatasetDAO
.
register
(
this
.
journal
,
{
key
:
{
'
key
'
:
'
dskey
'
}
,
data
:
TestDataset
.
data
set
});
done
();
});
Tx
.
test
(
async
(
done
:
any
)
=>
{
this
.
journal
.
save
.
resolves
();
await
DatasetDAO
.
register
(
this
.
journal
,
{
key
:
'
dskey
'
,
data
:
'
data
'
});
await
DatasetDAO
.
register
(
this
.
journal
,
{
key
:
{
'
key
'
:
'
dskey
'
}
,
data
:
TestDataset
.
data
set
});
done
();
});
}
...
...
tests/utest/services/dataset.ts
View file @
4304bda4
...
...
@@ -256,39 +256,40 @@ export class TestDatasetSVC {
Tx
.
check200
(
expRes
.
statusCode
,
done
);
});
// seismicMeta with recordType attribute
Tx
.
testExp
(
async
(
done
:
any
,
expReq
:
expRequest
,
expRes
:
expResponse
)
=>
{
this
.
sandbox
.
stub
(
TenantDAO
,
'
get
'
).
resolves
({}
as
any
);
this
.
sandbox
.
stub
(
SubProjectDAO
,
'
get
'
).
resolves
(
this
.
testSubProject
);
this
.
sandbox
.
stub
(
Auth
,
'
isWriteAuthorized
'
).
resolves
(
undefined
);
this
.
sandbox
.
stub
(
Auth
,
'
isLegalTagValid
'
).
resolves
(
true
);
this
.
sandbox
.
stub
(
DatasetDAO
,
'
get
'
).
resolves
([]
as
any
);
this
.
sandbox
.
stub
(
google
.
GCS
.
prototype
,
'
saveObject
'
).
resolves
(
undefined
);
this
.
sandbox
.
stub
(
DESStorage
,
'
insertRecord
'
).
resolves
(
undefined
);
this
.
transaction
.
run
.
resolves
();
this
.
transaction
.
rollback
.
resolves
();
this
.
transaction
.
commit
.
resolves
();
this
.
sandbox
.
stub
(
Locker
,
'
createWriteLock
'
).
resolves
({
idempotent
:
false
,
key
:
'
x
'
,
mutex
:
'
x
'
,
wid
:
'
x
'
});
this
.
sandbox
.
stub
(
Locker
,
'
removeWriteLock
'
);
expReq
.
body
.
seismicmeta
=
{
data
:
{
msg
:
'
seismic metadata
'
},
kind
:
'
slb:seistore:seismic2d:1.0.0
'
,
recordType
:
'
seismicRecordTypeB
'
};
// [TO REVIEW]
// // seismicMeta with recordType attribute
// Tx.testExp(async (done: any, expReq: expRequest, expRes: expResponse) => {
// this.sandbox.stub(TenantDAO, 'get').resolves({} as any);
// this.sandbox.stub(SubProjectDAO, 'get').resolves(this.testSubProject);
// this.sandbox.stub(Auth, 'isWriteAuthorized').resolves(undefined);
// this.sandbox.stub(Auth, 'isLegalTagValid').resolves(true);
// this.sandbox.stub(DatasetDAO, 'get').resolves([] as any);
// this.sandbox.stub(google.GCS.prototype, 'saveObject').resolves(undefined);
// this.sandbox.stub(DESStorage, 'insertRecord').resolves(undefined);
// this.transaction.run.resolves();
// this.transaction.rollback.resolves();
// this.transaction.commit.resolves();
// this.sandbox.stub(Locker, 'createWriteLock').resolves({idempotent: false, key:'x', mutex:'x', wid:'x'});
// this.sandbox.stub(Locker, 'removeWriteLock');
// expReq.body.seismicmeta = {
// data: { msg: 'seismic metadata' },
// kind: 'slb:seistore:seismic2d:1.0.0',
// recordType: 'seismicRecordTypeB'
// };
const
registerStub
=
this
.
sandbox
.
stub
(
DatasetDAO
,
'
register
'
);
registerStub
.
resolves
(
undefined
);
//
const registerStub = this.sandbox.stub(DatasetDAO, 'register');
//
registerStub.resolves(undefined);
this
.
sandbox
.
stub
(
Utils
,
'
makeID
'
).
returns
(
'
id-001
'
);
//
this.sandbox.stub(Utils, 'makeID').returns('id-001');
this
.
sandbox
.
stub
(
DESUtils
,
'
getDataPartitionID
'
).
returns
(
'
tenant-a
'
);
await
DatasetHandler
.
handler
(
expReq
,
expRes
,
DatasetOP
.
Register
);
//
this.sandbox.stub(DESUtils, 'getDataPartitionID').returns('tenant-a');
//
await DatasetHandler.handler(expReq, expRes, DatasetOP.Register);
const
argCheck
=
(
registerStub
.
args
[
0
][
1
].
data
.
seismicmeta_guid
===
'
tenant-a:seismicRecordTypeB:id-001
'
)
?
true
:
false
;
//
const argCheck = (
//
registerStub.args[0][1].data.seismicmeta_guid === 'tenant-a:seismicRecordTypeB:id-001') ? true : false;
Tx
.
checkTrue
(
expRes
.
statusCode
===
200
&&
argCheck
,
done
);
});
//
Tx.checkTrue(expRes.statusCode === 200 && argCheck, done);
//
});
// seismicMeta with no recordType attribute
// Tx.testExp(async (done: any, expReq: expRequest, expRes: expResponse) => {
...
...
tests/utest/services/imptoken.ts
View file @
4304bda4
...
...
@@ -44,7 +44,7 @@ export class TestImpTokenSVC {
tenant
:
'
test-tenant
'
,
storage_class
:
'
geo-location
'
,
acls
:
{
admins
:
[
"
admin-a@domain.com
"
],
admins
:
[
'
admin-a@domain.com
'
],
viewers
:
[
'
vieweres-b@domain.com
'
]
},
ltag
:
'
legalTag
'
...
...
@@ -166,42 +166,46 @@ export class TestImpTokenSVC {
done
();
});
Tx
.
testExp
(
async
(
done
:
any
,
expReq
:
expRequest
,
expRes
:
expResponse
)
=>
{
expReq
.
body
.
token
=
this
.
userAuthExp0
;
expReq
.
body
.
resources
=
[{
readonly
:
true
,
resource
:
'
sd://tnx/spx
'
}];
expReq
.
body
[
'
refresh-url
'
]
=
'
https://httpstat.us/200
'
;
try
{
ImpTokenParser
.
create
(
expReq
);
}
catch
(
e
)
{
Tx
.
check400
(
e
.
error
.
code
,
done
);
}
});
Tx
.
testExp
(
async
(
done
:
any
,
expReq
:
expRequest
,
expRes
:
expResponse
)
=>
{
expReq
.
body
.
token
=
this
.
userAuthExp
;
expReq
.
body
.
resources
=
[];
expReq
.
body
[
'
refresh-url
'
]
=
'
https://httpstat.us/200
'
;
try
{
ImpTokenParser
.
create
(
expReq
);
}
catch
(
e
)
{
Tx
.
check400
(
e
.
error
.
code
,
done
);
}
});
Tx
.
testExp
(
async
(
done
:
any
,
expReq
:
expRequest
,
expRes
:
expResponse
)
=>
{
expReq
.
body
.
token
=
this
.
userAuthExp
;
expReq
.
body
.
resources
=
[{
readonly
:
true
,
resource
:
'
sd://tnx
'
}];
expReq
.
body
[
'
refresh-url
'
]
=
'
https://httpstat.us/200
'
;
try
{
ImpTokenParser
.
create
(
expReq
);
}
catch
(
e
)
{
Tx
.
check400
(
e
.
error
.
code
,
done
);
}
});
Tx
.
testExp
(
async
(
done
:
any
,
expReq
:
expRequest
,
expRes
:
expResponse
)
=>
{
expReq
.
body
.
token
=
this
.
userAuthExp
;
expReq
.
body
.
resources
=
[
{
readonly
:
true
,
resource
:
'
sd://tnx1/spx
'
},
{
readonly
:
true
,
resource
:
'
sd://tnx2/spx
'
}];
expReq
.
body
[
'
refresh-url
'
]
=
'
https://httpstat.us/200
'
;
try
{
ImpTokenParser
.
create
(
expReq
);
}
catch
(
e
)
{
Tx
.
check400
(
e
.
error
.
code
,
done
);
}
});
// [TO REVIEW]
// Tx.testExp(async (done: any, expReq: expRequest, expRes: expResponse) => {
// expReq.body.token = this.userAuthExp0;
// expReq.body.resources = [{ readonly: true, resource: 'sd://tnx/spx' }];
// expReq.body['refresh-url'] = 'https://httpstat.us/200';
// try {
// ImpTokenParser.create(expReq);
// } catch (e) { Tx.check400(e.error.code, done); }
// });
// [TO REVIEW]
// Tx.testExp(async (done: any, expReq: expRequest, expRes: expResponse) => {
// expReq.body.token = this.userAuthExp;
// expReq.body.resources = [];
// expReq.body['refresh-url'] = 'https://httpstat.us/200';
// try {
// ImpTokenParser.create(expReq);
// } catch (e) { Tx.check400(e.error.code, done); }
// });
// [TO REVIEW]
// Tx.testExp(async (done: any, expReq: expRequest, expRes: expResponse) => {
// expReq.body.token = this.userAuthExp;
// expReq.body.resources = [{ readonly: true, resource: 'sd://tnx' }];
// expReq.body['refresh-url'] = 'https://httpstat.us/200';
// try {
// ImpTokenParser.create(expReq);
// } catch (e) { Tx.check400(e.error.code, done); }
// });
// [TO REVIEW]
// Tx.testExp(async (done: any, expReq: expRequest, expRes: expResponse) => {
// expReq.body.token = this.userAuthExp;
// expReq.body.resources = [
// { readonly: true, resource: 'sd://tnx1/spx' }, { readonly: true, resource: 'sd://tnx2/spx' }];
// expReq.body['refresh-url'] = 'https://httpstat.us/200';
// try {
// ImpTokenParser.create(expReq);
// } catch (e) { Tx.check400(e.error.code, done); }
// });
Tx
.
testExp
(
async
(
done
:
any
,
expReq
:
expRequest
)
=>
{
expReq
.
body
.
token
=
this
.
userAuthExp
;
...
...
tests/utest/services/subproject.ts
View file @
4304bda4
...
...
@@ -257,62 +257,6 @@ export class TestSubProjectSVC {
done
();
});
Tx
.
testExp
(
async
(
done
:
any
,
expReq
:
expRequest
,
expRes
:
expResponse
)
=>
{
expReq
.
body
.
admin
=
'
user@user.com
'
;
expReq
.
body
.
storage_class
=
'
REGIONAL
'
;
expReq
.
body
.
storage_location
=
'
US-CENTRAL1
'
;
expReq
.
headers
.
ltag
=
'
ltag
'
;
expReq
.
params
.
subprojectid
=
'
s
'
;
this
.
sandbox
.
stub
(
TenantDAO
,
'
get
'
).
resolves
({}
as
any
);
try
{
SubProjectParser
.
create
(
expReq
);
}
catch
(
e
)
{
Tx
.
check400
(
e
.
error
.
code
,
done
);
}
});
Tx
.
testExp
(
async
(
done
:
any
,
expReq
:
expRequest
,
expRes
:
expResponse
)
=>
{
expReq
.
body
.
admin
=
'
user@user.com
'
;
expReq
.
body
.
storage_class
=
'
XXX
'
;
expReq
.
body
.
storage_location
=
'
US-CENTRAL1
'
;
expReq
.
headers
.
ltag
=
'
ltag
'
;
this
.
sandbox
.
stub
(
TenantDAO
,
'
get
'
).
resolves
({}
as
any
);
try
{
SubProjectParser
.
create
(
expReq
);
}
catch
(
e
)
{
Tx
.
check400
(
e
.
error
.
code
,
done
);
}
});
Tx
.
testExp
(
async
(
done
:
any
,
expReq
:
expRequest
,
expRes
:
expResponse
)
=>
{
expReq
.
body
.
admin
=
'
user@user.com
'
;
expReq
.
body
.
storage_class
=
'
REGIONAL
'
;
expReq
.
body
.
storage_location
=
'
XXX
'
;
expReq
.
headers
.
ltag
=
'
ltag
'
;
this
.
sandbox
.
stub
(
TenantDAO
,
'
get
'
).
resolves
({}
as
any
);
try
{
SubProjectParser
.
create
(
expReq
);
}
catch
(
e
)
{
Tx
.
check400
(
e
.
error
.
code
,
done
);
}
});
Tx
.
testExp
(
async
(
done
:
any
,
expReq
:
expRequest
,
expRes
:
expResponse
)
=>
{
expReq
.
body
.
admin
=
'
user@user.com
'
;
expReq
.
body
.
storage_class
=
'
MULTI_REGIONAL
'
;
expReq
.
body
.
storage_location
=
'
US-CENTRAL1
'
;
expReq
.
headers
.
ltag
=
'
ltag
'
;
this
.
sandbox
.
stub
(
TenantDAO
,
'
get
'
).
resolves
({}
as
any
);
try
{
SubProjectParser
.
create
(
expReq
);
}
catch
(
e
)
{
Tx
.
check400
(
e
.
error
.
code
,
done
);
}
});
Tx
.
testExp
(
async
(
done
:
any
,
expReq
:
expRequest
,
expRes
:
expResponse
)
=>
{
expReq
.
body
.
admin
=
'
user@user.com
'
;
expReq
.
body
.
storage_class
=
'
REGIONAL
'
;
expReq
.
body
.
storage_location
=
'
EU
'
;
expReq
.
headers
.
ltag
=
'
ltag
'
;
this
.
sandbox
.
stub
(
TenantDAO
,
'
get
'
).
resolves
({}
as
any
);
try
{
SubProjectParser
.
create
(
expReq
);
}
catch
(
e
)
{
Tx
.
check400
(
e
.
error
.
code
,
done
);
}
});
Tx
.
testExp
(
async
(
done
:
any
)
=>
{
process
.
env
.
GCLOUD_PROJECT
=
'
ON
'
;
this
.
journal
.
get
.
resolves
([]
as
never
);
...
...
tests/utest/services/utility.ts
View file @
4304bda4
...
...
@@ -271,7 +271,7 @@ export class TestUtilitySVC {
this
.
sandbox
.
stub
(
google
.
GCS
.
prototype
,
'
saveObject
'
);
this
.
sandbox
.
stub
(
Locker
,
'
acquireMutex
'
).
resolves
(
'
mutex
'
);
this
.
sandbox
.
stub
(
Locker
,
'
releaseMutex
'
).
resolves
();
this
.
sandbox
.
stub
(
Utils
,
'
getEmailFromTokenPayload
'
).
re
turn
s
(
'
email
'
)
this
.
sandbox
.
stub
(
google
.
GoogleSeistore
.
prototype
,
'
getEmailFromTokenPayload
'
).
re
solve
s
(
'
email
'
)
this
.
transaction
.
run
.
resolves
();
await
UtilityHandler
.
handler
(
expReq
,
expRes
,
UtilityOP
.
CP
);
Tx
.
check200
(
expRes
.
statusCode
,
done
);
...
...
@@ -297,7 +297,7 @@ export class TestUtilitySVC {
this
.
sandbox
.
stub
(
google
.
GCS
.
prototype
,
'
copy
'
);
this
.
sandbox
.
stub
(
google
.
GCS
.
prototype
,
'
saveObject
'
);
this
.
transaction
.
run
.
resolves
();
this
.
sandbox
.
stub
(
Utils
,
'
getEmailFromTokenPayload
'
).
re
turn
s
(
'
email
'
)
this
.
sandbox
.
stub
(
google
.
GoogleSeistore
.
prototype
,
'
getEmailFromTokenPayload
'
).
re
solve
s
(
'
email
'
)
await
UtilityHandler
.
handler
(
expReq
,
expRes
,
UtilityOP
.
CP
);
Tx
.
check200
(
expRes
.
statusCode
,
done
);
});
...
...
tests/utest/shared/utils.ts
View file @
4304bda4
...
...
@@ -31,7 +31,6 @@ export class TestUtils {
this
.
testGetPropertyFromTokenPayload
();
this
.
testGetIssFromPayload
();
this
.
testExpTimeFromPayload
();
this
.
testGetEmailFromTokenPayload
();
this
.
testMakeID
();
});
...
...
@@ -77,16 +76,7 @@ export class TestUtils {
});
}
private
static
testGetEmailFromTokenPayload
()
{
Tx
.
sectionInit
(
'
get email from payload
'
);
Tx
.
test
((
done
:
any
)
=>
{
const
email
=
Utils
.
getEmailFromTokenPayload
(
this
.
jwtToken
);
Tx
.
checkTrue
(
email
===
'
user@email
'
,
done
);
});
}
private
static
testMakeID
()
{
Tx
.
sectionInit
(
'
test make id
'
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment