|
|
@@ -166,6 +166,82 @@ describe("Society Operations", function () {
|
|
166
|
166
|
done();
|
|
167
|
167
|
});
|
|
168
|
168
|
});
|
|
169
|
|
- });
|
|
|
169
|
+ }); //end GET /society/view/:societyid/events
|
|
|
170
|
+
|
|
|
171
|
+ describe("POST /society/join/", function () {
|
|
|
172
|
+
|
|
|
173
|
+ it("successfully joins the society", function (done) {
|
|
|
174
|
+ request({
|
|
|
175
|
+ url: base_url + "/user/auth/",
|
|
|
176
|
+ method: "POST",
|
|
|
177
|
+ json: {
|
|
|
178
|
+ user: "foo456",
|
|
|
179
|
+ password: "foofoo"
|
|
|
180
|
+ }
|
|
|
181
|
+ }, function (error, response, body) {
|
|
|
182
|
+ foo456auth = body["auth-key"];
|
|
|
183
|
+ request({
|
|
|
184
|
+ url: base_url + "/society/join/",
|
|
|
185
|
+ method: "POST",
|
|
|
186
|
+ json: {
|
|
|
187
|
+ society: "foo123soc",
|
|
|
188
|
+ auth: foo456auth
|
|
|
189
|
+ }
|
|
|
190
|
+ }, function (error, response, body) {
|
|
|
191
|
+ expect(response.statusCode).toBe(200);
|
|
|
192
|
+ expect(body.success).toBe(1);
|
|
|
193
|
+ expect(body.error).toBe(0);
|
|
|
194
|
+ done();
|
|
|
195
|
+ });
|
|
|
196
|
+ });
|
|
|
197
|
+ });
|
|
|
198
|
+
|
|
|
199
|
+ it("doesn't join the society twice", function (done) {
|
|
|
200
|
+ request({
|
|
|
201
|
+ url: base_url + "/society/join/",
|
|
|
202
|
+ method: "POST",
|
|
|
203
|
+ json: {
|
|
|
204
|
+ society: "foo123soc",
|
|
|
205
|
+ auth: foo456auth
|
|
|
206
|
+ }
|
|
|
207
|
+ }, function (error, response, body) {
|
|
|
208
|
+ expect(response.statusCode).toBe(200);
|
|
|
209
|
+ expect(body.success).toBe(0);
|
|
|
210
|
+ expect(body.error).toBe(1);
|
|
|
211
|
+ done();
|
|
|
212
|
+ });
|
|
|
213
|
+ });
|
|
|
214
|
+
|
|
|
215
|
+ it("rejects invalid authentication keys", function (done) {
|
|
|
216
|
+ request({
|
|
|
217
|
+ url: base_url + "/society/join/",
|
|
|
218
|
+ method: "POST",
|
|
|
219
|
+ json: {
|
|
|
220
|
+ society: "foo123soc",
|
|
|
221
|
+ auth: "nah"
|
|
|
222
|
+ }
|
|
|
223
|
+ }, function (error, response, body) {
|
|
|
224
|
+ expect(response.statusCode).toBe(200);
|
|
|
225
|
+ expect(body.success).toBe(0);
|
|
|
226
|
+ expect(body.error).toBe(3);
|
|
|
227
|
+ done();
|
|
|
228
|
+ });
|
|
|
229
|
+ });
|
|
|
230
|
+
|
|
|
231
|
+ it("rejects malformed requests", function (done) {
|
|
|
232
|
+ request({
|
|
|
233
|
+ url: base_url + "/society/join/",
|
|
|
234
|
+ method: "POST",
|
|
|
235
|
+ json: {
|
|
|
236
|
+ society: "foo123soc",
|
|
|
237
|
+ }
|
|
|
238
|
+ }, function (error, response, body) {
|
|
|
239
|
+ expect(response.statusCode).toBe(200);
|
|
|
240
|
+ expect(body.success).toBe(0);
|
|
|
241
|
+ expect(body.error).toBe(2);
|
|
|
242
|
+ done();
|
|
|
243
|
+ });
|
|
|
244
|
+ });
|
|
|
245
|
+ }); //end POST /society/join/
|
|
170
|
246
|
|
|
171
|
247
|
});
|