package mock

import "github.com/ditsuke/go-amizone/amizone/internal/mock"

Index

Constants

const (
	ValidUser = "fakeUsername"
	ValidPass = "fakePassword"

	InvalidUser = "this-user-does-not-exist"
	InvalidPass = "this-password-does-not-either"

	AuthCookie        = "fakeAuthCookie"
	VerificationToken = "fakeRequestVerificationToken"
	SessionID         = "fakeSessionId"

	// StudentUUID is the UUID associated with the student used across testdata in filesystem.
	StudentUUID = "98RFGK88-A01C-1JJO-N73D-4BJR42B33J51"

	StudentName             = "John Doe"
	StudentEnrollmentNumber = "A2305221007"
	StudentIDCardNumber     = "95188911"
	StudentBloodGroup       = "B-ve"
	StudentProgram          = "B.Tech (CSE)"
	StudentBatch            = "2020-2024"

	StudentIDValidity Timestamp = 1719705600
	StudentDOB        Timestamp = 986428800

	// A valid mac address, and the first mac in the mock wifi pages
	ValidMac1   = "55-04-2d-e7-be-a4"
	ValidMac2   = "fd-d5-14-18-0c-8b"
	ValidMacNew = "dd-d5-14-18-0c-8c"
)

Constants for use in tests using the mock package to create Gock requests, etc.

const BaseUrl = "https://s.amizone.net"

Functions

func GockRegisterAuthenticatedGet

func GockRegisterAuthenticatedGet(endpoint string, file File) error

GockRegisterAuthenticatedGet registers an authenticated GET request for the relative endpoint passed. The second parameter is used as the response body of the request.

func GockRegisterAuthenticatedGetWithParams

func GockRegisterAuthenticatedGetWithParams(endpoint string, params map[string]string, file File) error

GockRegisterAuthenticatedGetWithParams registers an authenticated GET request for the relative endpoint passed. The second parameter is used as the parameters of the request. The third parameter is used as the response body of the request.

func GockRegisterAuthenticatedPost

func GockRegisterAuthenticatedPost(endpoint string, requestMatcher gock.MatchFunc, file File) error

func GockRegisterCalendarEndpoint

func GockRegisterCalendarEndpoint(start, end string, file File) error

func GockRegisterCurrentCoursesPage

func GockRegisterCurrentCoursesPage() error

func GockRegisterExamResultPage

func GockRegisterExamResultPage() error

func GockRegisterExamResultRequest

func GockRegisterExamResultRequest(semesterRef string) error

func GockRegisterHomePageLoggedIn

func GockRegisterHomePageLoggedIn() error

GockRegisterHomePageLoggedIn registers a gock route for the amizone home page, serving the home page for a logged-in user from the mock filesystem. The request must have the referrers and cookies expected by the home page.

func GockRegisterLoginPage

func GockRegisterLoginPage() error

GockRegisterLoginPage registers a gock route for the amizone login page serving the login page from the mock filesystem.

func GockRegisterLoginRequest

func GockRegisterLoginRequest() error

GockRegisterLoginRequest registers 2 gock routes - one for valid credentials and one for invalid credentials. Valid credentials: ValidUser, ValidPass Invalid credentials: InvalidUser, InvalidPass

func GockRegisterProfilePage

func GockRegisterProfilePage() error

func GockRegisterSemWiseCoursesPage

func GockRegisterSemWiseCoursesPage() error

func GockRegisterSemesterCoursesRequest

func GockRegisterSemesterCoursesRequest(semesterRef string) error

func GockRegisterUnauthenticatedGet

func GockRegisterUnauthenticatedGet(endpoint string) error

GockRegisterUnauthenticatedGet registers an unauthenticated GET request for the relative endpoint passed.

func GockRegisterUnauthenticatedPost

func GockRegisterUnauthenticatedPost(endpoint string, requestBody string, responseBody io.Reader)

func GockRegisterWifiInfo

func GockRegisterWifiInfo() error

func GockRegisterWifiInfoOneSlot

func GockRegisterWifiInfoOneSlot() error

func GockRegisterWifiMacDeletion

func GockRegisterWifiMacDeletion(params map[string]string, response File) error

func GockRegisterWifiRegistration

func GockRegisterWifiRegistration(payload url.Values) error

GockRegisterWifiRegistration() registers a gock route for the wifi registration page. The request must have the expected referrer, cookies and post data to be successful.

Types

type ExpectedJSON

type ExpectedJSON string
const (
	ExpectedFacultyFeedbackSpec  ExpectedJSON = "testdata/expected__faculty_feedback_spec.json"
	ExpectedExamScheduleWithRoom ExpectedJSON = "testdata/expected__exam_schedule_with_room.json"
)

func (ExpectedJSON) Open

func (f ExpectedJSON) Open() (fs.File, error)

Open returns a fs.File interface to the file in filesystem, the mock filesystem.

type File

type File string
const (
	DiaryEventsNone                 File = "testdata/diary_events_none.json"
	DiaryEventsJSON                 File = "testdata/diary_events.json"
	DiaryEventsSmallJSON            File = "testdata/diary_events_small.json"
	ExaminationSchedule             File = "testdata/examination_schedule.html"
	ExaminationScheduleWithLocation File = "testdata/examination_schedule_exam_room.html"
	HomePageLoggedIn                File = "testdata/home_page_logged_in.html"
	LoginPage                       File = "testdata/login_page.html"
	CoursesPage                     File = "testdata/my_courses.html"
	CoursesPageSemWise              File = "testdata/courses_semwise.html"
	IDCardPage                      File = "testdata/id_card_page.html"
	WifiPage                        File = "testdata/wifi_mac_registration.html"
	WifiPageOneSlotPopulated        File = "testdata/wifi_mac_registration_one_empty.html"
	FacultyPage                     File = "testdata/faculty_page.html"
	ExaminationResultPage           File = "testdata/examination_result.html"
)

Constants for file paths in the filesystem embedded filesystem.

func (File) Open

func (f File) Open() (fs.File, error)

Open returns a fs.File interface to the file in filesystem, the mock filesystem.

type Timestamp

type Timestamp int64

func (Timestamp) Time

func (t Timestamp) Time() time.Time

Source Files

constants.go routes.go testdata.go

Version
v0.8.0 (latest)
Published
Jun 9, 2023
Platform
linux/amd64
Imports
9 packages
Last checked
1 day ago

Tools for package owners.