1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
|
/*
This file is part of GNU Anastasis
(C) 2021-2022 Anastasis SARL
GNU Anastasis is free software; you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
GNU Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with
GNU Anastasis; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
/**
*
* @author Sebastian Javier Marchano (sebasjm)
*/
import {
ChallengeFeedbackStatus,
ReducerState,
} from "@gnu-taler/anastasis-core";
import { createExample, reducerStatesExample } from "../../../utils/index.js";
import { authMethods as TestedComponent, KnownAuthMethods } from "./index.js";
export default {
title: "Auth method: Question solve",
component: TestedComponent,
args: {
order: 5,
},
argTypes: {
onUpdate: { action: "onUpdate" },
onBack: { action: "onBack" },
},
};
const type: KnownAuthMethods = "question";
export const WithoutFeedback = createExample(
TestedComponent[type].solve,
{
...reducerStatesExample.challengeSolving,
recovery_information: {
challenges: [
{
instructions: "does P equals NP?",
type: "question",
uuid: "uuid-1",
},
],
policies: [],
},
selected_challenge_uuid: "uuid-1",
} as ReducerState,
{
id: "uuid-1",
},
);
const recovery_information = {
challenges: [
{
instructions: "does P equal NP?",
type: "question",
uuid: "ASDASDSAD!1",
},
],
policies: [],
};
export const CodeInFileFeedback = createExample(TestedComponent[type].solve, {
...reducerStatesExample.challengeSolving,
recovery_information,
selected_challenge_uuid: "ASDASDSAD!1",
challenge_feedback: {
"ASDASDSAD!1": {
state: ChallengeFeedbackStatus.CodeInFile,
filename: "asd",
display_hint: "hint",
},
},
} as ReducerState);
export const CodeSentFeedback = createExample(TestedComponent[type].solve, {
...reducerStatesExample.challengeSolving,
recovery_information,
selected_challenge_uuid: "ASDASDSAD!1",
challenge_feedback: {
"ASDASDSAD!1": {
state: ChallengeFeedbackStatus.CodeSent,
address_hint: "asdasd",
display_hint: "qweqweqw",
},
},
} as ReducerState);
export const SolvedFeedback = createExample(TestedComponent[type].solve, {
...reducerStatesExample.challengeSolving,
recovery_information,
selected_challenge_uuid: "ASDASDSAD!1",
challenge_feedback: {
"ASDASDSAD!1": {
state: ChallengeFeedbackStatus.Solved,
},
},
} as ReducerState);
export const ServerFailureFeedback = createExample(
TestedComponent[type].solve,
{
...reducerStatesExample.challengeSolving,
recovery_information,
selected_challenge_uuid: "ASDASDSAD!1",
challenge_feedback: {
"ASDASDSAD!1": {
state: ChallengeFeedbackStatus.ServerFailure,
http_status: 500,
},
},
} as ReducerState,
);
export const TruthUnknownFeedback = createExample(TestedComponent[type].solve, {
...reducerStatesExample.challengeSolving,
recovery_information,
selected_challenge_uuid: "ASDASDSAD!1",
challenge_feedback: {
"ASDASDSAD!1": {
state: ChallengeFeedbackStatus.TruthUnknown,
},
},
} as ReducerState);
export const TalerPaymentFeedback = createExample(TestedComponent[type].solve, {
...reducerStatesExample.challengeSolving,
recovery_information,
selected_challenge_uuid: "ASDASDSAD!1",
challenge_feedback: {
"ASDASDSAD!1": {
state: ChallengeFeedbackStatus.TalerPayment,
payment_secret: "secret",
provider: "asdasdas",
taler_pay_uri: "taler://pay/...",
},
},
} as ReducerState);
export const UnsupportedFeedback = createExample(TestedComponent[type].solve, {
...reducerStatesExample.challengeSolving,
recovery_information,
selected_challenge_uuid: "ASDASDSAD!1",
challenge_feedback: {
"ASDASDSAD!1": {
state: ChallengeFeedbackStatus.Unsupported,
unsupported_method: "method",
},
},
} as ReducerState);
export const RateLimitExceededFeedback = createExample(
TestedComponent[type].solve,
{
...reducerStatesExample.challengeSolving,
recovery_information,
selected_challenge_uuid: "ASDASDSAD!1",
challenge_feedback: {
"ASDASDSAD!1": {
state: ChallengeFeedbackStatus.RateLimitExceeded,
},
},
} as ReducerState,
);
export const IbanInstructionsFeedback = createExample(
TestedComponent[type].solve,
{
...reducerStatesExample.challengeSolving,
recovery_information,
selected_challenge_uuid: "ASDASDSAD!1",
challenge_feedback: {
"ASDASDSAD!1": {
state: ChallengeFeedbackStatus.IbanInstructions,
challenge_amount: "EUR:1",
target_iban: "DE12345789000",
target_business_name: "Data Loss Incorporated",
wire_transfer_subject: "Anastasis 987654321",
answer_code: 987654321,
},
},
} as ReducerState,
);
export const IncorrectAnswerFeedback = createExample(
TestedComponent[type].solve,
{
...reducerStatesExample.challengeSolving,
recovery_information,
selected_challenge_uuid: "ASDASDSAD!1",
challenge_feedback: {
"ASDASDSAD!1": {
state: ChallengeFeedbackStatus.IncorrectAnswer,
},
},
} as ReducerState,
);
// export const AuthIbanFeedback = createExample(TestedComponent[type].solve, {
// ...reducerStatesExample.challengeSolving,
// recovery_information: {
// challenges: [
// {
// instructions: "does P equals NP?",
// type: "question",
// uuid: "ASDASDSAD!1",
// },
// ],
// policies: [],
// },
// selected_challenge_uuid: "ASDASDSAD!1",
// challenge_feedback: {
// "ASDASDSAD!1": ibanFeedback,
// },
// } as ReducerState);
// export const PaymentFeedback = createExample(TestedComponent[type].solve, {
// ...reducerStatesExample.challengeSolving,
// recovery_information: {
// challenges: [
// {
// instructions: "does P equals NP?",
// type: "question",
// uuid: "ASDASDSAD!1",
// },
// ],
// policies: [],
// },
// selected_challenge_uuid: "ASDASDSAD!1",
// challenge_feedback: {
// "ASDASDSAD!1": {
// state: ChallengeFeedbackStatus.TalerPayment,
// taler_pay_uri: "taler://pay/...",
// provider: "https://localhost:8080/",
// payment_secret: "3P4561HAMHRRYEYD6CM6J7TS5VTD5SR2K2EXJDZEFSX92XKHR4KG",
// },
// },
// } as ReducerState);
|