Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
dunixir
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
teaching
dunixir
Commits
952e2b7e
Commit
952e2b7e
authored
3 years ago
by
ROUSSET Noemie
Browse files
Options
Downloads
Patches
Plain Diff
issue BR_G63 code + tests
parent
3f41892f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/local_augmentation_example.ex
+12
-0
12 additions, 0 deletions
lib/local_augmentation_example.ex
test/identity/augmentation/ident_writability_test.exs
+85
-0
85 additions, 0 deletions
test/identity/augmentation/ident_writability_test.exs
with
97 additions
and
0 deletions
lib/local_augmentation_example.ex
+
12
−
0
View file @
952e2b7e
...
...
@@ -372,6 +372,18 @@ defmodule Index.Augmentation do
:ets
.
insert
(
local_iindex
,
{
key
,
Map
.
merge
(
entry
,
%{
isBeingKicked:
!entry
.
member
})})
end
## BR_G63
def
identityWritability
(
local_iindex
)
do
:ets
.
match
(
local_iindex
,
{
:_
,
:"$1"
})
|>
Enum
.
reduce
(
true
,
fn
[
entry
],
acc
->
if
entry
[
:age
]
!=
nil
do
(
entry
.
age
<=
Constants
.
Contract
.
idtyWindow
)
&&
acc
else
acc
end
end
)
end
## BR_G73
def
identityUserIdUnicity
(
local_iindex
)
do
:ets
.
match
(
local_iindex
,
{
:_
,
:"$1"
})
...
...
This diff is collapsed.
Click to expand it.
test/identity/augmentation/ident_writability_test.exs
0 → 100644
+
85
−
0
View file @
952e2b7e
defmodule
IdentityWritabilityTest
do
use
ExUnit
.
Case
@identWritabilityOk
%{
op:
'CREATE'
,
uid:
"tic"
,
pub:
"5B8iMAzq1dNmFe3ZxFTBQkqhq4fsztg1gZvxHXCk1XYH"
,
created_on:
"7543-000044410C5370DE8DBA911A358F318096B7A269CFC2BB93272E397CC513EA0A"
,
written_on:
"167884-0001DFCA28002A8C96575E53B8CEF8317453A7B0BA255542CCF0EC8AB5E99038"
,
member:
true
,
wasMember:
true
,
kick:
false
,
age:
Constants
.
Contract
.
idtyWindow
-
10
}
@identWritabilityNok
%{
op:
'CREATE'
,
uid:
"tic"
,
pub:
"5B8iMAzq1dNmFe3ZxFTBQkqhq4fsztg1gZvxHXCk1XYH"
,
created_on:
"7543-000044410C5370DE8DBA911A358F318096B7A269CFC2BB93272E397CC513EA0A"
,
written_on:
"167884-0001DFCA28002A8C96575E53B8CEF8317453A7B0BA255542CCF0EC8AB5E99038"
,
member:
true
,
wasMember:
true
,
kick:
false
,
age:
Constants
.
Contract
.
idtyWindow
+
10
}
@identWritabilityWithoutField
%{
op:
'CREATE'
,
uid:
"tic"
,
pub:
"5B8iMAzq1dNmFe3ZxFTBQkqhq4fsztg1gZvxHXCk1XYH"
,
created_on:
"7543-000044410C5370DE8DBA911A358F318096B7A269CFC2BB93272E397CC513EA0A"
,
written_on:
"167884-0001DFCA28002A8C96575E53B8CEF8317453A7B0BA255542CCF0EC8AB5E99038"
,
member:
true
,
wasMember:
true
,
kick:
false
}
doctest
Index
.
Augmentation
.
IIndex
setup_all
do
#test with a valid age
local_iindex
=
:ets
.
new
(
:"test/local_iindex"
,
[
:set
,
:protected
])
:ets
.
insert
(
local_iindex
,
{
0
,
@identWritabilityOk
})
writabilityOneEltOk
=
Index
.
Augmentation
.
IIndex
.
identityWritability
(
local_iindex
)
:file
.
delete
(
"test/local_iindex"
)
#test with a valid age
local_iindex
=
:ets
.
new
(
:"test/local_iindex"
,
[
:set
,
:protected
])
:ets
.
insert
(
local_iindex
,
{
0
,
@identWritabilityWithoutField
})
writabilityOneEltWithoutFieldOK
=
Index
.
Augmentation
.
IIndex
.
identityWritability
(
local_iindex
)
:file
.
delete
(
"test/local_iindex"
)
#test with a valid age
local_iindex
=
:ets
.
new
(
:"test/local_iindex"
,
[
:set
,
:protected
])
:ets
.
insert
(
local_iindex
,
{
0
,
@identWritabilityWithoutField
})
:ets
.
insert
(
local_iindex
,
{
1
,
@identWritabilityOk
})
writabilityManyEltOk
=
Index
.
Augmentation
.
IIndex
.
identityWritability
(
local_iindex
)
:file
.
delete
(
"test/local_iindex"
)
#test with an invalid age
local_iindex
=
:ets
.
new
(
:"test/local_iindex"
,
[
:set
,
:protected
])
:ets
.
insert
(
local_iindex
,
{
0
,
@identWritabilityNok
})
writabilityOneEltNok
=
Index
.
Augmentation
.
IIndex
.
identityWritability
(
local_iindex
)
:file
.
delete
(
"test/local_iindex"
)
#test with an invalid age
local_iindex
=
:ets
.
new
(
:"test/local_iindex"
,
[
:set
,
:protected
])
:ets
.
insert
(
local_iindex
,
{
0
,
@identWritabilityWithoutField
})
:ets
.
insert
(
local_iindex
,
{
1
,
@identWritabilityNok
})
:ets
.
insert
(
local_iindex
,
{
2
,
@identWritabilityOk
})
writabilityManyEltNok
=
Index
.
Augmentation
.
IIndex
.
identityWritability
(
local_iindex
)
:file
.
delete
(
"test/local_iindex"
)
{
:ok
,
writabilityOneEltOk:
writabilityOneEltOk
,
writabilityOneEltWithoutFieldOK:
writabilityOneEltWithoutFieldOK
,
writabilityManyEltOk:
writabilityManyEltOk
,
writabilityOneEltNok:
writabilityOneEltNok
,
writabilityManyEltNok:
writabilityManyEltNok
}
end
test
"check identity writability"
,
state
do
assert
state
.
writabilityOneEltOk
==
true
assert
state
.
writabilityOneEltWithoutFieldOK
==
true
assert
state
.
writabilityManyEltOk
==
true
assert
state
.
writabilityOneEltNok
==
false
assert
state
.
writabilityManyEltNok
==
false
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment