Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ARSnova Backend
Manage
Activity
Members
Labels
Plan
Issues
27
Issue boards
Milestones
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Privacy
Imprint
Contact
Snippets
Groups
Projects
Show more breadcrumbs
ARSnova
ARSnova Backend
Commits
5085f0e2
There was an error fetching the commit references. Please try again later.
Commit
5085f0e2
authored
10 years ago
by
Paul-Christian Volkmer
Browse files
Options
Downloads
Patches
Plain Diff
Fixed issue #10524: Interposed questions can be removed from session owner
parent
ce8d0267
No related merge requests found
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/de/thm/arsnova/services/QuestionService.java
+112
-112
112 additions, 112 deletions
src/main/java/de/thm/arsnova/services/QuestionService.java
src/test/java/de/thm/arsnova/services/QuestionServiceTest.java
+13
-7
13 additions, 7 deletions
...est/java/de/thm/arsnova/services/QuestionServiceTest.java
with
125 additions
and
119 deletions
src/main/java/de/thm/arsnova/services/QuestionService.java
+
112
−
112
View file @
5085f0e2
This diff is collapsed.
Click to expand it.
src/test/java/de/thm/arsnova/services/QuestionServiceTest.java
+
13
−
7
View file @
5085f0e2
...
...
@@ -63,10 +63,10 @@ public class QuestionServiceTest {
@Autowired
private
StubDatabaseDao
databaseDao
;
private
void
setAuthenticated
(
boolean
isAuthenticated
,
String
username
)
{
private
void
setAuthenticated
(
final
boolean
isAuthenticated
,
final
String
username
)
{
if
(
isAuthenticated
)
{
List
<
GrantedAuthority
>
ga
=
new
ArrayList
<
GrantedAuthority
>();
UsernamePasswordAuthenticationToken
token
=
new
UsernamePasswordAuthenticationToken
(
username
,
"secret"
,
ga
);
final
List
<
GrantedAuthority
>
ga
=
new
ArrayList
<
GrantedAuthority
>();
final
UsernamePasswordAuthenticationToken
token
=
new
UsernamePasswordAuthenticationToken
(
username
,
"secret"
,
ga
);
SecurityContextHolder
.
getContext
().
setAuthentication
(
token
);
userService
.
setUserAuthenticated
(
isAuthenticated
,
username
);
}
else
{
...
...
@@ -105,7 +105,7 @@ public class QuestionServiceTest {
@Test
public
void
testShouldMarkInterposedQuestionAsReadIfSessionCreator
()
throws
Exception
{
setAuthenticated
(
true
,
"ptsr00"
);
InterposedQuestion
theQ
=
new
InterposedQuestion
();
final
InterposedQuestion
theQ
=
new
InterposedQuestion
();
theQ
.
setRead
(
false
);
theQ
.
set_id
(
"the internal id"
);
theQ
.
setSessionId
(
"12345678"
);
...
...
@@ -119,7 +119,7 @@ public class QuestionServiceTest {
@Test
public
void
testShouldNotMarkInterposedQuestionAsReadIfRegularUser
()
throws
Exception
{
setAuthenticated
(
true
,
"regular user"
);
InterposedQuestion
theQ
=
new
InterposedQuestion
();
final
InterposedQuestion
theQ
=
new
InterposedQuestion
();
theQ
.
setRead
(
false
);
theQ
.
set_id
(
"the internal id"
);
theQ
.
setSessionId
(
"12345678"
);
...
...
@@ -133,15 +133,21 @@ public class QuestionServiceTest {
@Test
(
expected
=
ForbiddenException
.
class
)
public
void
testShouldSaveQuestion
()
throws
Exception
{
setAuthenticated
(
true
,
"regular user"
);
Question
question
=
new
Question
();
final
Question
question
=
new
Question
();
question
.
setSessionKeyword
(
"12345678"
);
question
.
setQuestionVariant
(
"freetext"
);
questionService
.
saveQuestion
(
question
);
}
@Test
(
expected
=
ForbiddenException
.
class
)
public
void
testShouldDeleteQuestion
()
throws
Exception
{
public
void
testShould
Not
DeleteQuestion
()
throws
Exception
{
setAuthenticated
(
true
,
"otheruser"
);
questionService
.
deleteQuestion
(
"a1a2a3a4a5a6a7a8a9a"
);
}
@Test
(
expected
=
ForbiddenException
.
class
)
public
void
testShouldNotDeleteInterposedQuestion
()
throws
Exception
{
setAuthenticated
(
true
,
"otheruser"
);
questionService
.
deleteInterposedQuestion
(
"a1a2a3a4a5a6a7a8a9a"
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
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